Class GlobalDecorator

  • All Implemented Interfaces:
    Decorator

    public class GlobalDecorator
    extends Object
    implements Decorator
    A GlobalDecorator stores decorators configuration in order to re-apply them when requested to decorate a given heap object instance.
    • Field Detail

      • GLOBAL_DECORATOR_HEAP_KEY

        public static final String GLOBAL_DECORATOR_HEAP_KEY
        Heap Key for the global decorator(s). They may be local to each Heap.
        See Also:
        Constant Field Values
    • Constructor Detail

      • GlobalDecorator

        public GlobalDecorator​(Decorator parent,
                               JsonValue config,
                               Heap heap,
                               String... reservedFieldNames)
        Builds a new GlobalDecorator using given decorators JSON object element.
        Parameters:
        parent - the parent global decorator from which additional global decorators may be inherited. May be null
        config - a JSON configuration
        heap - the heap where this global decorator is declared (never null)
        reservedFieldNames - the names of reserved top level fields in the config which
    • Method Detail

      • accepts

        public boolean accepts​(Class<?> type)
        Description copied from interface: Decorator
        Returns true if this decorator is compatible with the provided component type. Note that a return value of true does not necessarily indicate that decoration will be performed since it may also depend on other factors
        Specified by:
        accepts in interface Decorator
        Parameters:
        type - type under test
        Returns:
        true if the decorator can decorate instance of the given type, false otherwise.
      • decorate

        public DecorationHandle decorate​(Object delegate,
                                         JsonValue ignored,
                                         Context context)
                                  throws HeapException
        Decorate the given object instance with the previously declared set of decorations instead of the provided one.
        Specified by:
        decorate in interface Decorator
        Parameters:
        delegate - instance to decorate
        ignored - ignored (may probably be null)
        context - Context of the heap object to be decorated
        Returns:
        the decorated instance or the original delegate (if no decorator could apply)
        Throws:
        HeapException - if one of the decorator failed to decorate the instance