S - The self typeT - Type of produced objectpublic abstract class Factory<S extends Factory<S,T>,T extends Identifiable> extends java.lang.Object implements Identifiable
| Modifier and Type | Field and Description |
|---|---|
protected java.util.function.Supplier<T> |
constructor
The constructor function
|
protected java.lang.String |
id
The ID of the factory
|
protected java.util.function.Function<T,T> |
processor
The processor function
|
protected java.lang.Class<? extends T> |
type
The type of the object to construct
|
| Constructor and Description |
|---|
Factory(java.lang.String id,
java.lang.Class<? extends T> type)
Creates a new factory with a constructor function that instantiates the factory object,
and with a processor that is capable of mutating the instantiated object after its initialization.
|
Factory(java.lang.String id,
java.lang.Class<? extends T> type,
java.util.function.Function<T,T> processor)
Creates a new factory with a constructor function that instantiates the factory object,
and with a processor that is capable of mutating the instantiated object after its initialization.
|
Factory(java.lang.String id,
java.lang.Class<? extends T> type,
java.util.function.Function<T,T> processor,
java.util.function.Function<java.lang.Class<?>,java.util.Optional<?>> mapping)
Creates a new factory with a constructor function that instantiates the factory object,
and with a processor that is capable of mutating the instantiated object after its initialization.
|
Factory(java.lang.String id,
java.util.function.Supplier<T> constructor)
Creates a new factory with a constructor function that instantiates the factory object,
and with a processor that is capable of mutating the instantiated object after its initialization.
|
Factory(java.lang.String id,
java.util.function.Supplier<T> constructor,
java.util.function.Function<T,T> processor)
Creates a new factory with a constructor function that instantiates the factory object,
and with a processor that is capable of mutating the instantiated object after its initialization.
|
| Modifier and Type | Method and Description |
|---|---|
T |
build() |
java.lang.String |
getID()
Get the ID to identify this object by
|
java.lang.Class<? extends T> |
getType()
Get the class of the type argument T.
|
S |
process(java.util.function.Function<T,T> processor)
Adds a processor to the factory
|
protected S |
selfConstructor(java.lang.String id,
java.lang.Class<T> type,
java.util.function.Function<T,T> processor) |
protected abstract S |
selfConstructor(java.lang.String id,
java.util.function.Supplier<T> constructor,
java.util.function.Function<T,T> processor) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitsameTypeprotected final java.lang.String id
protected final java.util.function.Supplier<T extends Identifiable> constructor
protected final java.util.function.Function<T extends Identifiable,T extends Identifiable> processor
protected final java.lang.Class<? extends T extends Identifiable> type
public Factory(java.lang.String id,
java.lang.Class<? extends T> type,
java.util.function.Function<T,T> processor,
java.util.function.Function<java.lang.Class<?>,java.util.Optional<?>> mapping)
id - The identifier for this factory typetype - The implementation classprocessor - The processor functionmapping - The custom DI mappingpublic Factory(java.lang.String id,
java.lang.Class<? extends T> type,
java.util.function.Function<T,T> processor)
id - The identifier for this factory typetype - The implementation classprocessor - The processor functionpublic Factory(java.lang.String id,
java.lang.Class<? extends T> type)
id - The identifier for this factory typetype - The implementation classpublic Factory(java.lang.String id,
java.util.function.Supplier<T> constructor,
java.util.function.Function<T,T> processor)
id - The identifier for this factory typeconstructor - The construction functionprocessor - The processor functionpublic Factory(java.lang.String id,
java.util.function.Supplier<T> constructor)
id - The identifier for this factory typeconstructor - The construction functionpublic S process(java.util.function.Function<T,T> processor)
processor - A processor that mutates the constructionprotected S selfConstructor(java.lang.String id, java.lang.Class<T> type, java.util.function.Function<T,T> processor)
protected abstract S selfConstructor(java.lang.String id, java.util.function.Supplier<T> constructor, java.util.function.Function<T,T> processor)
public java.lang.Class<? extends T> getType()
public T build()
public java.lang.String getID()
IdentifiablegetID in interface Identifiable