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,
Class<? extends Annotation> annoClass)
Creates an AnnotationMirror representing a unit defined by annoClass, with no prefix
|
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(@Nullable 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 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 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 AnnotationMirror unitsAnnotation)
Checks to see if a particular Annotated Type has a particular base unit (represented by its
Annotation)
|
static AnnotatedTypeMirror |
removePrefix(@Nullable 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 AnnotationMirror |
removePrefix(@Nullable Elements elements,
@Nullable 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 buildAnnoMirrorWithDefaultPrefix(ProcessingEnvironment env, Class<? extends 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 AnnotationMirror buildAnnoMirrorWithSpecificPrefix(ProcessingEnvironment env, Class<? extends 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 AnnotationMirror buildAnnoMirrorWithNoPrefix(ProcessingEnvironment env, Class<? extends 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 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 AnnotationMirror unitsAnnotation)
unitsAnnotation
- an AnnotationMirror representing a Units Annotationpublic static @Nullable AnnotationMirror removePrefix(@Nullable Elements elements, @Nullable AnnotationMirror unitsAnnotation)
elements
- 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 Elements elements, @Nullable AnnotatedTypeMirror annoType)
elements
- 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 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 AnnotationMirror unitsAnnotation)
annoType
- an AnnotatedTypeMirror representing a Units Annotated TypeunitsAnnotation
- an AnnotationMirror representing a Units Annotation of the base unit