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

public class PathRestriction extends AbstractCommonRestriction implements HelpHint
Implements restriction on options and arguments that expect to receive a path to a file and/or directory
  • Field Details

    • mustExist

      private final boolean mustExist
    • readable

      private final boolean readable
    • writable

      private final boolean writable
    • executable

      private final boolean executable
    • kind

      private final PathKind kind
  • Constructor Details

    • PathRestriction

      public PathRestriction(boolean mustExist, boolean readable, boolean writable, boolean executable, PathKind kind)
      Creates a new path restriction
      Parameters:
      mustExist - Whether the path must exist
      readable - Whether the path must be readable, if the specific path does not exist then this check validates that the first parent in the path that exists is readable
      writable - Whether the path must be writable, if the specific path does not exist then this check validates that the first parent in the path that exists is writable
      executable - Whether the path must be executable, if the specific path does not exist then this check validates that the first parent in the path that exists is executable
      kind -
  • Method Details

    • validate

      protected void validate(String title, String path)
    • notExecutable

      private void notExecutable(String title, String path)
    • notWritable

      private void notWritable(String title, String path)
    • notReadable

      private void notReadable(String title, String path)
    • preValidate

      public <T> void preValidate(ParseState<T> state, OptionMetadata option, String value)
      Description copied from interface: OptionRestriction
      Method that is called before Airline attempts to convert a string argument received into a strongly typed Java value
      Specified by:
      preValidate in interface OptionRestriction
      Overrides:
      preValidate in class AbstractCommonRestriction
      Parameters:
      state - Parser state
      option - Option meta-data
      value - String value
    • preValidate

      public <T> void preValidate(ParseState<T> state, ArgumentsMetadata arguments, String value)
      Description copied from interface: ArgumentsRestriction
      Method that is called before Airline attempts to convert a string argument received into a strongly typed Java value
      Specified by:
      preValidate in interface ArgumentsRestriction
      Overrides:
      preValidate in class AbstractCommonRestriction
      Parameters:
      state - Parser state
      arguments - Arguments meta-data
      value - String 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