Class AbstractRequiredUnlessRestriction

java.lang.Object
com.github.rvesse.airline.restrictions.AbstractCommonRestriction
com.github.rvesse.airline.restrictions.options.AbstractRequiredUnlessRestriction
All Implemented Interfaces:
ArgumentsRestriction, OptionRestriction
Direct Known Subclasses:
RequiredUnlessEnvironmentRestriction

public abstract class AbstractRequiredUnlessRestriction extends AbstractCommonRestriction
A restriction that options/arguments are required unless some other criteria is met
  • Constructor Details

    • AbstractRequiredUnlessRestriction

      public AbstractRequiredUnlessRestriction()
  • Method Details

    • unless

      protected abstract <T> boolean unless(ParseState<T> state, OptionMetadata option)
      Answers whether the unless condition of the restriction is met

      If the unless condition is met then the restriction will not require the option to be present.

      Type Parameters:
      T - Command Type
      Parameters:
      state - Parse state
      option - Option Metadata
      Returns:
      True if unless condition met, false otherwise
    • unless

      protected abstract <T> boolean unless(ParseState<T> state, ArgumentsMetadata arguments)
      Answers whether the unless condition of the restriction is met

      If the unless condition is met then the restriction will not require arguments to be present.

      Type Parameters:
      T - Command Type
      Parameters:
      state - Parse state
      arguments - Arguments Metadata
      Returns:
      True if unless condition met, false otherwise
    • unlessDescription

      protected abstract String unlessDescription()
      Provides a description of the unless condition, this will be included in the error messages when this restriction is not met
      Returns:
      Unless condition description
    • finalValidate

      public <T> void finalValidate(ParseState<T> state, OptionMetadata option)
      Description copied from interface: OptionRestriction
      Method that is called after Airline has completed parsing

      This can be used to implement restrictions that require the final parser state to process

      Specified by:
      finalValidate in interface OptionRestriction
      Overrides:
      finalValidate in class AbstractCommonRestriction
      Parameters:
      state - Parser state
      option - Option meta-data
    • finalValidate

      public <T> void finalValidate(ParseState<T> state, ArgumentsMetadata arguments)
      Description copied from interface: ArgumentsRestriction
      Method that is called after Airline has completed parsing

      This can be used to implement restrictions that require the final parser state to process

      Specified by:
      finalValidate in interface ArgumentsRestriction
      Overrides:
      finalValidate in class AbstractCommonRestriction
      Parameters:
      state - Parser state
      arguments - Arguments meta-data