Search in sources :

Example 1 with MapEntityViewBuilderListener

use of com.blazebit.persistence.view.MapEntityViewBuilderListener in project blaze-persistence by Blazebit.

the class EntityViewBuilderBaseImpl method withBuilder.

@Override
public <K, V> EntityViewNestedBuilder<V, ? extends BuilderType, ?> withBuilder(MapAttribute<ViewType, K, V> attribute, K key) {
    if (key == null) {
        throw new IllegalArgumentException("Illegal null key!");
    }
    AbstractAttribute<?, ?> attr = getAttribute(attribute);
    checkAttribute(attr, MapAttribute.class, "Map");
    Type<?> keyType = ((MapAttribute<?, ?, ?>) attr).getKeyType();
    checkType(attr.getElementType(), "element", attr);
    key = getValue(keyType, key);
    Map<ManagedViewType<? extends V>, String> inheritanceSubtypeMappings = ((PluralAttribute<?, ?, V>) attr).getElementInheritanceSubtypeMappings();
    return new EntityViewNestedBuilderImpl<>(evm, (ManagedViewTypeImplementor<V>) attr.getElementType(), inheritanceSubtypeMappings, optionalParameters, (BuilderType) this, new MapEntityViewBuilderListener(getMap(attr), key));
}
Also used : MapAttribute(com.blazebit.persistence.view.metamodel.MapAttribute) ManagedViewType(com.blazebit.persistence.view.metamodel.ManagedViewType) PluralAttribute(com.blazebit.persistence.view.metamodel.PluralAttribute) MapEntityViewBuilderListener(com.blazebit.persistence.view.MapEntityViewBuilderListener)

Example 2 with MapEntityViewBuilderListener

use of com.blazebit.persistence.view.MapEntityViewBuilderListener in project blaze-persistence by Blazebit.

the class EntityViewBuilderBaseImpl method withMapBuilder.

private <V> EntityViewNestedBuilder<V, ? extends BuilderType, ?> withMapBuilder(AbstractAttribute<?, ?> attr, Object key) {
    if (key == null) {
        throw new IllegalArgumentException("Illegal null key!");
    }
    checkAttribute(attr, MapAttribute.class, "Map");
    Type<?> keyType = ((MapAttribute<?, ?, ?>) attr).getKeyType();
    checkType(attr.getElementType(), "element", attr);
    key = getValue(keyType, key);
    Map<ManagedViewType<? extends V>, String> inheritanceSubtypeMappings = ((PluralAttribute<?, ?, V>) attr).getElementInheritanceSubtypeMappings();
    return new EntityViewNestedBuilderImpl<>(evm, (ManagedViewTypeImplementor<V>) attr.getElementType(), inheritanceSubtypeMappings, optionalParameters, (BuilderType) this, new MapEntityViewBuilderListener(getMap(attr), key));
}
Also used : MapAttribute(com.blazebit.persistence.view.metamodel.MapAttribute) ManagedViewType(com.blazebit.persistence.view.metamodel.ManagedViewType) PluralAttribute(com.blazebit.persistence.view.metamodel.PluralAttribute) MapEntityViewBuilderListener(com.blazebit.persistence.view.MapEntityViewBuilderListener)

Aggregations

MapEntityViewBuilderListener (com.blazebit.persistence.view.MapEntityViewBuilderListener)2 ManagedViewType (com.blazebit.persistence.view.metamodel.ManagedViewType)2 MapAttribute (com.blazebit.persistence.view.metamodel.MapAttribute)2 PluralAttribute (com.blazebit.persistence.view.metamodel.PluralAttribute)2