Module aeonics.core

Class Destination

  • Direct Known Subclasses:
    HttpResponse

    public class Destination
    extends Item<Destination.Type>
    This class represents the Destination of data. It is the termination point of a data flow.

    Every time some data is available the Destination.Type.accept(Message, String) method will be called.

    Be careful that multiple calls to the Destination.Type.accept(Message, String) method may happen in parallel. If your implementation is not thread safe, you should add proper thread safety (example with a synchronized block statement).

    There are two recommended ways to create your own item inline (without creating a full class). The first method allows to provide the data processing function and registers automatically the template in the factory and the instance in the registry:

     Destination.Type item = new Destination() { } // <-- note the '{ }' to create a new anonymous class
         
         .template() // <-- create the template and register it in the factory
         
         // add all your template documentation
         .summary("Does something")
         
         .create() // <-- create an instance of the entity and register it in the registry
         
         // set the processing function
         .process((message, input) -> {}); // <-- the process logic
     

    If you need more control over the behavior such as private member variables or multiple methods, then you need to declare a custom entity end register it before calling the template method:

     public static class MyEntity extends Destination.Type {
         private void log(Message message) { System.out.println(message); }
         public void accept(Message message, String input) { log(message); }
     }
     
     Destination.Type item = new Destination() { } // <-- note the '{ }' to create a new anonymous class
         
         // register the custom entity before calling the template
         .target(MyEntity.class)
         .creator(MyEntity::new)
         
         .template() // <-- create the template and register it in the factory
         
         // add all your template documentation
         .summary("Do something")
         
         .create(); // <-- create an instance of the entity and register it in the registry
     
    • Constructor Detail

      • Destination

        public Destination()
    • Method Detail

      • defaultTarget

        protected java.lang.Class<? extends Destination.Type> defaultTarget()
        Description copied from class: Item
        Returns the default target entity type. This method should be implemented by subclasses to specify the target entity type.
        Specified by:
        defaultTarget in class Item<Destination.Type>
        Returns:
        the default target entity type
      • defaultCreator

        protected java.util.function.Supplier<? extends Destination.Type> defaultCreator()
        Description copied from class: Item
        Returns the default target entity creator. This method should be implemented by subclasses to specify the entity creator.
        Specified by:
        defaultCreator in class Item<Destination.Type>
        Returns:
        the default target entity creator
      • category

        protected java.lang.Class<? extends Destination> category()
        Description copied from class: Item
        Returns the target entity category. This method should be implemented by subclasses to specify the entity category.
        Specified by:
        category in class Item<Destination.Type>
        Returns:
        the target entity category
      • template

        public Destination.Template template()
        Description copied from class: Item
        Returns the template to build the target entity.

        This method should ultimately be used to provide the final entity template. Although, it may also provide a partial template that subclassed may complement.

        Overrides:
        template in class Item<Destination.Type>
        Returns:
        the matching entity template