Package com.google.auto.value.processor
Class Optionalish
- java.lang.Object
-
- com.google.auto.value.processor.Optionalish
-
public class Optionalish extends java.lang.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 Summary
Fields Modifier and Type Field Description private java.lang.String
className
private static com.google.common.collect.ImmutableSet<java.lang.String>
OPTIONAL_CLASS_NAMES
private javax.lang.model.type.DeclaredType
optionalType
private static com.google.common.collect.ImmutableMap<java.lang.String,javax.lang.model.type.TypeKind>
PRIMITIVE_TYPE_KINDS
-
Constructor Summary
Constructors Modifier Constructor Description private
Optionalish(javax.lang.model.type.DeclaredType optionalType)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) 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.private javax.lang.model.type.TypeMirror
getContainedPrimitiveType(javax.lang.model.util.Types typeUtils)
(package private) javax.lang.model.type.TypeMirror
getContainedType(javax.lang.model.util.Types typeUtils)
java.lang.String
getEmpty()
Returns a string representing the method call to obtain the empty version of this Optional.java.lang.String
getRawType()
Returns a string representing the raw type of this Optional.(package private) static boolean
isOptional(javax.lang.model.type.TypeMirror type)
(package private) java.lang.String
ofNullable()
-
-
-
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.empty
from 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)
-
-