public class UnitsRelationsTools
extends java.lang.Object
Constructor and Description |
---|
UnitsRelationsTools() |
Modifier and Type | Method and Description |
---|---|
static @Nullable javax.lang.model.element.AnnotationMirror |
buildAnnoMirrorWithDefaultPrefix(javax.annotation.processing.ProcessingEnvironment env,
java.lang.Class<? extends java.lang.annotation.Annotation> annoClass)
Creates an AnnotationMirror representing a unit defined by annoClass, with the default Prefix
of
Prefix.one . |
static @Nullable javax.lang.model.element.AnnotationMirror |
buildAnnoMirrorWithNoPrefix(javax.annotation.processing.ProcessingEnvironment env,
java.lang.CharSequence annoClass)
Creates an AnnotationMirror representing a unit defined by annoClass, with no prefix.
|
static @Nullable javax.lang.model.element.AnnotationMirror |
buildAnnoMirrorWithSpecificPrefix(javax.annotation.processing.ProcessingEnvironment env,
java.lang.CharSequence annoClass,
Prefix p)
Creates an AnnotationMirror representing a unit defined by annoClass, with the specific
Prefix p.
|
static @Nullable javax.lang.model.element.AnnotationMirror |
buildAnnoMirrorWithSpecificPrefix(javax.annotation.processing.ProcessingEnvironment env,
java.lang.Class<? extends java.lang.annotation.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(javax.lang.model.element.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(javax.lang.model.element.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,
javax.lang.model.element.AnnotationMirror unitsAnnotation)
Checks to see if a particular Annotated Type has a specific unit (represented by its
Annotation).
|
static boolean |
hasSpecificUnitIgnoringPrefix(AnnotatedTypeMirror annoType,
javax.lang.model.element.AnnotationMirror unitsAnnotation)
Checks to see if a particular Annotated Type has a particular base unit (represented by its
Annotation).
|
static AnnotatedTypeMirror |
removePrefix(javax.lang.model.util.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 javax.lang.model.element.AnnotationMirror |
removePrefix(javax.lang.model.util.Elements elements,
javax.lang.model.element.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 javax.lang.model.element.AnnotationMirror buildAnnoMirrorWithSpecificPrefix(javax.annotation.processing.ProcessingEnvironment env, java.lang.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 javax.lang.model.element.AnnotationMirror buildAnnoMirrorWithNoPrefix(javax.annotation.processing.ProcessingEnvironment env, java.lang.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(javax.lang.model.element.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(javax.lang.model.element.AnnotationMirror unitsAnnotation)
unitsAnnotation
- an AnnotationMirror representing a Units Annotationpublic static @Nullable javax.lang.model.element.AnnotationMirror removePrefix(javax.lang.model.util.Elements elements, javax.lang.model.element.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(javax.lang.model.util.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, javax.lang.model.element.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, javax.lang.model.element.AnnotationMirror unitsAnnotation)
annoType
- an AnnotatedTypeMirror representing a Units Annotated TypeunitsAnnotation
- an AnnotationMirror representing a Units Annotation of the base unitpublic static @Nullable javax.lang.model.element.AnnotationMirror buildAnnoMirrorWithSpecificPrefix(javax.annotation.processing.ProcessingEnvironment env, java.lang.Class<? extends java.lang.annotation.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 javax.lang.model.element.AnnotationMirror buildAnnoMirrorWithDefaultPrefix(javax.annotation.processing.ProcessingEnvironment env, java.lang.Class<? extends java.lang.annotation.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)