Class FeatureDecorator<T, F extends Enum<F>>

java.lang.Object
net.logstash.logback.decorate.FeatureDecorator<T,F>
Type Parameters:
T - Type of object being decorated (e.g. JsonFactory)
F - Feature enum type (e.g. JsonWriteFeature)
All Implemented Interfaces:
Decorator<T>
Direct Known Subclasses:
CborWriteFeatureDecorator, DateTimeFeatureDecorator, EnumFeatureDecorator, JsonNodeFeatureDecorator, JsonWriteFeatureDecorator, MapperFeatureDecorator, SerializationFeatureDecorator, SmileWriteFeatureDecorator, StreamWriteFeatureDecorator, TokenStreamFactoryFeatureDecorator, YamlWriteFeatureDecorator

public abstract class FeatureDecorator<T, F extends Enum<F>> extends Object implements Decorator<T>
A generic decorator that allows enabling/disabling of Jackson features by feature name.
  • Constructor Details

    • FeatureDecorator

      protected FeatureDecorator(Class<F> enumType)
  • Method Details

    • decorate

      public T decorate(T decoratable)
      Description copied from interface: Decorator
      Decorates the given decoratable.
      Specified by:
      decorate in interface Decorator<T>
      Parameters:
      decoratable - the object to decorate
      Returns:
      the decorated object (can be a different from the object passed in as an arg)
    • configure

      protected abstract T configure(T decoratable, F feature, boolean state)
      Configures the given feature on the given decoratable.
      Parameters:
      decoratable - the object to configure
      feature - the feature to enable or disable
      state - true to enable the feature, false to disable the feature.
      Returns:
      the decorated object
    • addEnable

      public void addEnable(String feature)
      Enables the feature with the given name. Reflectively called by logback when reading xml configuration.
      Parameters:
      feature - the name of the feature to enable
    • enable

      public void enable(F feature)
      Enables the given feature. Use this method for programmatic configuration.
      Parameters:
      feature - the feature to enable
    • addDisable

      public void addDisable(String feature)
      Disables the feature with the given name. Reflectively called by logback when reading xml configuration.
      Parameters:
      feature - the name of the feature to disable
    • disable

      public void disable(F feature)
      Disables the given feature. Use this method for programmatic configuration.
      Parameters:
      feature - the feature to disable