Package com.atlassian.adf.util
Class Factory<T extends Element>
- java.lang.Object
-
- com.atlassian.adf.util.Factory<T>
-
- Type Parameters:
T- the type of element returned by this factory (either a node or a mark)
@Internal @ReturnValuesAreNonnullByDefault public class Factory<T extends Element> extends Object
Supporting class for the parser that resolves thetypeof an element to its corresponding node or mark class as well as a sub-parser that can reconstruct the element from its map value.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <K,T extends Element>
Map<K,Factory<? extends T>>extractLookupMap(Function<Factory<? extends T>,K> keyExtractor, Factory<? extends T>... factories)Given a group of factories, builds a lookup map that can resolve each factory'stypeClass()to the corresponding factory.Tparse(Map<String,?> map)Parses the given value map, assuming that it is a well-formed representation of an element of the type that this factory can produce.Stringtype()Class<T>typeClass()static <T extends Element,U extends T>
Factory<T>unsupported(Class<T> typeClass, Function<Map<String,?>,U> parser)
-
-
-
Method Detail
-
unsupported
public static <T extends Element,U extends T> Factory<T> unsupported(Class<T> typeClass, Function<Map<String,?>,U> parser)
-
type
public String type()
- Returns:
- the value used to identify elements of this type, or an empty string if this factory creates opaque representations for an unsupported element type
-
parse
public T parse(Map<String,?> map)
Parses the given value map, assuming that it is a well-formed representation of an element of the type that this factory can produce.- Parameters:
map- the value map to be parsed- Returns:
- the reconstructed element
-
extractLookupMap
@SafeVarargs public static <K,T extends Element> Map<K,Factory<? extends T>> extractLookupMap(Function<Factory<? extends T>,K> keyExtractor, Factory<? extends T>... factories)
Given a group of factories, builds a lookup map that can resolve each factory'stypeClass()to the corresponding factory.- Type Parameters:
K- the inferred key type for the resulting lookup mapT- the inferred element type returned by this factory- Parameters:
keyExtractor- the function for extracting the lookup key for the factory lookup mapfactories- all factories to include in the lookup map- Returns:
- the (immutable) lookup map
-
-