Package com.google.auto.value.processor
Class Optionalish
- java.lang.Object
-
- com.google.auto.value.processor.Optionalish
-
public class Optionalish extends java.lang.ObjectA 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 Summary
Fields Modifier and Type Field Description private java.lang.StringclassNameprivate static com.google.common.collect.ImmutableSet<java.lang.String>OPTIONAL_CLASS_NAMESprivate javax.lang.model.type.DeclaredTypeoptionalTypeprivate static com.google.common.collect.ImmutableMap<java.lang.String,javax.lang.model.type.TypeKind>PRIMITIVE_TYPE_KINDS
-
Constructor Summary
Constructors Modifier Constructor Description privateOptionalish(javax.lang.model.type.DeclaredType optionalType)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static OptionalishcreateIfOptional(javax.lang.model.type.TypeMirror type)Returns an instance wrapping the given TypeMirror, or null if it is not any kind of Optional.private javax.lang.model.type.TypeMirrorgetContainedPrimitiveType(javax.lang.model.util.Types typeUtils)(package private) javax.lang.model.type.TypeMirrorgetContainedType(javax.lang.model.util.Types typeUtils)java.lang.StringgetEmpty()Returns a string representing the method call to obtain the empty version of this Optional.java.lang.StringgetRawType()Returns a string representing the raw type of this Optional.(package private) static booleanisOptional(javax.lang.model.type.TypeMirror type)(package private) java.lang.StringofNullable()
-
-
-
Field Detail
-
OPTIONAL_CLASS_NAMES
private static final com.google.common.collect.ImmutableSet<java.lang.String> OPTIONAL_CLASS_NAMES
-
optionalType
private final javax.lang.model.type.DeclaredType optionalType
-
className
private final java.lang.String className
-
PRIMITIVE_TYPE_KINDS
private static final com.google.common.collect.ImmutableMap<java.lang.String,javax.lang.model.type.TypeKind> PRIMITIVE_TYPE_KINDS
-
-
Method Detail
-
createIfOptional
static Optionalish createIfOptional(javax.lang.model.type.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 exampleOptional<String>.
-
isOptional
static boolean isOptional(javax.lang.model.type.TypeMirror type)
-
getRawType
public java.lang.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 java.lang.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.emptyfrom templates.
-
getContainedType
javax.lang.model.type.TypeMirror getContainedType(javax.lang.model.util.Types typeUtils)
-
ofNullable
java.lang.String ofNullable()
-
getContainedPrimitiveType
private javax.lang.model.type.TypeMirror getContainedPrimitiveType(javax.lang.model.util.Types typeUtils)
-
-