com.fasterxml.jackson.core.util

## Class JacksonFeatureSet<F extends JacksonFeature>

- java.lang.Object
- - com.fasterxml.jackson.core.util.JacksonFeatureSet<F>

-     public final class JacksonFeatureSet<F extends JacksonFeature>
      extends Object

  Container similar to `EnumSet` meant for storing sets of `JacksonFeature`s (usually `Enum`s): main difference being that these sets are immutable. Also only supports relatively small sets of features: specifically, up to 31 features.
  Since:
    2.12

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected int` | `_enabled`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `JacksonFeatureSet(int bitmask)` Constructor for creating instance with specific bitmask, wherein `1` bit means matching `JacksonFeature` is enabled and `0` disabled.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `asBitmask()` Accessor for underlying bitmask
    `static <F extends JacksonFeature> JacksonFeatureSet<F>` | `fromBitmask(int bitmask)`
    `static <F extends JacksonFeature> JacksonFeatureSet<F>` | `fromDefaults(F[] allFeatures)` "Default" factory which will calculate settings based on default-enabled status of all features.
    `boolean` | `isEnabled(F feature)` Main accessor for checking whether given feature is enabled in this feature set.
    `JacksonFeatureSet<F>` | `with(F feature)` Mutant factory for getting a set in which specified feature is enabled: will either return this instance (if no change), or newly created set (if there is change).
    `JacksonFeatureSet<F>` | `without(F feature)` Mutant factory for getting a set in which specified feature is disabled: will either return this instance (if no change), or newly created set (if there is change).

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

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

- - ### Field Detail

    - #### _enabled

          protected int _enabled

  - ### Constructor Detail

    - #### JacksonFeatureSet

          protected JacksonFeatureSet(int bitmask)

      Constructor for creating instance with specific bitmask, wherein `1` bit means matching `JacksonFeature` is enabled and `0` disabled.
      Parameters:
        `bitmask` - Bitmask for features that are enabled

  - ### Method Detail

    - #### fromDefaults

          public static <F extends JacksonFeature> JacksonFeatureSet<F> fromDefaults(F[] allFeatures)

      "Default" factory which will calculate settings based on default-enabled status of all features.
      Type Parameters:
        `F` - Self-reference type for convenience
      Parameters:
        `allFeatures` - Set of all features (enabled or disabled): usually from `Enum.values()`
      Returns:
        Feature set instance constructed

    - #### fromBitmask

          public static <F extends JacksonFeature> JacksonFeatureSet<F> fromBitmask(int bitmask)

    - #### with

          public JacksonFeatureSet<F> with(F feature)

      Mutant factory for getting a set in which specified feature is enabled: will either return this instance (if no change), or newly created set (if there is change).
      Parameters:
        `feature` - Feature to enable in set returned
      Returns:
        Newly created set of state of feature changed; `this` if not

    - #### without

          public JacksonFeatureSet<F> without(F feature)

      Mutant factory for getting a set in which specified feature is disabled: will either return this instance (if no change), or newly created set (if there is change).
      Parameters:
        `feature` - Feature to disable in set returned
      Returns:
        Newly created set of state of feature changed; `this` if not

    - #### isEnabled

          public boolean isEnabled(F feature)

      Main accessor for checking whether given feature is enabled in this feature set.
      Parameters:
        `feature` - Feature to check
      Returns:
        True if feature is enabled in this set; false otherwise

    - #### asBitmask

          public int asBitmask()

      Accessor for underlying bitmask
      Returns:
        Bitmask of enabled features

Copyright © 2008–2021 FasterXML. All rights reserved.