java.lang.Object
org.fuin.objects4j.core.AbstractStringValueObject
org.fuin.ddd4j.core.EntityIdPath
- All Implemented Interfaces:
Serializable,Comparable<org.fuin.objects4j.core.AbstractStringValueObject>,org.fuin.objects4j.common.AsStringCapable,org.fuin.objects4j.common.ValueObject,org.fuin.objects4j.common.ValueObjectWithBaseType<String>
public final class EntityIdPath
extends org.fuin.objects4j.core.AbstractStringValueObject
implements Serializable
An ordered list of entity identifiers. An aggregate root will be the first entry if it's contained in the list.
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionEntityIdPath(List<EntityId> ids) Constructor with ID list.EntityIdPath(EntityId... entityIds) Constructor with ID array. -
Method Summary
Modifier and TypeMethodDescriptionfinal Stringfinal <T extends EntityId>
Tfirst()Returns the first entity identifier in the path.static booleanisValid(@NotNull EntityIdFactory factory, String value) Check that a given string is a well-formed email address.iterator()Creates a NEW list of the entity identifiers contained in the entity id path and returns an iterator on it.final <T extends EntityId>
Tlast()Returns the last entity identifier in the path.parent()Returns the parent path without the last entry.static voidrequireArgValid(@NotNull EntityIdFactory factory, @NotNull String name, String value) Checks if the argument is a valid email and throws an exception if this is not the case.final EntityIdPathrest()Returns the path without the first entry.final intsize()Returns the number of elements in the path.final StringtoString()static EntityIdPathvalueOf(@NotNull EntityIdFactory factory, String str) Converts a given string into an instance of this class.Methods inherited from class org.fuin.objects4j.core.AbstractStringValueObject
asString, compareTo, equals, getBaseType, hashCode, length
-
Field Details
-
PATH_SEPARATOR
Divides the entity identifiers in the path.- See Also:
-
-
Constructor Details
-
EntityIdPath
Constructor with ID array.- Parameters:
entityIds- Entity identifier in correct order (from outer to inner).
-
EntityIdPath
Constructor with ID list.- Parameters:
ids- Entity identifiers in correct order (from outer to inner).
-
-
Method Details
-
iterator
Creates a NEW list of the entity identifiers contained in the entity id path and returns an iterator on it. This means deleting an element using theIterator.remove()method will NOT remove something from this entity id path.- Returns:
- Iterator on a new list instance.
-
first
Returns the first entity identifier in the path.- Type Parameters:
T- Type of the entity identifier that is returned.- Returns:
- First entity identifier in the path.
-
last
Returns the last entity identifier in the path.- Type Parameters:
T- Type of the entity identifier that is returned.- Returns:
- Last entity identifier in the path.
-
rest
Returns the path without the first entry.- Returns:
- Rest or NULL if the path has only one element.
-
parent
Returns the parent path without the last entry.- Returns:
- Parent identifier path or NULL if this is an aggregate root ID.
-
size
public final int size()Returns the number of elements in the path.- Returns:
- Number of identifiers contained in the path.
-
asBaseType
- Specified by:
asBaseTypein interfaceorg.fuin.objects4j.common.ValueObjectWithBaseType<String>
-
toString
-
valueOf
@Nullable public static EntityIdPath valueOf(@NotNull @NotNull EntityIdFactory factory, @Nullable String str) Converts a given string into an instance of this class.- Parameters:
factory- Factory used to create enitity identifiers.str- String to convert.- Returns:
- New instance.
-
isValid
Check that a given string is a well-formed email address.- Parameters:
factory- Factory used to create enitity identifiers.value- Value to check.- Returns:
- Returns true if it's a valid email address else false is returned.
-
requireArgValid
public static void requireArgValid(@NotNull @NotNull EntityIdFactory factory, @NotNull @NotNull String name, @Nullable String value) throws org.fuin.objects4j.common.ConstraintViolationException Checks if the argument is a valid email 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.
-