public class Optionalish
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
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 |
private java.lang.String |
rawTypeSpelling |
Modifier | Constructor and Description |
---|---|
private |
Optionalish(javax.lang.model.type.DeclaredType optionalType,
java.lang.String rawTypeSpelling) |
Modifier and Type | Method and Description |
---|---|
(package private) static Optionalish |
createIfOptional(javax.lang.model.type.TypeMirror type,
java.lang.String rawTypeSpelling)
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) |
private static final com.google.common.collect.ImmutableSet<java.lang.String> OPTIONAL_CLASS_NAMES
private final javax.lang.model.type.DeclaredType optionalType
private final java.lang.String rawTypeSpelling
private static final com.google.common.collect.ImmutableMap<java.lang.String,javax.lang.model.type.TypeKind> PRIMITIVE_TYPE_KINDS
private Optionalish(javax.lang.model.type.DeclaredType optionalType, java.lang.String rawTypeSpelling)
static Optionalish createIfOptional(javax.lang.model.type.TypeMirror type, java.lang.String rawTypeSpelling)
type
- the TypeMirror for the original optional type, for example
Optional<String>
.rawTypeSpelling
- the representation of the base Optional type in source code, given
the imports that will be present. Usually this will be Optional
,
OptionalInt
, etc. In cases of ambiguity it might be java.util.Optional
etc.static boolean isOptional(javax.lang.model.type.TypeMirror type)
public java.lang.String getRawType()
"Optional"
, but it might be "OptionalInt"
or "java.util.Optional"
for example.public java.lang.String getEmpty()
"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.
javax.lang.model.type.TypeMirror getContainedType(javax.lang.model.util.Types typeUtils)
private javax.lang.model.type.TypeMirror getContainedPrimitiveType(javax.lang.model.util.Types typeUtils)