Class Intrinsics


  • public final class Intrinsics
    extends java.lang.Object
    Intrinsic methods that are fully functional for the source templates (generic) and are replaced with low-level corresponding equivalents for the generated primitive types. Whenever there is a generic type on a static method it can be used to parameterize the given method based on the actual template type. Most intrinsics can guess their generic template parameter (for example if the template has only one replaceable type), but sometimes it may be necessary to provide the template type directly. This class should not appear in the final distribution (all methods are replaced in templates. Use forbidden-apis checker to make sure this is the case.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> T add​(T op1, T op2)
      An intrinsic that is replaced with plain addition of arguments for primitive template types.
      static <T> T cast​(java.lang.Object value)
      A template cast to the given type T.
      static <T> T empty()
      Returns the default "empty key" (null or 0 for primitive types).
      static <T> boolean equals​(Intrinsics.EqualityFunction delegate, java.lang.Object e1, java.lang.Object e2)
      Compare two keys for equivalence.
      static <T> boolean equals​(java.lang.Object e1, java.lang.Object e2)
      Compare two keys for equivalence.
      static <T> boolean isEmpty​(java.lang.Object value)
      Returns true if the provided value is an "empty key" marker.
      static <T> T[] newArray​(int arraySize)
      Creates an array for the given template type.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • isEmpty

        public static <T> boolean isEmpty​(java.lang.Object value)
        Returns true if the provided value is an "empty key" marker. For generic types the empty key is null, for any other type it is an equivalent of zero. Testing for zeros should be compiled into fast machine code.
      • empty

        public static <T> T empty()
        Returns the default "empty key" (null or 0 for primitive types).
      • cast

        public static <T> T cast​(java.lang.Object value)
        A template cast to the given type T. With type erasure it should work internally just fine and it simplifies code. The cast will be erased for primitive types.
      • newArray

        public static <T> T[] newArray​(int arraySize)
        Creates an array for the given template type.
      • equals

        public static <T> boolean equals​(Intrinsics.EqualityFunction delegate,
                                         java.lang.Object e1,
                                         java.lang.Object e2)
        Compare two keys for equivalence. Generic types are compared using the delegate function. Primitive types are compared using ==, except for floating-point types where they're compared by their actual representation bits as returned from Double.doubleToLongBits(double) and Float.floatToIntBits(float).
      • equals

        public static <T> boolean equals​(java.lang.Object e1,
                                         java.lang.Object e2)
        Compare two keys for equivalence. Generic types are compared for null-equivalence or using Object.equals(Object). Primitive types are compared using ==, except for floating-point types where they're compared by their actual representation bits as returned from Double.doubleToLongBits(double) and Float.floatToIntBits(float).
      • add

        public static <T> T add​(T op1,
                                T op2)
        An intrinsic that is replaced with plain addition of arguments for primitive template types. Invalid for non-number generic types.