All Downloads are FREE. Search and download functionalities are using the official Maven repository.

checker.src.org.checkerframework.checker.units.qual.PolyUnit Maven / Gradle / Ivy

Go to download

The Checker Framework enhances Java’s type system to make it more powerful and useful. This lets software developers detect and prevent errors in their Java programs. The Checker Framework includes compiler plug-ins ("checkers") that find bugs or verify their absence. It also permits you to write your own compiler plug-ins.

There is a newer version: 3.42.0
Show newest version
package org.checkerframework.checker.units.qual;

import java.lang.annotation.*;

import org.checkerframework.framework.qual.*;

/**
 * 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: * *

 {@literal @}PolyUnit int triplePolyUnit(@PolyUnit int amount) {
 *    return 3*amount;
 *  }
 *
 *  void testPolyUnit() {
 *   {@literal @}m int m1 = 7 * UnitsTools.m;
 *   {@literal @}m int m2 = triplePolyUnit(m1);
 *
 *   {@literal @}s int sec1 = 7 * UnitsTools.s;
 *   {@literal @}s int sec2 = triplePolyUnit(sec1);
 *
 *    //:: error: (assignment.type.incompatible)
 *   {@literal @}s int sec3 = triplePolyUnit(m1);
 *  }
 * 
* * @checker_framework.manual #units-checker Units Checker */ @Documented @PolymorphicQualifier(UnknownUnits.class) @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) public @interface PolyUnit { }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy