Class RequiredUnlessEnvironmentRestriction

All Implemented Interfaces:
HelpHint, ArgumentsRestriction, OptionRestriction

public class RequiredUnlessEnvironmentRestriction extends AbstractRequiredUnlessRestriction implements HelpHint
A restriction that requires an option/argument be set UNLESS a suitable environment variable is specified.
  • Field Details

    • variables

      private final List<String> variables
  • Constructor Details

    • RequiredUnlessEnvironmentRestriction

      public RequiredUnlessEnvironmentRestriction(String[] envVars)
  • Method Details

    • unless

      protected <T> boolean unless(ParseState<T> state, OptionMetadata option)
      Description copied from class: AbstractRequiredUnlessRestriction
      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.

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

      protected <T> boolean unless(ParseState<T> state, ArgumentsMetadata arguments)
      Description copied from class: AbstractRequiredUnlessRestriction
      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.

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

      protected String unlessDescription()
      Description copied from class: AbstractRequiredUnlessRestriction
      Provides a description of the unless condition, this will be included in the error messages when this restriction is not met
      Specified by:
      unlessDescription in class AbstractRequiredUnlessRestriction
      Returns:
      Unless condition description
    • getPreamble

      public String getPreamble()
      Description copied from interface: HelpHint
      Gets the preamble text that should be included
      Specified by:
      getPreamble in interface HelpHint
      Returns:
      Preamble text
    • getFormat

      public HelpFormat getFormat()
      Description copied from interface: HelpHint
      Gets the format of the provided help information
      Specified by:
      getFormat in interface HelpHint
      Returns:
      Help format
    • numContentBlocks

      public int numContentBlocks()
      Description copied from interface: HelpHint
      Gets the number of content blocks provided

      Help generators should consult the HelpHint.getFormat() return value to determine how to format the content blocks but they are not required to do so

      Specified by:
      numContentBlocks in interface HelpHint
      Returns:
      Number of content blocks
    • getContentBlock

      public String[] getContentBlock(int blockNumber)
      Description copied from interface: HelpHint
      Gets the content block with the given number
      Specified by:
      getContentBlock in interface HelpHint
      Parameters:
      blockNumber - Block number
      Returns:
      Content Block