Class PathArgument

java.lang.Object
io.github.grumpystuff.grumpyrest.request.PathArgument

public final class PathArgument extends Object
A concrete argument that was bound to a path parameter. This class contains the argument in its text form, not yet converted to a high-level / application type, and offers methods to perform this conversion. Instances of this class only exist for path parameters, not for fixed (literal) segments of a mounted route.
  • Constructor Details

    • PathArgument

      public PathArgument(String name, String text, ParseFromStringService parseFromStringService)
      NOT PUBLIC API
      Parameters:
      name - ...
      text - ...
      parseFromStringService - ...
  • Method Details

    • getName

      public String getName()
      Getter for the name of the path parameter.
      Returns:
      the name of the path parameter
    • getText

      public String getText()
      Getter for the textual value of the path argument
      Returns:
      the path argument text
    • getValue

      public <T> T getValue(Class<T> clazz) throws PathArgumentParseException
      Converts the path argument to the specified class type.
      Type Parameters:
      T - the static type of the class
      Parameters:
      clazz - the class to convert to
      Returns:
      the converted value
      Throws:
      PathArgumentParseException - if conversion fails because the path argument does not conform to the expected format according to the type to convert to
    • getValue

      public <T> T getValue(TypeToken<T> typeToken) throws PathArgumentParseException
      Converts the path argument to the specified type.
      Type Parameters:
      T - the static type to convert to
      Parameters:
      typeToken - a type token for the type to convert to
      Returns:
      the converted value
      Throws:
      PathArgumentParseException - if conversion fails because the path argument does not conform to the expected format according to the type to convert to
    • getValue

      public Object getValue(Type type) throws PathArgumentParseException
      Converts the path argument to the specified type.
      Parameters:
      type - the type to convert to
      Returns:
      the converted value
      Throws:
      PathArgumentParseException - if conversion fails because the path argument does not conform to the expected format according to the type to convert to