Class CodeFactory<D extends CodeDelegate>

    • Field Detail

      • BASE_CLASS_KEY

        public static final String BASE_CLASS_KEY
        Key for use in control info properties with the name of the base delegate type (class) as the value.
        See Also:
        Constant Field Values
      • BASE_IMPORTS_KEY

        public static final String 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:
        Constant Field Values
    • Constructor Detail

      • CodeFactory

        @Deprecated
        protected CodeFactory​(ClassBodyContext<D> cbc,
                              ComponentType type,
                              Class<? extends D> defaultCls,
                              String template)
        Deprecated.
        Construct CodeFactory for a type extending the base code delegate type. This constructor allows for a precompiled default delegate class to be provided. This must correspond to the code compiled from wrapping the provided class body template in the provided class body context.
        Parameters:
        cbc - class body context that will wrap source code
        type - the component type
        defaultCls - precompiled default delegate
        template - code template reflecting default delegate
      • CodeFactory

        @Deprecated
        protected CodeFactory​(ClassBodyContext<D> cbc,
                              ComponentType type,
                              String template)
        Deprecated.
        Construct CodeFactory for a type extending the base code delegate type. This constructor is used where the default delegate is compiled from the template at runtime.
        Parameters:
        cbc - class body context that will wrap source code
        type - the component type
        template - code template reflecting default delegate
    • Method Detail

      • getComponentType

        @Deprecated
        public final ComponentType getComponentType()
        Deprecated.
        Get the component type.
        Returns:
        component type
      • componentType

        public final ComponentType componentType()
        Get the component type.
        Returns:
        component type
      • getClassBodyContext

        @Deprecated
        public final ClassBodyContext<D> getClassBodyContext()
        Deprecated.
        Class body context used to create wrapping class for source code.
        Returns:
        class body context
      • getSourceTemplate

        @Deprecated
        public final String getSourceTemplate()
        Deprecated.
        The source template corresponding to the default delegate class.
        Returns:
        source template
      • sourceTemplate

        public final String sourceTemplate()
        The source template corresponding to the default delegate class.
        Returns:
        source template
      • getDefaultDelegateClass

        @Deprecated
        public final Optional<Class<? extends D>> getDefaultDelegateClass()
        Deprecated.
        Optional precompiled version of the default delegate class.
        Returns:
        optional precompiled default delegate
      • defaultDelegateClass

        public final Class<? extends D> defaultDelegateClass()
        Query the default delegate class.
        Returns:
        default delegate class
      • baseClass

        public final Class<D> baseClass()
        Query the base delegate class. This is the superclass for the source template and any derived code body.
        Returns:
        base delegate class
      • baseImports

        public final List<String> baseImports()
        Query the base imports to be automatically added to the source body.
        Returns:
        base imports
      • task

        public CodeFactory.Task<D> task()
        Create a task for constructing a context or component from a delegate class. This will return a suitable Task subclass that should be configured and used to create a context or component.
        Returns:
        code factory task
      • base

        public static <B extends CodeDelegateCodeFactory.Base<B> base​(Class<B> baseClass,
                                                                        List<String> baseImports,
                                                                        BiFunction<CodeFactory.Task<B>,​B,​CodeContext<B>> contextCreator)
        Create a component CodeFactory.Base for 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 a CodeContext, and will usually correspond to (task, delegate) -> new XXXCodeContext(new XXXCodeConnector(task, delegate))
        Type Parameters:
        B - base delegate type
        Parameters:
        baseClass - base delegate superclass
        baseImports - default base imports
        contextCreator - create context for delegate
        Returns:
        code factory base
      • containerBase

        public static <B extends CodeContainerDelegateCodeFactory.Base<B> containerBase​(Class<B> baseClass,
                                                                                          List<String> baseImports,
                                                                                          BiFunction<CodeFactory.Task<B>,​B,​CodeContext<B>> contextCreator)
        Create a container CodeFactory.Base for 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 a CodeContext, and will usually correspond to (task, delegate) -> new XXXCodeContext(new XXXCodeConnector(task, delegate))
        Type Parameters:
        B - base delegate type
        Parameters:
        baseClass - base delegate superclass
        baseImports - default base imports
        contextCreator - create context for delegate
        Returns:
        code factory base
      • rootBase

        public static <B extends CodeRootDelegateCodeFactory.Base<B> rootBase​(Class<B> baseClass,
                                                                                List<String> baseImports,
                                                                                BiFunction<CodeFactory.Task<B>,​B,​CodeContext<B>> contextCreator)
        Create a root component CodeFactory.Base for 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 a CodeContext, and will usually correspond to (task, delegate) -> new XXXCodeContext(new XXXCodeConnector(task, delegate))
        Type Parameters:
        B - base delegate type
        Parameters:
        baseClass - base delegate superclass
        baseImports - default base imports
        contextCreator - create context for delegate
        Returns:
        code factory base
      • rootContainerBase

        public static <B extends CodeRootContainerDelegateCodeFactory.Base<B> rootContainerBase​(Class<B> baseClass,
                                                                                                  List<String> baseImports,
                                                                                                  BiFunction<CodeFactory.Task<B>,​B,​CodeContext<B>> contextCreator)
        Create a root container CodeFactory.Base for 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 a CodeContext, and will usually correspond to (task, delegate) -> new XXXCodeContext(new XXXCodeConnector(task, delegate))
        Type Parameters:
        B - base delegate type
        Parameters:
        baseClass - base delegate superclass
        baseImports - default base imports
        contextCreator - create context for delegate
        Returns:
        code factory base