Top Description Methods
org.checkerframework.checker.units.qual

public @Interface PolyUnit

extends Annotation
Annotations
@Documented
@Retention:RUNTIME
@Target:TYPE_USE, TYPE_PARAMETER
@PolymorphicQualifier:UnknownUnits
Imports
java.lang.annotation.Documented, .ElementType, .Retention, .RetentionPolicy, .Target, org.checkerframework.framework.qual.PolymorphicQualifier

A polymorphic qualifier for the units-of-measure type system implemented by the Units Checker.

Any method written using @PolyUnit conceptually has many versions: in each one, every instance of @PolyUnit has been replaced by a different unit qualifier such as @kg (kilograms) or @h (hours).

The following example shows how method triplePolyUnit can be used to process either meters or seconds:


@PolyUnit int triplePolyUnit(@PolyUnit int amount) {
   return 3*amount;
 }

 void testPolyUnit() {
  @m int m1 = 7 * UnitsTools.m;
  @m int m2 = triplePolyUnit(m1);

  @s int sec1 = 7 * UnitsTools.s;
  @s int sec2 = triplePolyUnit(sec1);

   // :: error: (assignment)
  @s int sec3 = triplePolyUnit(m1);
 }

Method Summary

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString