Package com.exedio.cope.pattern
Class ListField<E>
- java.lang.Object
-
- com.exedio.cope.Feature
-
- com.exedio.cope.Pattern
-
- com.exedio.cope.pattern.AbstractListField<E>
-
- com.exedio.cope.pattern.ListField<E>
-
- All Implemented Interfaces:
Copyable
,Serializable
public final class ListField<E> extends AbstractListField<E> implements Copyable
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
add(Item item, E value)
ListField<E>
copy(CopyMapper mapper)
ListField<E>
copyWith(FunctionField<?> copyWith)
Returns a new ListField, that differs from this ListField by enforcing that parent and element items have the same value in the given field.static <E> ListField<E>
create(FunctionField<E> element)
List<E>
get(Item item)
<T> FunctionField<T>
getCopyWithCopyField(FunctionField<T> template)
Get the field that stores a redudant copy of a parent item's value at the relation item, to enforce aCopyConstraint
added withcopyWith(FunctionField)
.List<FunctionField<?>>
getCopyWithTemplateFields()
Get the template fields added withcopyWith(FunctionField)
.<P extends Item>
List<P>getDistinctParents(Class<P> parentClass, E element)
Returns the items, for which this field list contains the given element.FunctionField<E>
getElement()
IntegerField
getOrder()
ItemField<?>
getParent()
<P extends Item>
ItemField<P>getParent(Class<P> parentClass)
Query<E>
getQuery(Item item)
Returns the query that is used to implementget(Item)
.Type<?>
getRelationType()
UniqueConstraint
getUniqueConstraint()
static <E> ListField<E>
newList(FunctionField<E> element)
Deprecated.Usecreate(FunctionField)
insteadprotected void
onMount()
Here you can do additional initialization not yet done in the constructor.boolean
removeAll(Item item, E element)
void
set(Item item, Collection<? extends E> value)
-
Methods inherited from class com.exedio.cope.pattern.AbstractListField
getMaximumSize, setAndCast
-
Methods inherited from class com.exedio.cope.Pattern
addSource, addSource, addSource, addSource, addSourceFeature, addSourceFeature, addSourceFeature, annotationField, equals, getGeneratedTypes, getSourceFeatures, getSourceFeaturesGather, getSourceFields, getSources, getSourceTypes, getType, hashCode, initialize, newSourceType, newSourceType, newSourceType, newSourceType, newSourceType, newSourceType, newType, newType, registerSource
-
Methods inherited from class com.exedio.cope.Feature
afterModelCreated, getAbstractType, getAnnotation, getID, getLocalizationKeys, getName, getPattern, isAnnotationPresent, isSourceAlready, mount, readResolve, requireMounted, toString, toString, writeReplace
-
-
-
-
Method Detail
-
create
public static <E> ListField<E> create(FunctionField<E> element)
-
copy
public ListField<E> copy(CopyMapper mapper)
-
copyWith
public ListField<E> copyWith(FunctionField<?> copyWith)
Returns a new ListField, that differs from this ListField by enforcing that parent and element items have the same value in the given field.- Throws:
IllegalStateException
- if theelement
field is not anItemField
IllegalArgumentException
- if the field given as parameter is not final
-
onMount
protected void onMount()
Description copied from class:Pattern
Here you can do additional initialization not yet done in the constructor. In this method you can call methodsPattern.getType()
andFeature.getName()
for the first time.
-
getParent
public ItemField<?> getParent()
-
getOrder
public IntegerField getOrder()
-
getUniqueConstraint
public UniqueConstraint getUniqueConstraint()
-
getElement
public FunctionField<E> getElement()
- Specified by:
getElement
in classAbstractListField<E>
-
getRelationType
public Type<?> getRelationType()
-
getCopyWithTemplateFields
public List<FunctionField<?>> getCopyWithTemplateFields()
Get the template fields added withcopyWith(FunctionField)
.
-
getCopyWithCopyField
@Nonnull public <T> FunctionField<T> getCopyWithCopyField(FunctionField<T> template)
Get the field that stores a redudant copy of a parent item's value at the relation item, to enforce aCopyConstraint
added withcopyWith(FunctionField)
.- Throws:
IllegalArgumentException
- if the field given as parameter does not belong to this ListField'stype
.IllegalStateException
- if there is no CopyConstraint on the given field
-
get
@Nonnull public List<E> get(Item item)
- Specified by:
get
in classAbstractListField<E>
- See Also:
getQuery(Item)
-
getQuery
@Nonnull public Query<E> getQuery(Item item)
Returns the query that is used to implementget(Item)
.
-
getDistinctParents
@Nonnull public <P extends Item> List<P> getDistinctParents(@Nonnull Class<P> parentClass, E element)
Returns the items, for which this field list contains the given element. The result does not contain any duplicates, even if the element is contained in this field list for an item more than once. The order of the result is unspecified.
-
removeAll
public boolean removeAll(@Nonnull Item item, E element)
- Returns:
true
if the result ofget(Item)
changed as a result of the call.
-
set
public void set(@Nonnull Item item, @Nonnull Collection<? extends E> value)
- Specified by:
set
in classAbstractListField<E>
-
newList
@Deprecated public static <E> ListField<E> newList(FunctionField<E> element)
Deprecated.Usecreate(FunctionField)
instead
-
-