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.Class<? extends java.lang.annotation.Annotation> 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.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(@Nullable javax.lang.model.element.AnnotationMirror unitsAnnotation)
Retrieves the SI Prefix of an Annotation
|
static boolean |
hasNoPrefix(@Nullable AnnotatedTypeMirror annoType)
Checks to see if an Annotated Type has no prefix
|
static boolean |
hasNoPrefix(@Nullable javax.lang.model.element.AnnotationMirror unitsAnnotation)
Checks to see if an Annotation has no prefix
|
static boolean |
hasNoUnits(@Nullable AnnotatedTypeMirror annoType)
Checks to see if a particular Annotated Type has no units, such as scalar constants in
calculations.
|
static boolean |
hasSpecificUnit(@Nullable AnnotatedTypeMirror annoType,
@Nullable 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(@Nullable AnnotatedTypeMirror annoType,
@Nullable 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(@Nullable javax.lang.model.util.Elements elements,
@Nullable 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(@Nullable javax.lang.model.util.Elements elements,
@Nullable 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 buildAnnoMirrorWithDefaultPrefix(javax.annotation.processing.ProcessingEnvironment env, java.lang.Class<? extends java.lang.annotation.Annotation> annoClass)
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)public static @Nullable javax.lang.model.element.AnnotationMirror buildAnnoMirrorWithSpecificPrefix(javax.annotation.processing.ProcessingEnvironment env, java.lang.Class<? extends java.lang.annotation.Annotation> annoClass, Prefix p)
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 buildAnnoMirrorWithNoPrefix(javax.annotation.processing.ProcessingEnvironment env, java.lang.Class<? extends java.lang.annotation.Annotation> annoClass)
env
- 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)public static @Nullable Prefix getPrefix(AnnotatedTypeMirror annoType)
annoType
- an AnnotatedTypeMirror representing a Units Annotated Typepublic static @Nullable Prefix getPrefix(@Nullable javax.lang.model.element.AnnotationMirror unitsAnnotation)
unitsAnnotation
- an AnnotationMirror representing a Units Annotationpublic static boolean hasNoPrefix(@Nullable AnnotatedTypeMirror annoType)
annoType
- an AnnotatedTypeMirror representing a Units Annotated Typepublic static boolean hasNoPrefix(@Nullable javax.lang.model.element.AnnotationMirror unitsAnnotation)
unitsAnnotation
- an AnnotationMirror representing a Units Annotationpublic static @Nullable javax.lang.model.element.AnnotationMirror removePrefix(@Nullable javax.lang.model.util.Elements elements, @Nullable 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(@Nullable javax.lang.model.util.Elements elements, @Nullable 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(@Nullable 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(@Nullable AnnotatedTypeMirror annoType, @Nullable 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(@Nullable AnnotatedTypeMirror annoType, @Nullable javax.lang.model.element.AnnotationMirror unitsAnnotation)
annoType
- an AnnotatedTypeMirror representing a Units Annotated TypeunitsAnnotation
- an AnnotationMirror representing a Units Annotation of the base unit