Package it.tidalwave.role
Interface IdFactory
-
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface IdFactory
A factory for creating a new, uniqueId
for an object.- Author:
- Fabrizio Giudici
- Status: stable API
- Stereotype:
- Role
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
IdFactory.Private
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Id
createId()
Creates a new id.default Id
createId(java.lang.Class<?> objectClass)
Creates a new id for an object of the given class.default Id
createId(java.lang.Class<?> objectClass, java.lang.Object object)
Creates a new id for the given object of the given class.
-
-
-
Field Detail
-
_IdFactory_
static final java.lang.Class<IdFactory> _IdFactory_
-
DEFAULT
static final IdFactory DEFAULT
A default implementation that uses UUID.- Since:
- 3.2-ALPHA-19
-
MOCK
static final IdFactory MOCK
A mock implementation, useful for testing, that returns mock UUIDs based on a sequential counter.- Since:
- 3.2-ALPHA-19
-
-
Method Detail
-
createId
@Nonnull Id createId()
Creates a new id.- Returns:
- the new id
-
createId
@Nonnull default Id createId(@Nonnull java.lang.Class<?> objectClass)
Creates a new id for an object of the given class.- Parameters:
objectClass
- the class of the object for which theId
is created- Returns:
- the new id
-
createId
@Nonnull default Id createId(@Nonnull java.lang.Class<?> objectClass, @Nonnull java.lang.Object object)
Creates a new id for the given object of the given class. This method allows to explicitly pass aClass
for cases in which theobject
implements multiple interfaces and one wants to specify the referenced one.- Parameters:
object
- the object for which theId
objectClass
- the class of the object for which theId
is created- Returns:
- the new id
-
-