Package 

Class UnsetValue


  • 
    public final class UnsetValue
    
                        

    A factory of Values representing default states of Protobuf message fields.

    This class does not instantiate default values of Protobuf messages. It merely creates instances of Value which represent values of Protobuf message fields, which are not set.

    • Method Summary

      Modifier and Type Method Description
      static Optional<Value> forField(Field field) Obtains an unset value for the given field.
      static Optional<Value> singular(Type type) Obtains the default value for type of the given field.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • forField

         static Optional<Value> forField(Field field)

        Obtains an unset value for the given field.

        If a field is a number or a {@code bool}, it is impossible to tell if it's set or not. In the binary representation, the {@code 0} and {@code false} values may either be explicitly set or just be the default values. For these cases, and only for these cases, the method returns {@code Optional.empty()}.

      • singular

         static Optional<Value> singular(Type type)

        Obtains the default value for type of the given field.

        Behaves in a similar way to forField, but never returns an empty list or an empty map.