Class Optionalish

java.lang.Object
com.google.auto.value.processor.Optionalish

public class Optionalish extends Object
A wrapper for properties of Optional-like classes. This can be com.google.common.base.Optional, or any of Optional, OptionalDouble, OptionalInt, OptionalLong in java.util.
  • Field Details

    • OPTIONAL_CLASS_NAMES

      private static final com.google.common.collect.ImmutableSet<String> OPTIONAL_CLASS_NAMES
    • optionalType

      private final DeclaredType optionalType
    • className

      private final String className
    • PRIMITIVE_TYPE_KINDS

      private static final com.google.common.collect.ImmutableMap<String,TypeKind> PRIMITIVE_TYPE_KINDS
  • Constructor Details

    • Optionalish

      private Optionalish(DeclaredType optionalType)
  • Method Details

    • createIfOptional

      static Optionalish createIfOptional(TypeMirror type)
      Returns an instance wrapping the given TypeMirror, or null if it is not any kind of Optional.
      Parameters:
      type - the TypeMirror for the original optional type, for example Optional<String>.
    • isOptional

      static boolean isOptional(TypeMirror type)
    • getRawType

      public String getRawType()
      Returns a string representing the raw type of this Optional. This will typically be just "Optional", but it might be "OptionalInt" or "java.util.Optional" for example.
    • getEmpty

      public String getEmpty()
      Returns a string representing the method call to obtain the empty version of this Optional. This will be something like "Optional.empty()" or possibly "java.util.Optional.empty()". It does not have a final semicolon.

      This method is public so that it can be referenced as p.optional.empty from templates.

    • getContainedType

      TypeMirror getContainedType(Types typeUtils)
    • ofNullable

      String ofNullable()
    • getContainedPrimitiveType

      private TypeMirror getContainedPrimitiveType(Types typeUtils)