MapProperty (cayenne-doc: Cayenne Documentation 5.0-M2 API)
Description: declaration: package: org.apache.cayenne.exp.property, class: MapProperty

# Class MapProperty<K, V extends Persistent>

java.lang.Object
org.apache.cayenne.exp.property.BaseProperty<Map<K,V>>
org.apache.cayenne.exp.property.MapProperty<K,V>

All Implemented Interfaces:
  `PathProperty<Map<K,V>>, Property<Map<K,V>>, RelationshipProperty<Map<K,V>>`

public class MapProperty<K, V extends Persistent> extends BaseProperty<Map<K,V>> implements RelationshipProperty<Map<K,V>>
Property that represents to-many relationship mapped on `Map`.

Since:
  4.2
See Also:
  - `org.apache.cayenne.exp.property`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected Class<V>`
  `entityType`
  `protected Class<K>`
  `keyType`

  ### Fields inherited from class BaseProperty

  `expressionSupplier, path, type`
  Modifier and Type
  Field
  Description
  `protected final Supplier<Expression>`
  `expressionSupplier`
  Expression provider for the property
  `protected final CayennePath`
  `path`
  Path of this property
  `protected final Class<Map<K,V>>`
  `type`
  Explicit type of the property

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `MapProperty(CayennePath path, Expression expression, Class<K> keyType, Class<V> entityType)`
  Constructs a new property with the given path and expression

- ## Method Summary

  Modifier and Type
  Method
  Description
  `MapProperty<K,V>`
  `alias(String alias)`
  Creates alias with different name for this property
  `Expression`
  `contains(Collection<V> values)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  since 5.0 in favour of `containsValuesCollection(Collection)`
  `Expression`
  `contains(V value)`
  `final Expression`
  `contains(V firstValue, V... moreValues)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  since 5.0 in favour of `containsValues(V...)`
  `Expression`
  `containsId(Object id)`
  `Expression`
  `containsId(Object firstId, Object... moreId)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  since 5.0 in favour of `containsIds(Object...)`
  `Expression`
  `containsId(Collection<Object> ids)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  since 5.0 in favour of `containsIdsCollection(Collection)`
  `Expression`
  `containsIds(Object... ids)`
  `Expression`
  `containsIdsCollection(Collection<?> ids)`
  `final Expression`
  `containsValues(V... values)`
  `Expression`
  `containsValuesCollection(Collection<V> values)`
  `MapProperty<K,V>`
  `enclosing()`
  This operator allows to access properties of the enclosing query from the subquery.
  `EntityProperty<V>`
  `flat()`
  Create new "flat" property for toMany relationship.
  `protected Class<V>`
  `getEntityType()`
  `protected Class<K>`
  `getKeyType()`
  `Expression`
  `notContains(Collection<V> values)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  since 5.0 in favour of `notContainsValuesCollection(Collection)`
  `Expression`
  `notContains(V value)`
  `final Expression`
  `notContains(V firstValue, V... moreValues)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  since 5.0 in favour of `notContainsValues(V...)`
  `Expression`
  `notContainsId(Object id)`
  `Expression`
  `notContainsId(Object firstId, Object... moreId)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  since 5.0 in favour of `notContainsIds(Object...)`
  `Expression`
  `notContainsId(Collection<Object> ids)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  since 5.0 in favour of `notContainsIdsCollection(Collection)`
  `Expression`
  `notContainsIds(Object... ids)`
  `Expression`
  `notContainsIdsCollection(Collection<?> ids)`
  `final Expression`
  `notContainsValues(V... values)`
  `Expression`
  `notContainsValuesCollection(Collection<V> values)`
  `MapProperty<K,V>`
  `outer()`
  Returns a version of this property that represents an OUTER join.

  ### Methods inherited from class BaseProperty

  `aggregate, asc, ascInsensitive, ascInsensitives, ascs, count, countDistinct, desc, descInsensitive, descInsensitives, descs, eq, eq, equals, function, function, getAlias, getExpression, getFrom, getFromAll, getName, getPath, getType, hashCode, in, in, in, isFalse, isNotNull, isNull, isTrue, ne, ne, nin, nin, nin, operator, operator, setIn, setInAll`
  Modifier and Type
  Method
  Description
  `<T> BaseProperty<T>`
  `aggregate(String function, Class<T> type)`
  `Ordering`
  `asc()`
  `Ordering`
  `ascInsensitive()`
  `Orderings`
  `ascInsensitives()`
  `Orderings`
  `ascs()`
  `NumericProperty<Long>`
  `count()`
  `NumericProperty<Long>`
  `countDistinct()`
  `Ordering`
  `desc()`
  `Ordering`
  `descInsensitive()`
  `Orderings`
  `descInsensitives()`
  `Orderings`
  `descs()`
  `Expression`
  `eq(Map<K,V> value)`
  `Expression`
  `eq(BaseProperty<?> value)`
  `boolean`
  `equals(Object o)`
  `<T> BaseProperty<T>`
  `function(String functionName, Class<T> returnType, Object... arguments)`
  `<T> BaseProperty<T>`
  `function(String functionName, Class<T> returnType, BaseProperty<?>... arguments)`
  `String`
  `getAlias()`
  `Expression`
  `getExpression()`
  This method returns fresh copy of the expression for each call.
  `Map<K,V>`
  `getFrom(Object bean)`
  Extracts property value from an object using JavaBean-compatible introspection with one addition - a property can be a dot-separated property name path.
  `List<Map<K,V>>`
  `getFromAll(Collection<?> beans)`
  Extracts property value from a collection of objects using JavaBean-compatible introspection with one addition - a property can be a dot-separated property name path.
  `String`
  `getName()`
  `CayennePath`
  `getPath()`
  `Class<Map<K,V>>`
  `getType()`
  `int`
  `hashCode()`
  `Expression`
  `in(Map<K,V> firstValue, Map<K,V>... moreValues)`
  `Expression`
  `in(Collection<Map<K,V>> values)`
  `Expression`
  `in(ColumnSelect<? extends Map<K,V>> subquery)`
  `Expression`
  `isFalse()`
  `Expression`
  `isNotNull()`
  `Expression`
  `isNull()`
  `Expression`
  `isTrue()`
  `Expression`
  `ne(Map<K,V> value)`
  `Expression`
  `ne(BaseProperty<?> value)`
  `Expression`
  `nin(Map<K,V> firstValue, Map<K,V>... moreValues)`
  `Expression`
  `nin(Collection<Map<K,V>> values)`
  `Expression`
  `nin(ColumnSelect<? extends Map<K,V>> subquery)`
  `<T> BaseProperty<T>`
  `operator(String operator, Class<T> returnType, Object... arguments)`
  `<T> BaseProperty<T>`
  `operator(String operator, Class<T> returnType, BaseProperty<?>... arguments)`
  `void`
  `setIn(Object bean, Map<K,V> value)`
  Sets a property value in 'obj' using JavaBean-compatible introspection with one addition - a property can be a dot-separated property name path.
  `void`
  `setInAll(Collection<?> beans, Map<K,V> value)`
  Sets a property value in a collection of objects using JavaBean-compatible introspection with one addition - a property can be a dot-separated property name path.

  ### Methods inherited from class Object

  `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface PathProperty

  `dot, dot, dot, dot, dot`
  Modifier and Type
  Method
  Description
  `default BaseProperty<Object>`
  `dot(String property)`
  Constructs a property path by appending the argument to the existing property separated by a dot.
  `default <T> BaseProperty<T>`
  `dot(BaseProperty<T> property)`
  Constructs a new property path by appending the argument to the existing property separated by a dot.
  `default <T> DateProperty<T>`
  `dot(DateProperty<T> property)`
  Constructs a new property path by appending the argument to the existing property separated by a dot.
  `default <T extends Number>
  NumericProperty<T>`
  `dot(NumericProperty<T> property)`
  Constructs a new property path by appending the argument to the existing property separated by a dot.
  `default <T extends CharSequence>
  StringProperty<T>`
  `dot(StringProperty<T> property)`
  Constructs a new property path by appending the argument to the existing property separated by a dot.

  ### Methods inherited from interface RelationshipProperty

  `disjoint, disjointById, dot, dot, dot, dot, dot, dot, dot, exists, joint, notExists`
  Modifier and Type
  Method
  Description
  `default PrefetchTreeNode`
  `disjoint()`
  Returns a prefetch tree that follows this property path, potentially spanning a number of phantom nodes, and having a single leaf with "disjoint" prefetch semantics.
  `default PrefetchTreeNode`
  `disjointById()`
  Returns a prefetch tree that follows this property path, potentially spanning a number of phantom nodes, and having a single leaf with "disjoint by id" prefetch semantics.
  `default <T> BaseIdProperty<T>`
  `dot(BaseIdProperty<T> property)`
  Constructs a new property path by appending the argument to the existing property separated by a dot.
  `default <T extends EmbeddableObject>
  EmbeddableProperty<T>`
  `dot(EmbeddableProperty<T> property)`
  Constructs a new property path by appending the argument to the existing property separated by a dot.
  `default <T extends Persistent>
  EntityProperty<T>`
  `dot(EntityProperty<T> property)`
  Constructs a new property path by appending the argument to the existing property separated by a dot.
  `default <T extends Persistent>
  ListProperty<T>`
  `dot(ListProperty<T> property)`
  Constructs a new property path by appending the argument to the existing property separated by a dot.
  `default <K, V extends Persistent>
  MapProperty<K,V>`
  `dot(MapProperty<K,V> property)`
  Constructs a new property path by appending the argument to the existing property separated by a dot.
  `default <T extends Number>
  NumericIdProperty<T>`
  `dot(NumericIdProperty<T> property)`
  Constructs a new property path by appending the argument to the existing property separated by a dot.
  `default <T extends Persistent>
  SetProperty<T>`
  `dot(SetProperty<T> property)`
  Constructs a new property path by appending the argument to the existing property separated by a dot.
  `default Expression`
  `exists()`
  `default PrefetchTreeNode`
  `joint()`
  Returns a prefetch tree that follows this property path, potentially spanning a number of phantom nodes, and having a single leaf with "joint" prefetch semantics.
  `default Expression`
  `notExists()`

