Class Out<T>

java.lang.Object
org.javagi.base.Out<T>
Type Parameters:
T - The parameter type.

@NullMarked public class Out<T> extends Object
A wrapper class for out-parameters of (usually primitive) values. When a method expects an Out<> object, the user must create it, optionally fill it with an initial value, and pass it to the method. After the method has returned, the user can read the the value of the out-parameter with a call to get().
  • Constructor Summary

    Constructors
    Constructor
    Description
    Out()
    Create an Out object with no initial value.
    Out(@Nullable T value)
    Create an Out object and set the initial value.
  • Method Summary

    Modifier and Type
    Method
    Description
    @Nullable T
    get()
    Get the value from the out-parameter.
    void
    set(@Nullable T value)
    Set the parameter to the provided value.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Out

      public Out()
      Create an Out object with no initial value.
    • Out

      public Out(@Nullable T value)
      Create an Out object and set the initial value.
      Parameters:
      value - the initial value
  • Method Details

    • get

      public @Nullable T get()
      Get the value from the out-parameter.
      Returns:
      the value of the out-parameter
    • set

      public void set(@Nullable T value)
      Set the parameter to the provided value.
      Parameters:
      value - the value to set