Class DefaultBuilderRef<T>

java.lang.Object
software.amazon.smithy.utils.DefaultBuilderRef<T>
Type Parameters:
T - The type of value being built, borrowed, and copied.
All Implemented Interfaces:
BuilderRef<T>

public final class DefaultBuilderRef<T> extends Object implements BuilderRef<T>
Default implementation of BuilderRef.

This class is not threadsafe; it should only be used to build up other objects using copy().

  • Constructor Details

  • Method Details

    • get

      public T get()
    • peek

      public T peek()
    • copy

      public T copy()
      Description copied from interface: BuilderRef
      Creates an immutable copy of T.

      Subsequent calls to BuilderRef.hasValue() may or may not return true after this method is called.

      Specified by:
      copy in interface BuilderRef<T>
      Returns:
      Returns the copied immutable value.
    • hasValue

      public boolean hasValue()
      Description copied from interface: BuilderRef
      Checks if the reference currently has a borrowed or owned value.

      This method does not check if the contained value is considered empty. This method only returns true if the reference contains any kind of previously built value. This might be useful for builder methods that attempt to remove values from the contained object. If there is no contained object, then there's no need to create one just to remove a value from an empty container.

      Specified by:
      hasValue in interface BuilderRef<T>
      Returns:
      Returns true if the reference contains a value of any kind.
    • clear

      public void clear()
      Description copied from interface: BuilderRef
      Removes any borrowed or owned values from the reference.

      Subsequent calls to BuilderRef.hasValue() will return false after this method is called.

      Specified by:
      clear in interface BuilderRef<T>