- ## Field Details

  - ### keyType

    protected Class<K> keyType

  - ### entityType

    protected Class<V extends Persistent> entityType

- ## Constructor Details

  - ### MapProperty

    protected MapProperty(CayennePath path, Expression expression, Class<K> keyType, Class<V> entityType)
    Constructs a new property with the given path and expression
    Parameters:
      `path` - of the property (will be used as alias for the expression)
      `expression` - expression for property
      `keyType` - type of keys of the property
      `entityType` - type of related entities
    See Also:
      - `PropertyFactory.createMap(String, Expression, Class, Class)`

- ## Method Details

  - ### flat

    public EntityProperty<V> flat()

    Create new "flat" property for toMany relationship.

    Example:

            List<Object[]> result = ObjectSelect
                 .columnQuery(Artist.class, Artist.ARTIST_NAME, Artist.PAINTING_ARRAY.flat(Painting.class))
                 .select(context);

  - ### contains

    public Expression contains(V value)
    Returns:
      An expression representing equality to a value.

  - ### notContains

    public Expression notContains(V value)
    Returns:
      An expression representing inequality to a value.

  - ### contains

    @Deprecated(since="5.0", forRemoval=true) @SafeVarargs public final Expression contains(V firstValue, V... moreValues)
    Deprecated, for removal: This API element is subject to removal in a future version.
    since 5.0 in favour of `containsValues(V...)`
    Returns:
      An expression for finding objects with values in the given set.

  - ### containsValues

    @SafeVarargs public final Expression containsValues(V... values)
    Returns:
      An expression for finding objects with values in the given set.
    Since:
      5.0

  - ### contains

    @Deprecated(since="5.0", forRemoval=true) public Expression contains(Collection<V> values)
    Deprecated, for removal: This API element is subject to removal in a future version.
    since 5.0 in favour of `containsValuesCollection(Collection)`
    Returns:
      An expression for finding objects with values in the given set.

  - ### containsValuesCollection

    public Expression containsValuesCollection(Collection<V> values)
    Returns:
      An expression for finding objects with values in the given set.
    Since:
      5.0

  - ### notContains

    @Deprecated(since="5.0", forRemoval=true) public Expression notContains(Collection<V> values)
    Deprecated, for removal: This API element is subject to removal in a future version.
    since 5.0 in favour of `notContainsValuesCollection(Collection)`
    Returns:
      An expression for finding objects with values not in the given set.

  - ### notContainsValuesCollection

    public Expression notContainsValuesCollection(Collection<V> values)
    Returns:
      An expression for finding objects with values in the given set.
    Since:
      5.0

  - ### notContains

    @Deprecated(since="5.0", forRemoval=true) @SafeVarargs public final Expression notContains(V firstValue, V... moreValues)
    Deprecated, for removal: This API element is subject to removal in a future version.
    since 5.0 in favour of `notContainsValues(V...)`
    Returns:
      An expression for finding objects with values not in the given set.

  - ### notContainsValues

    @SafeVarargs public final Expression notContainsValues(V... values)
    Returns:
      An expression for finding objects with values not in the given set.
    Since:
      5.0

  - ### containsId

    public Expression containsId(Object id)
    Parameters:
      `id` - object id
    Returns:
      An expression for finding object with given id.

  - ### containsId

    @Deprecated(since="5.0", forRemoval=true) public Expression containsId(Object firstId, Object... moreId)
    Deprecated, for removal: This API element is subject to removal in a future version.
    since 5.0 in favour of `containsIds(Object...)`
    Returns:
      An expression for finding objects with given id set

  - ### containsIds

    public Expression containsIds(Object... ids)
    Returns:
      An expression for finding objects with given id set
    Since:
      5.0

  - ### containsId

    @Deprecated(since="5.0", forRemoval=true) public Expression containsId(Collection<Object> ids)
    Deprecated, for removal: This API element is subject to removal in a future version.
    since 5.0 in favour of `containsIdsCollection(Collection)`
    Returns:
      An expression for finding objects with given id set.

  - ### containsIdsCollection

    public Expression containsIdsCollection(Collection<?> ids)
    Returns:
      An expression for finding objects with given id set.
    Since:
      5.0

  - ### notContainsId

    public Expression notContainsId(Object id)
    Parameters:
      `id` - object id
    Returns:
      An expression for finding object without given id.

  - ### notContainsId

    @Deprecated(since="5.0", forRemoval=true) public Expression notContainsId(Object firstId, Object... moreId)
    Deprecated, for removal: This API element is subject to removal in a future version.
    since 5.0 in favour of `notContainsIds(Object...)`
    Returns:
      An expression for finding objects without given id set.

  - ### notContainsIds

    public Expression notContainsIds(Object... ids)
    Returns:
      An expression for finding objects without given id set.
    Since:
      5.0

  - ### notContainsId

    @Deprecated(since="5.0", forRemoval=true) public Expression notContainsId(Collection<Object> ids)
    Deprecated, for removal: This API element is subject to removal in a future version.
    since 5.0 in favour of `notContainsIdsCollection(Collection)`
    Returns:
      An expression for finding objects without given id set.

  - ### notContainsIdsCollection

    public Expression notContainsIdsCollection(Collection<?> ids)
    Returns:
      An expression for finding objects without given id set.
    Since:
      5.0

  - ### alias

    public MapProperty<K,V> alias(String alias)
    Creates alias with different name for this property
    Overrides:
      `alias` in class `BaseProperty<Map<K, V extends Persistent>>`

  - ### outer

    public MapProperty<K,V> outer()
    Returns a version of this property that represents an OUTER join.
    Specified by:
      `outer` in interface `RelationshipProperty<K>`

  - ### getKeyType

    protected Class<K> getKeyType()
    Returns:
      type of keys in represented attribute

  - ### getEntityType

    protected Class<V> getEntityType()
    Returns:
      type of object entity in represented attribute

  - ### enclosing

    public MapProperty<K,V> enclosing()
    Description copied from class: `BaseProperty`
    This operator allows to access properties of the enclosing query from the subquery. It allows multiple nesting levels to access a corresponding query in case of multiple levels of subqueries. Example:

        ObjectSelect.query(Artist.class)
                        .where(ExpressionFactory.notExists(ObjectSelect.query(Painting.class)
                                .where(Painting.TO_ARTIST.eq(Artist.ARTIST_ID_PK_PROPERTY.enclosing()))))

    Overrides:
      `enclosing` in class `BaseProperty<Map<K, V extends Persistent>>`
    Returns:
      property that will be translated relative to parent query