Class PositiveNegativeRestriction

java.lang.Object
com.github.rvesse.airline.restrictions.AbstractCommonRestriction
com.github.rvesse.airline.restrictions.common.PositiveNegativeRestriction
All Implemented Interfaces:
HelpHint, ArgumentsRestriction, OptionRestriction

public class PositiveNegativeRestriction extends AbstractCommonRestriction implements HelpHint
Restriction that enforces that values must be either positive/negative with zero optionally included
  • Field Details

    • byteRestrictor

      private final RangeRestriction byteRestrictor
    • shortRestrictor

      private final RangeRestriction shortRestrictor
    • integerRestrictor

      private final RangeRestriction integerRestrictor
    • longRestrictor

      private final RangeRestriction longRestrictor
    • floatRestrictor

      private final RangeRestriction floatRestrictor
    • doubleRestrictor

      private final RangeRestriction doubleRestrictor
    • positive

      private final boolean positive
    • includeZero

      private final boolean includeZero
    • type

      private final String type
    • range

      private final String range
  • Constructor Details

    • PositiveNegativeRestriction

      public PositiveNegativeRestriction(boolean positive, boolean includeZero)
      Creates a new restriction
      Parameters:
      positive - Whether the value must be positive
      includeZero - Whether zero is included as a valid value
  • Method Details

    • isValid

      protected boolean isValid(Object value)
    • postValidate

      public <T> void postValidate(ParseState<T> state, OptionMetadata option, Object value)
      Description copied from interface: OptionRestriction
      Method that is called after Airline has converted a string argument received into a strongly typed Java value
      Specified by:
      postValidate in interface OptionRestriction
      Overrides:
      postValidate in class AbstractCommonRestriction
      Parameters:
      state - Parser state
      option - Option meta-data
      value - Strongly typed value
    • postValidate

      public <T> void postValidate(ParseState<T> state, ArgumentsMetadata arguments, Object value)
      Description copied from interface: ArgumentsRestriction
      Method that is called after Airline has converted a string argument received into a strongly typed Java value
      Specified by:
      postValidate in interface ArgumentsRestriction
      Overrides:
      postValidate in class AbstractCommonRestriction
      Parameters:
      state - Parser state
      arguments - Arguments meta-data
      value - Strongly typed value
    • 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