Class Item
- All Implemented Interfaces:
Serializable,Comparable<Item>
- Direct Known Subclasses:
Dispatcher.Run,DynamicModel.Enum,DynamicModel.Field,DynamicModel.Type,History.Event,History.Feature,PasswordLimiter.Refusal,PasswordRecovery.Token,Schedule.Run,TextUrlFilter.Paste
Serialization of instances of Item
is guaranteed to be light-weight -
there are no non-static, non-transient object reference
fields in this class or its superclasses.
- Author:
- Ralf Wiebicke
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ItemField.DeletePolicyDeprecated.static final ItemField.DeletePolicyDeprecated.Is default delete policy anyway.static final ItemField.DeletePolicyDeprecated.UseItemField.nullify()instead -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedActivation constructor.protected -
Method Summary
Modifier and TypeMethodDescriptionfinal ItemReturns the active item object representing the same item as this item object.protected voidIs called after every item creation.final voidIs equivalent tobf.{@link StringBuilder#append(String) append}({@link #getCopeID()});protected voidIs called before every item deletion.protected SetValue<?>[]beforeSetCopeItem(SetValue<?>[] setValues) Is called before every item modification.intDefines an order consistent to the query result order when usingQuery.setOrderBymethods with anyItemFunction.final voidfinal booleanReturns true, iforepresents the same item as this item.final booleanReturns, whether the item does exist.final <E> Efinal StringReturns a string unique for this item in all other items of the model.final Type<?>Returns the type of this item.final inthashCode()Returns a hash code, that is consistent withequals(Object).final booleanReturns, whether this item is active.newEnumAttribute(Class<E> valueClass) Deprecated.Renamed tonewEnumField(Class).newEnumField(Class<E> valueClass) Deprecated.UseEnumField.create(Class)insteadnewItemAttribute(Class<E> valueClass) Deprecated.Renamed tonewItemField(Class).newItemAttribute(Class<E> valueClass, ItemField.DeletePolicy policy) Deprecated.newItemField(Class<E> valueClass) Deprecated.UseItemField.create(Class)insteadnewItemField(Class<E> valueClass, ItemField.DeletePolicy policy) Deprecated.UseItemField.create(Class, DeletePolicy)insteadDeprecated.UseTypesBound.newType(Class)instead.final <E> voidset(FunctionField<E> field, E value) final voidtoString()ReturnsgetCopeID()as a default implementation for all persistent classes.protected final Object
-
Field Details
-
FORBID
Deprecated.Is default delete policy anyway. -
NULLIFY
Deprecated.UseItemField.nullify()instead -
CASCADE
Deprecated.UseItemField.cascade()instead
-
-
Constructor Details
-
Item
-
Item
Activation constructor. Is used for internal purposes only. Does not actually create a new item, but a passive item object for an already existing item.
-
-
Method Details
-
getCopeID
Returns a string unique for this item in all other items of the model. For any itema</tt> in its model <tt>mthe following holds true:a.equals(m.getItem(a.getCopeID()).Does not activate this item, if it's not already active. Never returns null.- See Also:
-
appendCopeID
Is equivalent tobf.{@link StringBuilder#append(String) append}({@link #getCopeID()}); -
getCopeType
Returns the type of this item. Never returns null. -
equals
Returns true, iforepresents the same item as this item. Is equivalent to(o != null) && (o instanceof Item) && getCopeID().equals(((Item)o).getCopeID())
Does not activate this item, if it's not already active. -
hashCode
public final int hashCode()Returns a hash code, that is consistent withequals(Object). Note, that this is not necessarily equivalent togetCopeID().hashCode(). Does not activate this item, if it's not already active. -
compareTo
Defines an order consistent to the query result order when usingQuery.setOrderBymethods with anyItemFunction.- Specified by:
compareToin interfaceComparable<Item>
-
toString
ReturnsgetCopeID()as a default implementation for all persistent classes. -
isActiveCopeItem
public final boolean isActiveCopeItem()Returns, whether this item is active. -
activeCopeItem
Returns the active item object representing the same item as this item object. For any two item objectsa</tt>, <tt>bthe following holds true:If and only if
a.equals(b)</tt> then <tt>a.activeCopeItem() == b.activeCopeItem().So it does for items, what
String.intern()does for strings. Does activate this item, if it's not already active. Is guaranteed to be very cheap, if this item object is already active, which means this method returnsthis. Never returns null. -
afterNewCopeItem
protected void afterNewCopeItem()Is called after every item creation. Is called only, ifDefaultChangeHookhas beeninstalled. Override this method when needed. The default implementation does nothing.If you want to affect field values before creating the item write a method:
static SetValue[] beforeNewCopeItem(SetValue[])If you want to postpone your action until the current transaction commits, use either
pre- orpost-commit hooks.- See Also:
-
beforeSetCopeItem
Is called before every item modification. Is called only, ifDefaultChangeHookhas beeninstalled. Override this method when needed. The default implementation does nothing.If you want to affect field values before creating the item write a method:
static SetValue[] beforeNewCopeItem(SetValue[])If you want to postpone your action until the current transaction commits, use either
pre- orpost-commit hooks.- Parameters:
setValues- is never null and never empty- Returns:
- must not return null
- See Also:
-
get
-
set
- Throws:
MandatoryViolationException- ifvalue</tt> is null and <tt>fieldismandatory.FinalViolationException- iffieldisfinal.ClassCastException- ifvalue</tt> is not compatible to <tt>field.
-
set
- Throws:
MandatoryViolationException- ifvalue</tt> is null and <tt>fieldismandatory.FinalViolationException- iffieldisfinal.ClassCastException- ifvalue</tt> is not compatible to <tt>field.
-
deleteCopeItem
public final void deleteCopeItem()- Throws:
IntegrityViolationException- if this item cannot be deleted due areferencewithItemField.DeletePolicy.FORBIDpointing to this item.
-
beforeDeleteCopeItem
protected void beforeDeleteCopeItem()Is called before every item deletion. Is called only, ifDefaultChangeHookhas beeninstalled. Override this method when needed. The default implementation does nothing.If you want to postpone your action until the current transaction commits, use either
pre- orpost-commit hooks.- See Also:
-
existsCopeItem
public final boolean existsCopeItem()Returns, whether the item does exist. There are two possibilities, why an item could not exist:- the item has been deleted by
deleteCopeItem(). - the item has been created in a transaction,
that was subsequently rolled back by
Model.rollback().
- the item has been deleted by
-
writeReplace
-
newEnumField
Deprecated.UseEnumField.create(Class)instead -
newItemField
Deprecated.UseItemField.create(Class)instead -
newItemField
@Deprecated public static final <E extends Item> ItemField<E> newItemField(Class<E> valueClass, ItemField.DeletePolicy policy) Deprecated.UseItemField.create(Class, DeletePolicy)instead -
newEnumAttribute
@Deprecated public static final <E extends Enum<E>> EnumField<E> newEnumAttribute(Class<E> valueClass) Deprecated.Renamed tonewEnumField(Class). -
newItemAttribute
Deprecated.Renamed tonewItemField(Class). -
newItemAttribute
@Deprecated public static final <E extends Item> ItemField<E> newItemAttribute(Class<E> valueClass, ItemField.DeletePolicy policy) Deprecated. -
newType
Deprecated.UseTypesBound.newType(Class)instead.
-
ItemField.cascade()instead