- java.lang.Object
- 
- aeonics.template.Factory<T>
 
- 
- Type Parameters:
- T- the entity category
 - All Implemented Interfaces:
- java.lang.Iterable<Template<T>>
 
 public class Factory<T extends Entity> extends java.lang.Object implements java.lang.Iterable<Template<T>> The factory contains the list of allTemplatethat can be used to create anEntitybased on user input. The templates are organized byTemplate.category().
- 
- 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <U extends Entity>
 Template<? extends U>add(Item<U> templated)Adds the specified template provider to its matching factoryTemplate.category().static <U extends Entity>
 Template<U>add(Template<U> template)Adds the specified template to its matching factoryTemplate.category().static java.lang.Iterable<Factory<?>>all()Returns an iterator over all factoriesjava.lang.Stringcategory()Returns the factory category.voidclear()Removes all templates from this factory.<V extends Item<? super T>>
 booleancontains(java.lang.Class<V> type)Returns true if a template is registered for the specified entity type.booleancontains(java.lang.String type)Returns true if a template is registered for the specified entity type.static <U extends Entity>
 Ucreate(Data data)Builds an instance of the exported or snapshotted entity.static <U extends Entity,V extends Item<? super U>>
 Ucreate(java.lang.Class<? extends Item<? super U>> category, java.lang.Class<V> type, Data data)Builds an instance of the exported or snapshotted entity.<U extends T,V extends Item<? super T>>
 Template<U>get(java.lang.Class<V> type)Fetches the template for the specified entity item type.<U extends T>
 Template<U>get(java.lang.String type)Fetches the template for the specified entity type.static booleanhas(java.lang.String category)Checks if the factory of the given entity category exists.java.util.Iterator<Template<T>>iterator()Returns an iterator over all templates registered in this factorystatic <U extends Entity>
 Template<U>of(Entity instance)Fetches the template that can be used to create or modify the specified entity.static <U extends Entity>
 Factory<U>of(java.lang.Class<? extends Item<? super U>> category)Fetches the factory of the given entity category.static <U extends Entity>
 Factory<U>of(java.lang.String category)Fetches the factory of the given entity category.<U extends T>
 Template<U>put(Template<U> template)Adds the specified template into this factory.<U extends T,V extends Item<? super T>>
 Template<U>remove(java.lang.Class<V> type)Removes the template for the specified entity item type.<U extends T>
 Template<U>remove(java.lang.String type)Removes the template for the specified entity type.intsize()Returns the number of templates in this factory.static <U extends Entity>
 Uupdate(U instance, Data data)Updates an existing entity given new parameters.
 
- 
- 
- 
Method Detail- 
ofpublic static <U extends Entity> Factory<U> of(java.lang.Class<? extends Item<? super U>> category) Fetches the factory of the given entity category. This is the same as callingof(StringUtils.toLowerCase(category))- Type Parameters:
- U- The entity category
- Parameters:
- category- The entity category
- Returns:
- The factory containing all Templatefor the specified category
 
 - 
ofpublic static <U extends Entity> Factory<U> of(java.lang.String category) Fetches the factory of the given entity category.- Type Parameters:
- U- The entity category
- Parameters:
- category- The entity category (should be or will be converted to lower case)
- Returns:
- The factory containing all Templatefor the specified category
 
 - 
ofpublic static <U extends Entity> Template<U> of(Entity instance) Fetches the template that can be used to create or modify the specified entity.- Type Parameters:
- U- The entity category
- Parameters:
- instance- The entity to fetch the category (should be or will be converted to lower case)
- Returns:
- The factory containing all Templatefor the specified category
 
 - 
haspublic static boolean has(java.lang.String category) Checks if the factory of the given entity category exists.- Parameters:
- category- The entity category (should be or will be converted to lower case)
- Returns:
- true if the factory of the given entity category exists
 
 - 
addpublic static <U extends Entity> Template<U> add(Template<U> template) Adds the specified template to its matching factoryTemplate.category().- Type Parameters:
- U- the entity category
- Parameters:
- template- the template
- Returns:
- the template
 
 - 
