java.lang.Object
org.praxislive.code.CodeFactory<D>
- Type Parameters:
D- base delegate type
A CodeFactory wraps configuration and task creation for creating code
components and contexts for a given delegate base type.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classCodeFactory.Base<B extends CodeDelegate>Base code factory for a given base delegate class.static final classCodeFactory.Task<D extends CodeDelegate>A task for creating a component or context for a given delegate. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic <B extends CodeDelegate>
CodeFactory.Base<B> base(Class<B> baseClass, List<String> baseImports, BiFunction<CodeFactory.Task<B>, B, CodeContext<B>> contextCreator) Create a componentCodeFactory.Basefor the given base delegate class, from which can be created individual CodeFactory instances.Query the base delegate class.Query the base imports to be automatically added to the source body.final ComponentTypeGet the component type.static <B extends CodeContainerDelegate>
CodeFactory.Base<B> containerBase(Class<B> baseClass, List<String> baseImports, BiFunction<CodeFactory.Task<B>, B, CodeContext<B>> contextCreator) Create a containerCodeFactory.Basefor the given base delegate class, from which can be created individual CodeFactory instances.Query the default delegate class.lookup()Access the lookup associated with this code factory.static <B extends CodeRootDelegate>
CodeFactory.Base<B> rootBase(Class<B> baseClass, List<String> baseImports, BiFunction<CodeFactory.Task<B>, B, CodeContext<B>> contextCreator) Create a root componentCodeFactory.Basefor the given base delegate class, from which can be created individual CodeFactory instances.static <B extends CodeRootContainerDelegate>
CodeFactory.Base<B> rootContainerBase(Class<B> baseClass, List<String> baseImports, BiFunction<CodeFactory.Task<B>, B, CodeContext<B>> contextCreator) Create a root containerCodeFactory.Basefor the given base delegate class, from which can be created individual CodeFactory instances.final StringThe source template corresponding to the default delegate class.task()Create a task for constructing a context or component from a delegate class.
-
Field Details
-
BASE_CLASS_KEY
Key for use in control info properties with the name of the base delegate type (class) as the value.- See Also:
-
BASE_IMPORTS_KEY
Key for use in control info properties with the base imports that should be available in source code. The value should be a PArray of import lines, each containing a full import declaration.- See Also:
-
-
Method Details
-
componentType
Get the component type.- Returns:
- component type
-
sourceTemplate
The source template corresponding to the default delegate class.- Returns:
- source template
-
defaultDelegateClass
Query the default delegate class.- Returns:
- default delegate class
-
baseClass
Query the base delegate class. This is the superclass for the source template and any derived code body.- Returns:
- base delegate class
-
baseImports
Query the base imports to be automatically added to the source body.- Returns:
- base imports
-
task
Create a task for constructing a context or component from a delegate class.- Returns:
- code factory task
-
lookup
Access the lookup associated with this code factory.- Returns:
- lookup
-
base
public static <B extends CodeDelegate> CodeFactory.Base<B> base(Class<B> baseClass, List<String> baseImports, BiFunction<CodeFactory.Task<B>, B, CodeContext<B>> contextCreator) Create a componentCodeFactory.Basefor the given base delegate class, from which can be created individual CodeFactory instances. The base class and default imports will be used to wrap user sources passed across to the compiler. The context creator function is used to wrap the compiled delegate in aCodeContext, and will usually correspond to(task, delegate) -> new XXXCodeContext(new XXXCodeConnector(task, delegate))- Type Parameters:
B- base delegate type- Parameters:
baseClass- base delegate superclassbaseImports- default base importscontextCreator- create context for delegate- Returns:
- code factory base
-
containerBase
public static <B extends CodeContainerDelegate> CodeFactory.Base<B> containerBase(Class<B> baseClass, List<String> baseImports, BiFunction<CodeFactory.Task<B>, B, CodeContext<B>> contextCreator) Create a containerCodeFactory.Basefor the given base delegate class, from which can be created individual CodeFactory instances. The base class and default imports will be used to wrap user sources passed across to the compiler. The context creator function is used to wrap the compiled delegate in aCodeContext, and will usually correspond to(task, delegate) -> new XXXCodeContext(new XXXCodeConnector(task, delegate))- Type Parameters:
B- base delegate type- Parameters:
baseClass- base delegate superclassbaseImports- default base importscontextCreator- create context for delegate- Returns:
- code factory base
-
rootBase
public static <B extends CodeRootDelegate> CodeFactory.Base<B> rootBase(Class<B> baseClass, List<String> baseImports, BiFunction<CodeFactory.Task<B>, B, CodeContext<B>> contextCreator) Create a root componentCodeFactory.Basefor the given base delegate class, from which can be created individual CodeFactory instances. The base class and default imports will be used to wrap user sources passed across to the compiler. The context creator function is used to wrap the compiled delegate in aCodeContext, and will usually correspond to(task, delegate) -> new XXXCodeContext(new XXXCodeConnector(task, delegate))- Type Parameters:
B- base delegate type- Parameters:
baseClass- base delegate superclassbaseImports- default base importscontextCreator- create context for delegate- Returns:
- code factory base
-
rootContainerBase
public static <B extends CodeRootContainerDelegate> CodeFactory.Base<B> rootContainerBase(Class<B> baseClass, List<String> baseImports, BiFunction<CodeFactory.Task<B>, B, CodeContext<B>> contextCreator) Create a root containerCodeFactory.Basefor the given base delegate class, from which can be created individual CodeFactory instances. The base class and default imports will be used to wrap user sources passed across to the compiler. The context creator function is used to wrap the compiled delegate in aCodeContext, and will usually correspond to(task, delegate) -> new XXXCodeContext(new XXXCodeConnector(task, delegate))- Type Parameters:
B- base delegate type- Parameters:
baseClass- base delegate superclassbaseImports- default base importscontextCreator- create context for delegate- Returns:
- code factory base
-