org.eclipse.january.dataset

## Class InterfaceUtils

- java.lang.Object
- - org.eclipse.january.dataset.InterfaceUtils

-     public class InterfaceUtils
      extends Object

  Since:
    2.3

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `InterfaceUtils()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static Class<? extends Dataset>` | `findSubInterface(Class<? extends Dataset> clazz)` Find sub-interface of Dataset
    `static Object` | `fromDoublesToBiggestPrimitives(Class<? extends Dataset> clazz, double[] x)` Convert double array to primitive array
    `static Number` | `fromDoubleToBiggestNumber(Class<? extends Dataset> clazz, double x)` Convert double to number
    `static Number` | `fromDoubleToNumber(Class<? extends Dataset> clazz, double x)` Convert double to number
    `static Class<? extends Dataset>` | `getBestFloatInterface(Class<? extends Dataset> clazz)` Find floating point dataset interface that best fits given class.
    `static Class<? extends Dataset>` | `getBestInterface(Class<? extends Dataset> a, Class<? extends Dataset> b)` Find dataset interface that best fits given classes.
    `static Class<? extends CompoundDataset>` | `getCompoundInterface(Class<? extends Dataset> clazz)`
    `static Class<? extends Dataset>` | `getElementalInterface(Class<? extends Dataset> clazz)`
    `static Class<?>` | `getElementClass(Class<? extends Dataset> clazz)`
    `static int` | `getElementsPerItem(Class<? extends Dataset> clazz)`
    `static Class<? extends Dataset>` | `getInterface(Object obj)` Get dataset interface from an object.
    `static Class<? extends Dataset>` | `getInterfaceFromClass(int elementsPerItem, Class<?> elementClass)`
    `static int` | `getItemBytes(int isize, Class<? extends Dataset> clazz)`
    `static Class<? extends Dataset>` | `getLargestInterface(Dataset a)` The largest dataset type suitable for a summation of around a few thousand items without changing from the "kind" of dataset
    `static boolean` | `hasInterface(Class<? extends Dataset> clazz, Class<? extends Dataset>... dInterfaces)`
    `static boolean` | `hasInterface(Class<? extends Dataset> clazz, Class<? extends Dataset> dInterface)`
    `static boolean` | `isComplex(Class<? extends Dataset> clazz)`
    `static boolean` | `isCompound(Class<? extends Dataset> clazz)`
    `static boolean` | `isElemental(Class<? extends Dataset> clazz)`
    `static boolean` | `isElemental(ILazyDataset a)`
    `static boolean` | `isElementSupported(Class<? extends Object> clazz)`
    `static boolean` | `isFloating(Class<? extends Dataset> clazz)`
    `static boolean` | `isFloating(ILazyDataset a)`
    `static boolean` | `isInstance(Object object, Class<? extends Dataset> dInterface)`
    `static boolean` | `isInteger(Class<? extends Dataset> clazz)`
    `static boolean` | `isInteger(ILazyDataset a)`
    `static boolean` | `isNumerical(Class<? extends Dataset> clazz)`
    `static Number` | `toBiggestNumber(Class<? extends Dataset> clazz, Number x)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### InterfaceUtils

          public InterfaceUtils()

  - ### Method Detail

    - #### isInstance

          public static boolean isInstance(Object object,
                                           Class<? extends Dataset> dInterface)

      Parameters:
        `object` - input
        `dInterface` - dataset interface
      Returns:
        true if object is an instance of dataset interface

    - #### hasInterface

          public static boolean hasInterface(Class<? extends Dataset> clazz,
                                             Class<? extends Dataset> dInterface)

      Parameters:
        `clazz` - dataset class
        `dInterface` - dataset interface
      Returns:
        true if given class implements interface

    - #### hasInterface

          public static boolean hasInterface(Class<? extends Dataset> clazz,
                                             Class<? extends Dataset>... dInterfaces)

      Parameters:
        `clazz` - dataset class
        `dInterfaces` - dataset interface
      Returns:
        true if given class implements any of the interfaces

    - #### isElementSupported

          public static boolean isElementSupported(Class<? extends Object> clazz)

      Parameters:
        `clazz` - element class
      Returns:
        true if supported as an element class (note, Object is not supported)

    - #### getElementClass

          public static Class<?> getElementClass(Class<? extends Dataset> clazz)

      Parameters:
        `clazz` - dataset class
      Returns:
        (boxed) class of constituent element

    - #### getInterface

          public static Class<? extends Dataset> getInterface(Object obj)

      Get dataset interface from an object. The following are supported: Java Number objects, Apache common math Complex objects, Java arrays and lists, Dataset objects and ILazyDataset object
      Parameters:
        `obj` - input
      Returns:
        dataset interface

    - #### findSubInterface

          public static Class<? extends Dataset> findSubInterface(Class<? extends Dataset> clazz)

      Find sub-interface of Dataset
      Parameters:
        `clazz` - dataset class
      Returns:
        sub-interface or null if given class is Dataset.class
      Since:
        2.3

    - #### getInterfaceFromClass

          public static Class<? extends Dataset> getInterfaceFromClass(int elementsPerItem,
                                                                       Class<?> elementClass)

      Parameters:
        `elementsPerItem` - item size
        `elementClass` - element class
      Returns:
        dataset interface

    - #### getElementalInterface

          public static Class<? extends Dataset> getElementalInterface(Class<? extends Dataset> clazz)

      Parameters:
        `clazz` - dataset interface
      Returns:
        elemental dataset interface available for given dataset interface

    - #### getCompoundInterface

          public static Class<? extends CompoundDataset> getCompoundInterface(Class<? extends Dataset> clazz)

      Parameters:
        `clazz` - dataset interface
      Returns:
        compound dataset interface available for given dataset interface

    - #### isElemental

          public static boolean isElemental(ILazyDataset a)

      Parameters:
        `a` - dataset
      Returns:
        true if dataset is not compound or complex

    - #### isElemental

          public static boolean isElemental(Class<? extends Dataset> clazz)

      Parameters:
        `clazz` - dataset class
      Returns:
        true if dataset interface is not compound or complex

    - #### isCompound

          public static boolean isCompound(Class<? extends Dataset> clazz)

      Parameters:
        `clazz` - dataset class
      Returns:
        true if dataset interface is compound (not complex)

    - #### isInteger

          public static boolean isInteger(ILazyDataset a)

      Parameters:
        `a` - dataset
      Returns:
        true if dataset has integer elements

    - #### isFloating

          public static boolean isFloating(ILazyDataset a)

      Parameters:
        `a` - dataset
      Returns:
        true if dataset has floating point elements

    - #### isInteger

          public static boolean isInteger(Class<? extends Dataset> clazz)

      Parameters:
        `clazz` - dataset class
      Returns:
        true if dataset interface has integer elements

    - #### isFloating

          public static boolean isFloating(Class<? extends Dataset> clazz)

      Parameters:
        `clazz` - dataset class
      Returns:
        true if dataset interface has floating point elements

    - #### isComplex

          public static boolean isComplex(Class<? extends Dataset> clazz)

      Parameters:
        `clazz` - dataset class
      Returns:
        true if dataset interface has complex items

    - #### isNumerical

          public static boolean isNumerical(Class<? extends Dataset> clazz)

      Parameters:
        `clazz` - dataset class
      Returns:
        true if dataset interface has numerical elements

    - #### getElementsPerItem

          public static int getElementsPerItem(Class<? extends Dataset> clazz)

      Parameters:
        `clazz` - dataset class
      Returns:
        number of elements per item

    - #### getBestInterface

          public static Class<? extends Dataset> getBestInterface(Class<? extends Dataset> a,
                                                                  Class<? extends Dataset> b)

      Find dataset interface that best fits given classes. The best class takes into account complex and array datasets
      Parameters:
        `a` - first dataset class
        `b` - second dataset class
      Returns:
        best dataset interface

    - #### getLargestInterface

          public static Class<? extends Dataset> getLargestInterface(Dataset a)

      The largest dataset type suitable for a summation of around a few thousand items without changing from the "kind" of dataset
      Parameters:
        `a` - dataset
      Returns:
        largest dataset type available for given dataset type

    - #### getBestFloatInterface

          public static Class<? extends Dataset> getBestFloatInterface(Class<? extends Dataset> clazz)

      Find floating point dataset interface that best fits given class. The best interface takes into account complex and array datasets
      Parameters:
        `clazz` - dataset class
      Returns:
        best dataset interface

    - #### getItemBytes

          public static int getItemBytes(int isize,
                                         Class<? extends Dataset> clazz)

      Parameters:
        `isize` - number of elements in an item
        `clazz` - dataset interface
      Returns:
        length of single item in bytes

    - #### fromDoublesToBiggestPrimitives

          public static Object fromDoublesToBiggestPrimitives(Class<? extends Dataset> clazz,
                                                              double[] x)

      Convert double array to primitive array
      Parameters:
        `clazz` - dataset interface
        `x` - values
      Returns:
        biggest native primitive array if integer. Return null if not interface is not numerical

    - #### fromDoubleToNumber

          public static Number fromDoubleToNumber(Class<? extends Dataset> clazz,
                                                  double x)

      Convert double to number
      Parameters:
        `clazz` - dataset interface
        `x` - value
      Returns:
        number if integer. Return null if not interface is not numerical
      Since:
        2.3

    - #### fromDoubleToBiggestNumber

          public static Number fromDoubleToBiggestNumber(Class<? extends Dataset> clazz,
                                                         double x)

      Convert double to number
      Parameters:
        `clazz` - dataset interface
        `x` - value
      Returns:
        biggest number if integer. Return null if not interface is not numerical

    - #### toBiggestNumber

          public static Number toBiggestNumber(Class<? extends Dataset> clazz,
                                               Number x)

      Parameters:
        `clazz` - dataset interface
        `x` - value
      Returns:
        biggest native primitive if integer
      Since:
        2.3

Copyright © 2014–2022 Eclipse Foundation. All rights reserved.