Class OMultiValue

java.lang.Object
com.orientechnologies.common.collection.OMultiValue

public class OMultiValue extends Object
Handles Multi-value types such as Arrays, Collections and Maps. It recognizes special Orient collections.
Author:
Luca Garulli (l.garulli--(at)--orientdb.com)
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static Object
    add(Object iObject, Object iToAdd)
    Utility function that add a value to the main object.
    static Object[]
    array(Object iValue)
     
    static <T> T[]
    array(Object iValue, Class<? extends T> iClass)
     
    static <T> T[]
    array(Object iValue, Class<? extends T> iClass, OCallable<Object,Object> iCallback)
     
    static boolean
    contains(Object iObject, Object iItem)
     
    static Object
    convert(Object iObject, OCallable<Object,Object> iCallback)
     
    static boolean
     
    static Object
    Returns the first item of the Multi-value object (array, collection or map)
    static Object
    Returns the last item of the Multi-value object (array, collection or map)
    Returns an Iterable object to browse the multi-value instance (array, collection or map).
    getMultiValueIterable(Object iObject, boolean iForceConvertRecord)
    Returns an Iterable object to browse the multi-value instance (array, collection or map).
    Returns an Iterator object to browse the multi-value instance (array, collection or map)
    getMultiValueIterator(Object iObject, boolean iForceConvertRecord)
    Returns an Iterator object to browse the multi-value instance (array, collection or map)
    static <T> List<T>
     
    static int
    getSize(Object iObject)
    Returns the size of the multi-value object
    static Object
    getValue(Object iObject, int iIndex)
    Returns the iIndex item of the Multi-value object (array, collection or map)
    static boolean
    isIterable(Object iObject)
     
    static boolean
    isMultiValue(Class<?> iType)
    Checks if a class is a multi-value type.
    static boolean
    Checks if the object is a multi-value type.
    static Object
    remove(Object iObject, Object iToRemove, boolean iAllOccurrences)
    Utility function that remove a value from the main object.
    protected static void
    removeFromOCollection(Object iObject, OCollection<Object> coll, Object iToRemove, boolean iAllOccurrences)
     
    static void
    setValue(Object iObject, Object iValue, int iIndex)
    Sets the value of the Multi-value object (array or collection) at iIndex
    static Object
     
    static String
    toString(Object iObject)
    Returns a stringified version of the multi-value object.

    Methods inherited from class java.lang.Object

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

      • OMultiValue

        public OMultiValue()
    • Method Details

      • isMultiValue

        public static boolean isMultiValue(Class<?> iType)
        Checks if a class is a multi-value type.
        Parameters:
        iType - Class to check
        Returns:
        true if it's an array, a collection or a map, otherwise false
      • isMultiValue

        public static boolean isMultiValue(Object iObject)
        Checks if the object is a multi-value type.
        Parameters:
        iObject - Object to check
        Returns:
        true if it's an array, a collection or a map, otherwise false
      • isIterable

        public static boolean isIterable(Object iObject)
      • getSize

        public static int getSize(Object iObject)
        Returns the size of the multi-value object
        Parameters:
        iObject - Multi-value object (array, collection or map)
        Returns:
        the size of the multi value object
      • getFirstValue

        public static Object getFirstValue(Object iObject)
        Returns the first item of the Multi-value object (array, collection or map)
        Parameters:
        iObject - Multi-value object (array, collection or map)
        Returns:
        The first item if any
      • getLastValue

        public static Object getLastValue(Object iObject)
        Returns the last item of the Multi-value object (array, collection or map)
        Parameters:
        iObject - Multi-value object (array, collection or map)
        Returns:
        The last item if any
      • getValue

        public static Object getValue(Object iObject, int iIndex)
        Returns the iIndex item of the Multi-value object (array, collection or map)
        Parameters:
        iObject - Multi-value object (array, collection or map)
        iIndex - integer as the position requested
        Returns:
        The first item if any
      • setValue

        public static void setValue(Object iObject, Object iValue, int iIndex)
        Sets the value of the Multi-value object (array or collection) at iIndex
        Parameters:
        iObject - Multi-value object (array, collection)
        iValue - The value to set at this specified index.
        iIndex - integer as the position requested
      • getMultiValueIterable

        public static Iterable<Object> getMultiValueIterable(Object iObject)
        Returns an Iterable object to browse the multi-value instance (array, collection or map).
        Parameters:
        iObject - Multi-value object (array, collection or map)
      • getMultiValueIterable

        public static Iterable<Object> getMultiValueIterable(Object iObject, boolean iForceConvertRecord)
        Returns an Iterable object to browse the multi-value instance (array, collection or map).
        Parameters:
        iObject - Multi-value object (array, collection or map)
        iForceConvertRecord - allow to force settings to convert RIDs to records while browsing.
      • getMultiValueIterator

        public static Iterator<Object> getMultiValueIterator(Object iObject, boolean iForceConvertRecord)
        Returns an Iterator object to browse the multi-value instance (array, collection or map)
        Parameters:
        iObject - Multi-value object (array, collection or map)
        iForceConvertRecord - allow to force settings to convert RIDs to records while browsing.
      • getMultiValueIterator

        public static Iterator<Object> getMultiValueIterator(Object iObject)
        Returns an Iterator object to browse the multi-value instance (array, collection or map)
        Parameters:
        iObject - Multi-value object (array, collection or map)
      • toString

        public static String toString(Object iObject)
        Returns a stringified version of the multi-value object.
        Parameters:
        iObject - Multi-value object (array, collection or map)
        Returns:
        a stringified version of the multi-value object.
      • add

        public static Object add(Object iObject, Object iToAdd)
        Utility function that add a value to the main object. It takes care about collections/array and single values.
        Parameters:
        iObject - MultiValue where to add value(s)
        iToAdd - Single value, array of values or collections of values. Map are not supported.
        Returns:
      • remove

        public static Object remove(Object iObject, Object iToRemove, boolean iAllOccurrences)
        Utility function that remove a value from the main object. It takes care about collections/array and single values.
        Parameters:
        iObject - MultiValue where to add value(s)
        iToRemove - Single value, array of values or collections of values. Map are not supported.
        iAllOccurrences - True if the all occurrences must be removed or false of only the first one (Like java.util.Collection.remove())
        Returns:
      • removeFromOCollection

        protected static void removeFromOCollection(Object iObject, OCollection<Object> coll, Object iToRemove, boolean iAllOccurrences)
      • array

        public static Object[] array(Object iValue)
      • array

        public static <T> T[] array(Object iValue, Class<? extends T> iClass)
      • array

        public static <T> T[] array(Object iValue, Class<? extends T> iClass, OCallable<Object,Object> iCallback)
      • convert

        public static Object convert(Object iObject, OCallable<Object,Object> iCallback)
      • equals

        public static boolean equals(Collection<Object> col1, Collection<Object> col2)
      • contains

        public static boolean contains(Object iObject, Object iItem)
      • toSet

        public static Object toSet(Object o)
      • getSingletonList

        public static <T> List<T> getSingletonList(T item)