Class BenchmarkAnonymousInstantiation

java.lang.Object
org.djunits.benchmark.BenchmarkAnonymousInstantiation

public final class BenchmarkAnonymousInstantiation extends Object
BenschmarkAnonymousInstantiation.java.

Copyright (c) 2019-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See DJUNITS License

Author:
Alexander Verbraeck
  • Method Summary

    Modifier and Type
    Method
    Description
    static <S extends org.djunits.value.vdouble.scalar.base.DoubleScalar<?, S>>
    S
    instantiateAnonymousCached(double value, org.djunits.unit.Unit<?> unit)
    Instantiate the DoubleScalar based on its unit.
    static <S extends org.djunits.value.vdouble.scalar.base.DoubleScalar<?, S>>
    S
    instantiateAnonymousCascade(double value, org.djunits.unit.Unit<?> unit)
    Instantiate the DoubleScalar based on its unit.
    static <S extends org.djunits.value.vdouble.scalar.base.DoubleScalar<?, S>>
    S
    instantiateAnonymousMethodHandle(double value, org.djunits.unit.Unit<?> unit)
    Instantiate the DoubleScalar based on its unit.
    static <S extends org.djunits.value.vdouble.scalar.base.DoubleScalar<?, S>>
    S
    instantiateAnonymousNonCached(double value, org.djunits.unit.Unit<?> unit)
    Instantiate the DoubleScalar based on its unit.
    static <U extends org.djunits.unit.Unit<U>, S extends org.djunits.value.vdouble.scalar.base.DoubleScalar<U, S>>
    S
    instantiateCached(double value, U unit)
    Instantiate the DoubleScalar based on its unit.
    static <U extends org.djunits.unit.Unit<U>, S extends org.djunits.value.vdouble.scalar.base.DoubleScalar<U, S>>
    S
    instantiateCascade(double value, U unit)
    Instantiate the DoubleScalar based on its unit.
    static <U extends org.djunits.unit.Unit<U>, S extends org.djunits.value.vdouble.scalar.base.DoubleScalar<U, S>>
    S
    instantiateMethodHandle(double value, U unit)
    Instantiate the DoubleScalar based on its unit.
    static <U extends org.djunits.unit.Unit<U>, S extends org.djunits.value.vdouble.scalar.base.DoubleScalar<U, S>>
    S
    instantiateNonCached(double value, U unit)
    Instantiate the DoubleScalar based on its unit.
    static void
    main(String[] args)
    Benchmark for anonymous scalar instantiation.

    Methods inherited from class java.lang.Object

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

    • instantiateCached

      public static <U extends org.djunits.unit.Unit<U>, S extends org.djunits.value.vdouble.scalar.base.DoubleScalar<U, S>> S instantiateCached(double value, U unit)
      Instantiate the DoubleScalar based on its unit. Rigid check on types for the compiler.
      Type Parameters:
      U - the unit
      S - the return type
      Parameters:
      value - double; the value
      unit - U; the unit in which the value is expressed
      Returns:
      an instantiated DoubleScalar with the value expressed in the unit
    • instantiateAnonymousCached

      public static <S extends org.djunits.value.vdouble.scalar.base.DoubleScalar<?, S>> S instantiateAnonymousCached(double value, org.djunits.unit.Unit<?> unit)
      Instantiate the DoubleScalar based on its unit. Loose check for types on the compiler. This allows the unit to be specified as a Unit<?> type.
      Note that it is possible to make mistakes with anonymous units.
      Type Parameters:
      S - the return type
      Parameters:
      value - double; the value
      unit - Unit<?>; the unit in which the value is expressed
      Returns:
      an instantiated DoubleScalar with the value expressed in the unit
    • instantiateCascade

      public static <U extends org.djunits.unit.Unit<U>, S extends org.djunits.value.vdouble.scalar.base.DoubleScalar<U, S>> S instantiateCascade(double value, U unit)
      Instantiate the DoubleScalar based on its unit. Rigid check on types for the compiler.
      Type Parameters:
      U - the unit
      S - the return type
      Parameters:
      value - double; the value
      unit - U; the unit in which the value is expressed
      Returns:
      an instantiated DoubleScalar with the value expressed in the unit
    • instantiateAnonymousCascade

      public static <S extends org.djunits.value.vdouble.scalar.base.DoubleScalar<?, S>> S instantiateAnonymousCascade(double value, org.djunits.unit.Unit<?> unit)
      Instantiate the DoubleScalar based on its unit. Loose check for types on the compiler. This allows the unit to be specified as a Unit<?> type.
      Note that it is possible to make mistakes with anonymous units.
      Type Parameters:
      S - the return type
      Parameters:
      value - double; the value
      unit - Unit<?>; the unit in which the value is expressed
      Returns:
      an instantiated DoubleScalar with the value expressed in the unit
    • instantiateNonCached

      public static <U extends org.djunits.unit.Unit<U>, S extends org.djunits.value.vdouble.scalar.base.DoubleScalar<U, S>> S instantiateNonCached(double value, U unit)
      Instantiate the DoubleScalar based on its unit. Rigid check on types for the compiler.
      Type Parameters:
      U - the unit
      S - the return type
      Parameters:
      value - double; the value
      unit - U; the unit in which the value is expressed
      Returns:
      an instantiated DoubleScalar with the value expressed in the unit
    • instantiateAnonymousNonCached

      public static <S extends org.djunits.value.vdouble.scalar.base.DoubleScalar<?, S>> S instantiateAnonymousNonCached(double value, org.djunits.unit.Unit<?> unit)
      Instantiate the DoubleScalar based on its unit. Loose check for types on the compiler. This allows the unit to be specified as a Unit<?> type.
      Note that it is possible to make mistakes with anonymous units.
      Type Parameters:
      S - the return type
      Parameters:
      value - double; the value
      unit - Unit<?>; the unit in which the value is expressed
      Returns:
      an instantiated DoubleScalar with the value expressed in the unit
    • instantiateMethodHandle

      public static <U extends org.djunits.unit.Unit<U>, S extends org.djunits.value.vdouble.scalar.base.DoubleScalar<U, S>> S instantiateMethodHandle(double value, U unit)
      Instantiate the DoubleScalar based on its unit. Rigid check on types for the compiler.
      Type Parameters:
      U - the unit
      S - the return type
      Parameters:
      value - double; the value
      unit - U; the unit in which the value is expressed
      Returns:
      an instantiated DoubleScalar with the value expressed in the unit
    • instantiateAnonymousMethodHandle

      public static <S extends org.djunits.value.vdouble.scalar.base.DoubleScalar<?, S>> S instantiateAnonymousMethodHandle(double value, org.djunits.unit.Unit<?> unit)
      Instantiate the DoubleScalar based on its unit. Loose check for types on the compiler. This allows the unit to be specified as a Unit<?> type.
      Note that it is possible to make mistakes with anonymous units.
      Type Parameters:
      S - the return type
      Parameters:
      value - double; the value
      unit - Unit<?>; the unit in which the value is expressed
      Returns:
      an instantiated DoubleScalar with the value expressed in the unit
    • main

      public static void main(String[] args) throws Throwable
      Benchmark for anonymous scalar instantiation.
      Parameters:
      args - empty
      Throws:
      Throwable - on error