Class QualifiedName
- java.lang.Object
-
- org.inferred.freebuilder.processor.source.ValueType
-
- org.inferred.freebuilder.processor.source.QualifiedName
-
- All Implemented Interfaces:
java.lang.Comparable<QualifiedName>
public class QualifiedName extends ValueType implements java.lang.Comparable<QualifiedName>
The qualified name of a type. Lets us pass a type to aTypeShortenerwithout a Class or javax.lang.model reference.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.inferred.freebuilder.processor.source.ValueType
ValueType.FieldReceiver
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringpackageNameprivate com.google.common.collect.ImmutableList<java.lang.String>simpleNames
-
Constructor Summary
Constructors Modifier Constructor Description privateQualifiedName(java.lang.String packageName, com.google.common.collect.ImmutableList<java.lang.String> simpleNames)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddFields(ValueType.FieldReceiver fields)Implement this method to report the name and value of each field.intcompareTo(QualifiedName o)QualifiedNameenclosingType()Returns theQualifiedNameof the type enclosing this one.java.lang.StringgetPackage()java.lang.StringgetSimpleName()com.google.common.collect.ImmutableList<java.lang.String>getSimpleNames()booleanisNestedIn(QualifiedName other)booleanisTopLevel()QualifiedNamenestedType(java.lang.String simpleName)Returns theQualifiedNameof a type calledsimpleNamenested in this one.static QualifiedNameof(java.lang.Class<?> cls)Returns aQualifiedNameforcls, unshading if necessary.static QualifiedNameof(java.lang.String packageName, java.lang.String topLevelType, java.lang.String... nestedTypes)Returns aQualifiedNamefor a type inpackageName.static QualifiedNameof(javax.lang.model.element.TypeElement type)Returns aQualifiedNamefortype.java.lang.StringtoString()Returns this qualified name as a string.TypeClasswithParameters(java.lang.Iterable<? extends javax.lang.model.element.TypeParameterElement> typeParameters)TypeClasswithParameters(javax.lang.model.element.TypeParameterElement... parameters)TypewithParameters(javax.lang.model.type.TypeMirror first, javax.lang.model.type.TypeMirror... rest)
-
-
-
Method Detail
-
of
public static QualifiedName of(java.lang.String packageName, java.lang.String topLevelType, java.lang.String... nestedTypes)
Returns aQualifiedNamefor a type inpackageName. IfnestedTypesis empty, it is a top level type calledtopLevelType; otherwise, it is nested in that type.
-
of
public static QualifiedName of(java.lang.Class<?> cls)
Returns aQualifiedNameforcls, unshading if necessary.
-
of
public static QualifiedName of(javax.lang.model.element.TypeElement type)
Returns aQualifiedNamefortype.
-
toString
public java.lang.String toString()
Returns this qualified name as a string.Returns the same as
Class.getName()andTypeElement.getQualifiedName()would for the same type, e.g. "java.lang.Integer" or "com.example.OuterType.InnerType".
-
getPackage
public java.lang.String getPackage()
-
enclosingType
public QualifiedName enclosingType()
Returns theQualifiedNameof the type enclosing this one.- Throws:
java.lang.IllegalStateException- ifisTopLevel()returns true
-
getSimpleNames
public com.google.common.collect.ImmutableList<java.lang.String> getSimpleNames()
-
getSimpleName
public java.lang.String getSimpleName()
-
isTopLevel
public boolean isTopLevel()
-
isNestedIn
public boolean isNestedIn(QualifiedName other)
-
nestedType
public QualifiedName nestedType(java.lang.String simpleName)
Returns theQualifiedNameof a type calledsimpleNamenested in this one.
-
withParameters
public TypeClass withParameters(javax.lang.model.element.TypeParameterElement... parameters)
-
withParameters
public Type withParameters(javax.lang.model.type.TypeMirror first, javax.lang.model.type.TypeMirror... rest)
-
withParameters
public TypeClass withParameters(java.lang.Iterable<? extends javax.lang.model.element.TypeParameterElement> typeParameters)
-
compareTo
public int compareTo(QualifiedName o)
- Specified by:
compareToin interfacejava.lang.Comparable<QualifiedName>
-
addFields
protected void addFields(ValueType.FieldReceiver fields)
Description copied from class:ValueTypeImplement this method to report the name and value of each field.
-
-