Top Description Fields Constructors Methods
com.google.auto.value.processor

public Class Optionalish

extends Object
Class Inheritance
Imports
com.google.auto.common.MoreElements, .MoreTypes, com.google.common.base.Verify, com.google.common.collect.ImmutableMap, .ImmutableSet, java.util.List, javax.lang.model.element.TypeElement, javax.lang.model.type.DeclaredType, javax.lang.model.type.TypeKind, javax.lang.model.type.TypeMirror, javax.lang.model.util.Types

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.
Author
[email protected] (Éamonn McManus)

Field Summary

Modifier and TypeField and Description
private final String
private static final ImmutableSet<String>
private final javax.lang.model.type.DeclaredType
private static final ImmutableMap<String, javax.lang.model.type.TypeKind>

Constructor Summary

AccessConstructor and Description
private
Optionalish(javax.lang.model.type.DeclaredType optionalType)

Method Summary

Modifier and TypeMethod and Description
pack-priv static Optionalish
createIfOptional(javax.lang.model.type.TypeMirror
the TypeMirror for the original optional type, for example Optional<String>.
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)

pack-priv javax.lang.model.type.TypeMirror
getContainedType(javax.lang.model.util.Types typeUtils)

public String
getEmpty()

Returns a string representing the method call to obtain the empty version of this Optional.

public String
getRawType()

Returns a string representing the raw type of this Optional.

pack-priv static boolean
isOptional(javax.lang.model.type.TypeMirror type)

pack-priv String
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

classNameback to summary
private final String className
OPTIONAL_CLASS_NAMESback to summary
private static final ImmutableSet<String> OPTIONAL_CLASS_NAMES
optionalTypeback to summary
private final javax.lang.model.type.DeclaredType optionalType
PRIMITIVE_TYPE_KINDSback to summary
private static final ImmutableMap<String, javax.lang.model.type.TypeKind> PRIMITIVE_TYPE_KINDS

Constructor Detail

Optionalishback to summary
private Optionalish(javax.lang.model.type.DeclaredType optionalType)

Method Detail

createIfOptionalback to summary
pack-priv 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:javax.lang.model.type.TypeMirror

the TypeMirror for the original optional type, for example Optional<String>.

getContainedPrimitiveTypeback to summary
private javax.lang.model.type.TypeMirror getContainedPrimitiveType(javax.lang.model.util.Types typeUtils)
getContainedTypeback to summary
pack-priv javax.lang.model.type.TypeMirror getContainedType(javax.lang.model.util.Types typeUtils)
getEmptyback to summary
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.

getRawTypeback to summary
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.

isOptionalback to summary
pack-priv static boolean isOptional(javax.lang.model.type.TypeMirror type)
ofNullableback to summary
pack-priv String ofNullable()