Package com.exedio.cope.pattern
Class SetField<E>
- java.lang.Object
-
- com.exedio.cope.Feature
-
- com.exedio.cope.Pattern
-
- com.exedio.cope.pattern.SetField<E>
-
- All Implemented Interfaces:
Copyable
,Serializable
public final class SetField<E> extends Pattern implements Copyable
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
add(Item item, E element)
SetField<E>
copy(CopyMapper mapper)
SetField<E>
copyWith(FunctionField<?> copyWith)
Returns a new SetField, that differs from this SetField by enforcing that parent and element items have the same value in the given field.static <E> SetField<E>
create(FunctionField<E> element)
Set<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)
.FunctionField<E>
getElement()
IntegerField
getOrder()
ItemField<?>
getParent()
<P extends Item>
ItemField<P>getParent(Class<P> parentClass)
<P extends Item>
List<P>getParents(Class<P> parentClass, E element)
Returns the items, for which this field set contains the given element.Query<E>
getQuery(Item item)
Type<?>
getRelationType()
UniqueConstraint
getUniqueConstraint()
UniqueConstraint
getUniqueConstraintForOrder()
boolean
isOrdered()
Returns whether thisSetField
is ordered.static <E> SetField<E>
newSet(FunctionField<E> element)
Deprecated.Usecreate(FunctionField)
insteadprotected void
onMount()
Here you can do additional initialization not yet done in the constructor.SetField<E>
ordered()
Returns a new SetField, that differs from this SetField by beingordered
.boolean
remove(Item item, E element)
void
set(Item item, Collection<? extends E> value)
void
setAndCast(Item item, Collection<?> value)
-
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> SetField<E> create(FunctionField<E> element)
-
copy
public SetField<E> copy(CopyMapper mapper)
-
ordered
public SetField<E> ordered()
Returns a new SetField, that differs from this SetField by beingordered
.
-
copyWith
public SetField<E> copyWith(FunctionField<?> copyWith)
Returns a new SetField, that differs from this SetField 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()
-
isOrdered
public boolean isOrdered()
Returns whether thisSetField
is ordered. An orderedSetField
maintains the insertion order of its elements.
-
getOrder
public IntegerField getOrder()
-
getUniqueConstraintForOrder
public UniqueConstraint getUniqueConstraintForOrder()
-
getElement
public FunctionField<E> getElement()
-
getUniqueConstraint
public UniqueConstraint getUniqueConstraint()
-
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 SetField'stype
.IllegalStateException
- if there is no CopyConstraint on the given field
-
getParents
@Nonnull public <P extends Item> List<P> getParents(@Nonnull Class<P> parentClass, @Nonnull E element)
Returns the items, for which this field set contains the given element. The order of the result is unspecified.
-
add
public boolean add(@Nonnull Item item, @Nonnull E element)
- Returns:
true
if the result ofget(Item)
changed as a result of the call.
-
remove
public boolean remove(@Nonnull Item item, @Nonnull 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)
-
setAndCast
public void setAndCast(Item item, Collection<?> value)
-
newSet
@Deprecated public static <E> SetField<E> newSet(FunctionField<E> element)
Deprecated.Usecreate(FunctionField)
instead
-
-