Class Id<T>
- Type Parameters:
T- the entity type. I.e.: a typical class will look something likepublic class ProjectId extends Id<Project>.
- All Implemented Interfaces:
HasId, Comparable<Id<?>>
Additionally, this object makes it possible to store and lookup entities using a case-insensitive identifier.
It also allows specifying the entity type which prevents the need for dynamic casting after loading the entity.
Note that, by default, this identifier is serialized as a string of the functionalId. Deserialization is done by
invoking a constructor on your subtype that accepts a single String argument. If such constructor does not exist,
please specify your own deserializer, using e.g. @JsonDeserialize on your type.
-
Constructor Summary
ConstructorsConstructorDescriptionId(@NonNull String functionalId, @NonNull Class<T> type, @NonNull String prefix, boolean caseSensitive) Construct an id for an entity.Construct an id for an entity.Construct a case-sensitive id for an entity without prefix.Construct an id for an entity without prefix.Construct a case-sensitive id for an entity without prefix.Construct an id for an entity without prefix.Construct a case-sensitive id for an entity.Construct a case-sensitive id for an entity. -
Method Summary
-
Constructor Details
-
Id
Construct a case-sensitive id for an entity without prefix. This constructor allows ids to be prefixed with a value to prevent clashes with other entities that may share the same functional id.The identifier's
typewill be determined using reflection.- Parameters:
functionalId- The functional id of the entity. The object's toString() method is used to get a string representation of the functional id.
-
Id
Construct a case-sensitive id for an entity without prefix. This constructor allows ids to be prefixed with a value to prevent clashes with other entities that may share the same functional id.- Parameters:
functionalId- The functional id of the entity. The object's toString() method is used to get a string representation of the functional id.type- The entity's type. This may be a superclass of the actual entity.
-
Id
Construct a case-sensitive id for an entity. This constructor allows ids to be prefixed with a value to prevent clashes with other entities that may share the same functional id.The identifier's
typewill be determined using reflection.- Parameters:
functionalId- The functional id of the entity. The object's toString() method is used to get a string representation of the functional id.prefix- The prefix that is prepended to thefunctionalIdto create the full id under which this entity will be stored. Eg, if the prefix of anIdis "user-", and the id is "pete123", the entity will be stored under "user-pete123".
-
Id
Construct a case-sensitive id for an entity. This constructor allows ids to be prefixed with a value to prevent clashes with other entities that may share the same functional id.- Parameters:
functionalId- The functional id of the entity. The object's toString() method is used to get a string representation of the functional id.type- The entity's type. This may be a superclass of the actual entity.prefix- The prefix that is prepended to thefunctionalIdto create the full id under which this entity will be stored. Eg, if the prefix of anIdis "user-", and the id is "pete123", the entity will be stored under "user-pete123".
-
Id
Construct an id for an entity without prefix. This constructor allows ids to be case-insensitive.The identifier's
typewill be determined using reflection.- Parameters:
functionalId- The functional id of the entity. The object's toString() method is used to get a string representation of the functional id.caseSensitive- whether this id is case-sensitive.
-
Id
Construct an id for an entity without prefix. This constructor allows ids to be case-insensitive.- Parameters:
functionalId- The functional id of the entity. The object's toString() method is used to get a string representation of the functional id.type- The entity's type. This may be a superclass of the actual entity.caseSensitive- whether this id is case-sensitive.
-
Id
public Id(@NonNull @NonNull String functionalId, @NonNull @NonNull String prefix, boolean caseSensitive) Construct an id for an entity. This constructor allows ids to be prefixed with a value to prevent clashes with other entities that may share the same functional id. It also enables ids to be case-insensitive.The identifier's
typewill be determined using reflection.- Parameters:
functionalId- The functional id of the entity. The object's toString() method is used to get a string representation of the functional id.prefix- The prefix that is prepended to thefunctionalIdto create the full id under which this entity will be stored. Eg, if the prefix of anIdis "user-", and the id is "pete123", the entity will be stored under "user-pete123".caseSensitive- whether this id is case-sensitive.
-
Id
public Id(@NonNull @NonNull String functionalId, @NonNull @NonNull Class<T> type, @NonNull @NonNull String prefix, boolean caseSensitive) Construct an id for an entity. This constructor allows ids to be prefixed with a value to prevent clashes with other entities that may share the same functional id. It also enables ids to be case-insensitive.- Parameters:
functionalId- The functional id of the entity. The object's toString() method is used to get a string representation of the functional id.type- The entity's type. This may be a superclass of the actual entity.prefix- The prefix that is prepended to thefunctionalIdto create the full id under which this entity will be stored. Eg, if the prefix of anIdis "user-", and the id is "pete123", the entity will be stored under "user-pete123".caseSensitive- whether this id is case-sensitive.
-
-
Method Details
-
getId
-
toString
-
equals
-
hashCode
-
compareTo
- Specified by:
compareToin interfaceComparable<T>
-