com.hammurapi.convert

## Class DecoratingService

- java.lang.Object
- - com.hammurapi.convert.DecoratingService

-     public class DecoratingService
      extends Object

  Decorates objects based on their type and decoration providers available. Decoration is done with dynamic proxies.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static Decorator` | `DECORATOR` Converter which delegates to convert() method.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DecoratingService()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static Object` | `decorate(Object obj)` Decorates object using static decoration providers from the object's class classloader.
    `static Object` | `decorate(Object obj, ClassLoader classLoader)` Decorates object using providers from the given classloader.
    `static Object` | `decorate(Object obj, Context context)` Decorates object using static decoration providers from the object's class classloader.
    `static Object` | `decorate(Object obj, Context context, ClassLoader classLoader)` Decorates object using given context for dynamic decorators and given class loader to load decorating providers.
    `static Decorator` | `getDecorator()` Creates decorating closure.
    `static Decorator` | `getDecorator(ClassLoader classLoader)` Creates decorating closure.
    `static Decorator` | `getDecorator(Context context)` Creates decorating closure.
    `static Decorator` | `getDecorator(Context context, ClassLoader classLoader)` Creates decorating closure.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### DECORATOR

          public static final Decorator DECORATOR

      Converter which delegates to convert() method.

  - ### Constructor Detail

    - #### DecoratingService

          public DecoratingService()

  - ### Method Detail

    - #### decorate

          public static Object decorate(Object obj)

      Decorates object using static decoration providers from the object's class classloader. If there are no decorations available or object doesn't impement any interfaces, then the object is returned as-is.
      Parameters:
        `obj` - Object to be decorated
      Returns:
        Decorated object (dynamic proxy instance) or original object if no decorations are available or object doesn't implement any interfaces.

    - #### decorate

          public static Object decorate(Object obj,
                        Context context)

      Decorates object using static decoration providers from the object's class classloader. If there are no decorations available or object doesn't impement any interfaces, then the object is returned as-is.
      Parameters:
        `obj` - Object to be decorated
        `context` - Context for dynamic decorators.
      Returns:
        Decorated object (dynamic proxy instance) or original object if no decorations are available or object doesn't implement any interfaces.

    - #### decorate

          public static Object decorate(Object obj,
                        ClassLoader classLoader)

      Decorates object using providers from the given classloader.
      Parameters:
        `obj` - Object to decorate.
        `classLoader` - Class loader.
      Returns:
        Decorated object (dynamic proxy instance) or original object if no decorations are available or object doesn't implement any interfaces.

    - #### decorate

          public static Object decorate(Object obj,
                        Context context,
                        ClassLoader classLoader)

      Decorates object using given context for dynamic decorators and given class loader to load decorating providers.
      Parameters:
        `obj` - Object to decorate.
        `context` - Context for dynamic decorators.
        `classLoader` - Class loader.
      Returns:
        Decorated object (dynamic proxy instance) or original object if no decorations are available or object doesn't implement any interfaces.

    - #### getDecorator

          public static Decorator getDecorator()

      Creates decorating closure.
      Returns:
        Decorating closure.

    - #### getDecorator

          public static Decorator getDecorator(ClassLoader classLoader)

      Creates decorating closure.
      Parameters:
        `classLoader` - Class loader.
      Returns:
        Decorating closure.

    - #### getDecorator

          public static Decorator getDecorator(Context context)

      Creates decorating closure.
      Parameters:
        `context` - Context for dynamic decorators.
      Returns:
        Decorating closure.

    - #### getDecorator

          public static Decorator getDecorator(Context context,
                               ClassLoader classLoader)

      Creates decorating closure.
      Parameters:
        `context` - Context for dynamic decorators.
        `classLoader` - Class loader.
      Returns:
        Decorating closure.