- All Superinterfaces:
org.fuin.objects4j.common.AsStringCapable,Serializable,org.fuin.utils4j.TechnicalId
- All Known Subinterfaces:
AggregateRootId
- All Known Implementing Classes:
AggregateRootUuid,IntegerEntityId
public interface EntityId
extends org.fuin.utils4j.TechnicalId, org.fuin.objects4j.common.AsStringCapable, Serializable
Identifies an entity within all entities of the same type.
-
Method Summary
Modifier and TypeMethodDescriptionasString()Returns the entity identifier as string.Returns the entity identifier as string with type and identifier.getType()Returns the type represented by this identifier.static booleanisValid(@NotNull EntityIdFactory factory, String value) Verifies that the given value can be converted into a value object using the factory.static voidrequireArgValid(@NotNull EntityIdFactory factory, @NotNull String name, String value) Verifies if the argument is valid and throws an exception if this is not the case.static EntityIdvalueOf(@NotNull EntityIdFactory factory, String value) Converts a string into an entity identifier.
-
Method Details
-
getType
EntityType getType()Returns the type represented by this identifier.- Returns:
- Type of entity.
-
asString
String asString()Returns the entity identifier as string.- Specified by:
asStringin interfaceorg.fuin.objects4j.common.AsStringCapable- Returns:
- Entity identifier.
-
asTypedString
String asTypedString()Returns the entity identifier as string with type and identifier.- Returns:
- Type and identifier.
-
isValid
Verifies that the given value can be converted into a value object using the factory. Anullparameter will returntrue.- Parameters:
factory- Factory used to create enitity identifiers.value- Value to check.- Returns:
trueif the value can be converted, elsefalse.
-
requireArgValid
static void requireArgValid(@NotNull @NotNull EntityIdFactory factory, @NotNull @NotNull String name, @Nullable String value) throws org.fuin.objects4j.common.ConstraintViolationException Verifies if the argument is valid and throws an exception if this is not the case.- Parameters:
factory- Factory used to create enitity identifiers.name- Name of the value for a possible error message.value- Value to check.- Throws:
org.fuin.objects4j.common.ConstraintViolationException- The value was not valid.
-
valueOf
Converts a string into an entity identifier. Anullparameter will returnnull.- Parameters:
factory- Factory used to create enitity identifiers.value- Representation of the entity identifier as string.- Returns:
- Value object.
-