public class UnitsRelationsTools extends Object
Constructor and Description |
---|
UnitsRelationsTools() |
Modifier and Type | Method and Description |
---|---|
static @Nullable AnnotationMirror |
buildAnnoMirrorWithDefaultPrefix(ProcessingEnvironment env,
Class<? extends Annotation> annoClass)
Creates an AnnotationMirror representing a unit defined by annoClass, with the default Prefix
of
Prefix.one . |
static @Nullable AnnotationMirror |
buildAnnoMirrorWithNoPrefix(ProcessingEnvironment env,
@FullyQualifiedName CharSequence annoClass)
Creates an AnnotationMirror representing a unit defined by annoClass, with no prefix.
|
static @Nullable AnnotationMirror |
buildAnnoMirrorWithSpecificPrefix(ProcessingEnvironment env,
@FullyQualifiedName CharSequence annoClass,
Prefix p)
Creates an AnnotationMirror representing a unit defined by annoClass, with the specific Prefix
p.
|
static @Nullable AnnotationMirror |
buildAnnoMirrorWithSpecificPrefix(ProcessingEnvironment env,
Class<? extends Annotation> annoClass,
Prefix p)
Creates an AnnotationMirror representing a unit defined by annoClass, with the specific Prefix
p.
|
static @Nullable Prefix |
getPrefix(AnnotatedTypeMirror annoType)
Retrieves the SI Prefix of an Annotated Type.
|
static @Nullable Prefix |
getPrefix(AnnotationMirror unitsAnnotation)
Retrieves the SI Prefix of an Annotation.
|
static boolean |
hasNoPrefix(AnnotatedTypeMirror annoType)
Checks to see if an Annotated Type has no prefix.
|
static boolean |
hasNoPrefix(AnnotationMirror unitsAnnotation)
Checks to see if an Annotation has no prefix (ie, no value element).
|
static boolean |
hasNoUnits(AnnotatedTypeMirror annoType)
Checks to see if a particular Annotated Type has no units, such as scalar constants in
calculations.
|
static boolean |
hasSpecificUnit(AnnotatedTypeMirror annoType,
AnnotationMirror unitsAnnotation)
Checks to see if a particular Annotated Type has a specific unit (represented by its
Annotation).
|
static boolean |
hasSpecificUnitIgnoringPrefix(AnnotatedTypeMirror annoType,
AnnotationMirror unitsAnnotation)
Checks to see if a particular Annotated Type has a particular base unit (represented by its
Annotation).
|
static AnnotatedTypeMirror |
removePrefix(Elements elements,
AnnotatedTypeMirror annoType)
Removes the Prefix value from an Annotated Type, by constructing and returning a copy of the
Annotated Type without the prefix.
|
static @Nullable AnnotationMirror |
removePrefix(Elements elements,
AnnotationMirror unitsAnnotation)
Removes the prefix value from an Annotation, by constructing and returning a copy of its base
SI unit's Annotation.
|
public static @Nullable AnnotationMirror buildAnnoMirrorWithSpecificPrefix(ProcessingEnvironment env, @FullyQualifiedName CharSequence annoClass, Prefix p)
env
- the Checker Processing Environment, provided as a parameter in init() of a
UnitsRelations implementationannoClass
- the fully-qualified name of an Annotation representing a Unit (eg m.class for
meters)p
- a Prefix valuepublic static @Nullable AnnotationMirror buildAnnoMirrorWithNoPrefix(ProcessingEnvironment env, @FullyQualifiedName CharSequence annoClass)
env
- checker Processing Environment, provided as a parameter in init() of a
UnitsRelations implementationannoClass
- the getElementValueClassname of an Annotation representing a Unit (eg m.class
for meters)public static @Nullable Prefix getPrefix(AnnotatedTypeMirror annoType)
annoType
- an AnnotatedTypeMirror representing a Units Annotated Typepublic static @Nullable Prefix getPrefix(AnnotationMirror unitsAnnotation)
unitsAnnotation
- an AnnotationMirror representing a Units Annotationpublic static boolean hasNoPrefix(AnnotatedTypeMirror annoType)
annoType
- an AnnotatedTypeMirror representing a Units Annotated Typepublic static boolean hasNoPrefix(AnnotationMirror unitsAnnotation)
unitsAnnotation
- an AnnotationMirror representing a Units Annotationpublic static @Nullable AnnotationMirror removePrefix(Elements elements, AnnotationMirror unitsAnnotation)
elements
- the Element Utilities from a checker's processing environment, typically
obtained by calling env.getElementUtils() in init() of a Units Relations implementationunitsAnnotation
- an AnnotationMirror representing a Units Annotationpublic static AnnotatedTypeMirror removePrefix(Elements elements, AnnotatedTypeMirror annoType)
elements
- the Element Utilities from a checker's processing environment, typically
obtained by calling env.getElementUtils() in init() of a Units Relations implementationannoType
- an AnnotatedTypeMirror representing a Units Annotated Typepublic static boolean hasNoUnits(AnnotatedTypeMirror annoType)
Any number that isn't assigned a unit will automatically get the Annotation UnknownUnits. eg: int x = 5; // x has @UnknownUnits
annoType
- an AnnotatedTypeMirror representing a Units Annotated Typepublic static boolean hasSpecificUnit(AnnotatedTypeMirror annoType, AnnotationMirror unitsAnnotation)
annoType
- an AnnotatedTypeMirror representing a Units Annotated TypeunitsAnnotation
- an AnnotationMirror representing a Units Annotation of a specific unitpublic static boolean hasSpecificUnitIgnoringPrefix(AnnotatedTypeMirror annoType, AnnotationMirror unitsAnnotation)
annoType
- an AnnotatedTypeMirror representing a Units Annotated TypeunitsAnnotation
- an AnnotationMirror representing a Units Annotation of the base unitpublic static @Nullable AnnotationMirror buildAnnoMirrorWithSpecificPrefix(ProcessingEnvironment env, Class<? extends Annotation> annoClass, Prefix p)
This interface is intended only for subclasses of UnitsRelations; other clients should use
buildAnnoMirrorWithSpecificPrefix(ProcessingEnvironment, CharSequence, Prefix)
env
- the Checker Processing Environment, provided as a parameter in init() of a
UnitsRelations implementationannoClass
- the Class of an Annotation representing a Unit (eg m.class for meters)p
- a Prefix valuepublic static @Nullable AnnotationMirror buildAnnoMirrorWithDefaultPrefix(ProcessingEnvironment env, Class<? extends Annotation> annoClass)
Prefix.one
.
This interface is intended only for subclasses of UnitsRelations; other clients should not use it.
env
- the Checker Processing Environment, provided as a parameter in init() of a
UnitsRelations implementationannoClass
- the Class of an Annotation representing a Unit (eg m.class for meters)