Class EntityIdWithType
- java.lang.Object
-
- org.eclipse.ditto.model.base.entity.id.EntityIdWithType
-
- All Implemented Interfaces:
CharSequence
,Comparable<EntityId>
,EntityId
,WithEntityType
- Direct Known Subclasses:
NamespacedEntityIdWithType
@Immutable public abstract class EntityIdWithType extends Object implements EntityId, WithEntityType
Base implementation for entity IDs which are aware of their entity type. Subclasses are required to be immutable.- Since:
- 1.1.0
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
EntityIdWithType(EntityId entityId)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static <I extends EntityIdWithType>
Consumer<I>createEqualityValidator(I expectedEntityId)
Deprecated.as of 1.2.0 please useisCompatibleOrThrow(EntityIdWithType)
instead.boolean
equals(Object o)
protected IllegalArgumentException
getIllegalArgumentExceptionForDifferentEntityIds(EntityIdWithType actual)
int
hashCode()
boolean
isCompatibleOrThrow(EntityIdWithType otherEntityId)
Checks if the passed entity ID is compatible with this entity ID.boolean
isDummy()
Checks whether this ID acts as dummy ID.String
toString()
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.CharSequence
chars, codePoints
-
Methods inherited from interface org.eclipse.ditto.model.base.entity.id.EntityId
charAt, compareTo, length, subSequence
-
Methods inherited from interface org.eclipse.ditto.model.base.entity.type.WithEntityType
getEntityType
-
-
-
-
Constructor Detail
-
EntityIdWithType
protected EntityIdWithType(EntityId entityId)
-
-
Method Detail
-
createEqualityValidator
@Deprecated public static <I extends EntityIdWithType> Consumer<I> createEqualityValidator(I expectedEntityId)
Deprecated.as of 1.2.0 please useisCompatibleOrThrow(EntityIdWithType)
instead.Creates an equality validator asConsumer
acceptingEntityIdWithType
instances comparing them to the passed inexpectedEntityId
.When the entity IDs don't match, the an
The equality validator will forIllegalArgumentException
will be thrown to the one providing the entity id to compare with.NamespacedEntityIdWithType
IDs compare equality of the IDsname
s excluding thenamespace
part as thenamespace
part might not yet be available.- Type Parameters:
I
- the type of EntityIdWithType which may also be NamespacedEntityIdWithType.- Parameters:
expectedEntityId
- the expected entity ID.- Returns:
- a consumer accepting an instance of
<I>
which gets compared withexpectedEntityId
- if the IDs are not equal, anIllegalArgumentException
will be thrown, if they are equal, no other side effect happens. - Throws:
NullPointerException
- ifexpectedEntityId
isnull
.
-
isCompatibleOrThrow
public boolean isCompatibleOrThrow(@Nullable EntityIdWithType otherEntityId)
Checks if the passed entity ID is compatible with this entity ID. In the base implementation a given entity ID is compatible if a call ofequals(Object)
with that ID would yieldtrue
. Subclasses may implement a different behavior. Please have a look at the documentation of the subclass for further information.- Parameters:
otherEntityId
- the entity ID to be compared for equality with this entity ID.- Returns:
true
ifotherEntityId
is compatible with this entity ID.- Throws:
IllegalArgumentException
- ifotherEntityId
is not compatible with this entity ID.- Since:
- 1.2.0
-
getIllegalArgumentExceptionForDifferentEntityIds
protected IllegalArgumentException getIllegalArgumentExceptionForDifferentEntityIds(@Nullable EntityIdWithType actual)
-
isDummy
public boolean isDummy()
Description copied from interface:EntityId
Checks whether this ID acts as dummy ID. Dummy IDs should not be used as ID for any entity.
-
toString
public String toString()
- Specified by:
toString
in interfaceCharSequence
- Overrides:
toString
in classObject
-
-