Class ArgumentValue<T>

java.lang.Object
org.springframework.graphql.data.ArgumentValue<T>
Type Parameters:
T - the type of value contained

public final class ArgumentValue<T> extends Object
Simple container for the value from binding a GraphQL argument to a higher level Object, along with a flag to indicate whether the input argument was omitted altogether, as opposed to provided but set to the "null" literal.

Supported in one of the following places:

  • On a controller method parameter, either instead of @Argument in which case the argument name is determined from the method parameter name, or together with @Argument to specify the argument name.
  • As a field within the object structure of an @Argument method parameter, either initialized via a constructor argument or a setter, including as a field of an object nested at any level below the top level object.
Since:
1.1.0
Author:
Rossen Stoyanchev
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    Return the contained value as a nullable Optional.
    boolean
    equals(Object other)
     
    int
     
    boolean
    Return true if the input value was omitted altogether from the input, and false if it was provided, but possibly set to the "null" literal.
    boolean
    Return true if a non-null value is present, and false otherwise.
    static <T> ArgumentValue<T>
    ofNullable(T value)
    Static factory method for an argument value that was provided, even if it was set to "null.
    static <T> ArgumentValue<T>
    Static factory method for an argument value that was omitted.
    Return the contained value, or null.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • isPresent

      public boolean isPresent()
      Return true if a non-null value is present, and false otherwise.
    • isOmitted

      public boolean isOmitted()
      Return true if the input value was omitted altogether from the input, and false if it was provided, but possibly set to the "null" literal.
    • value

      @Nullable public T value()
      Return the contained value, or null.
    • asOptional

      public Optional<T> asOptional()
      Return the contained value as a nullable Optional.
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • ofNullable

      public static <T> ArgumentValue<T> ofNullable(@Nullable T value)
      Static factory method for an argument value that was provided, even if it was set to "null.
      Parameters:
      value - the value to hold in the instance
    • omitted

      public static <T> ArgumentValue<T> omitted()
      Static factory method for an argument value that was omitted.