addpublic static <U extends Entity> Template<? extends U> add(Item<U> templated) Adds the specified template provider to its matching factoryTemplate.category().- Type Parameters:
- U- the entity category
- Parameters:
- templated- the template provider
- Returns:
- the template
- See Also:
- Template
 
 - 
createpublic static <U extends Entity> U create(Data data) Builds an instance of the exported or snapshotted entity.- Type Parameters:
- U- The entity type
- Parameters:
- data- the exported entity data
- Returns:
- the entity
- Throws:
- java.lang.RuntimeException- if a matching template cannot be found
- java.lang.IllegalArgumentException- if the provided data is invalid or corrupted
- See Also:
- Entity.export(),- Template.create(Data)
 
 - 
createpublic static <U extends Entity,V extends Item<? super U>> U create(java.lang.Class<? extends Item<? super U>> category, java.lang.Class<V> type, Data data) Builds an instance of the exported or snapshotted entity.- Type Parameters:
- U- The entity category
- V- The entity type
- Parameters:
- category- the entity category
- type- the entity type
- data- the user input data
- Returns:
- the entity
- Throws:
- java.lang.RuntimeException- if a matching template cannot be found
- java.lang.IllegalArgumentException- if the provided data is invalid or corrupted
- See Also:
- Template.create(Data)
 
 - 
updatepublic static <U extends Entity> U update(U instance, Data data) Updates an existing entity given new parameters.- Type Parameters:
- U- The entity type
- Parameters:
- instance- the existing instance to modify
- data- the new user input data
- Returns:
- the modified instance
- See Also:
- Template.update(Data, Entity)
 
 - 
allpublic static java.lang.Iterable<Factory<?>> all() Returns an iterator over all factories- Returns:
- a factory iterator
 
 - 
categorypublic java.lang.String category() Returns the factory category.- Returns:
- the factory category
 
 - 
getpublic <U extends T,V extends Item<? super T>> Template<U> get(java.lang.Class<V> type) Fetches the template for the specified entity item type. This is the same as callingget(StringUtils.toLowerCase(type))- Type Parameters:
- U- the entity type
- V- the entity item type
- Parameters:
- type- the entity item type
- Returns:
- the matching template or null if no such template is found
 
 - 
getpublic <U extends T> Template<U> get(java.lang.String type) Fetches the template for the specified entity type.- Type Parameters:
- U- the entity type
- Parameters:
- type- the entity type (should be or will be converted to lower case)
- Returns:
- the matching template or null if no such template is found
 
 - 
containspublic <V extends Item<? super T>> boolean contains(java.lang.Class<V> type) Returns true if a template is registered for the specified entity type. This is the same as callingcontains(StringUtils.toLowerCase(type))- Type Parameters:
- V- the entity item type
- Parameters:
- type- the entity item type
- Returns:
- true if a template is registered for the specified entity type
 
 - 
containspublic boolean contains(java.lang.String type) Returns true if a template is registered for the specified entity type.- Parameters:
- type- the entity type (should be or will be converted to lower case)
- Returns:
- true if a template is registered for the specified entity type
 
 - 
putpublic <U extends T> Template<U> put(Template<U> template) Adds the specified template into this factory. TheTemplate.category()should match this factory's category.- Type Parameters:
- U- the entity type
- Parameters:
- template- the template
- Returns:
- the template
- Throws:
- java.lang.IllegalArgumentException- if the template is null or if the category does not match
 
 - 
removepublic <U extends T,V extends Item<? super T>> Template<U> remove(java.lang.Class<V> type) Removes the template for the specified entity item type. This is the same as callingremove(StringUtils.toLowerCase(type))- Type Parameters:
- U- the entity type
- V- the entity item type
- Parameters:
- type- the entity item type
- Returns:
- the removed template, or null if there was no template for the specified entity type
 
 - 
removepublic <U extends T> Template<U> remove(java.lang.String type) Removes the template for the specified entity type. The entity type should always be lower case.- Type Parameters:
- U- the entity type
- Parameters:
- type- the entity type (should be or will be converted to lower case)
- Returns:
- the removed template, or null if there was no template for the specified entity type
 
 - 
clearpublic void clear() Removes all templates from this factory.
 - 
sizepublic int size() Returns the number of templates in this factory.- Returns:
- the number of templates in this factory
 
 
- 
 
-