Package cdc.util.cli

Class FeatureMask<E extends Enum<E>>

  • Type Parameters:
    E - The feature enum type.

    public final class FeatureMask<E extends Enum<E>>
    extends Object
    Utility to handle features.
    Author:
    Damien Carbonne
    • Constructor Detail

      • FeatureMask

        public FeatureMask()
    • Method Detail

      • setEnabled

        public final void setEnabled​(E feature,
                                     boolean enabled)
      • add

        public final void add​(E feature)
      • addAll

        @SafeVarargs
        public final void addAll​(E... features)
      • remove

        public final void remove​(E feature)
      • isEnabled

        public final boolean isEnabled​(E feature)
      • isEmpty

        public boolean isEmpty()
      • contains

        public final boolean contains​(E feature)
      • toSet

        public final Set<E> toSet()
      • toList

        public final List<E> toList()
      • checkAtMostOne

        @SafeVarargs
        public final boolean checkAtMostOne​(org.apache.logging.log4j.Logger logger,
                                            FailureReaction reaction,
                                            E... features)
        Check that at most one feature is enabled in a group of features.
        Parameters:
        logger - The logger to use.
        reaction - The reaction to adopt in case of failure.
        features - The features.
        Returns:
        true if at most one feature among features is enabled in this FeatureMask.
      • checkExactlyOne

        @SafeVarargs
        public final boolean checkExactlyOne​(org.apache.logging.log4j.Logger logger,
                                             FailureReaction reaction,
                                             E... features)
        Check that exactly one feature is enabled in a group of features.
        Parameters:
        logger - The logger to use.
        reaction - The reaction to adopt in case of failure.
        features - The features.
        Returns:
        true if exactly one feature among features is enabled in this FeatureMask.