Class DataObjectUtils


  • public class DataObjectUtils
    extends java.lang.Object
    Utilities for handling and manipulating single or multiple objects of any subclass of DataObject.
    Version:
    $Id: $Id
    Author:
    denis
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T extends DataObject>
      java.util.Map<java.lang.String,​T>
      createMapById​(java.util.List<T> dataObjects)
      Creates Map of dataObjects by their IDs.
      static <T extends DataObject,​P>
      java.util.Map<P,​T>
      createMapByKeyProperty​(java.lang.String propertyName, java.lang.Class<P> propertyClass, java.util.List<T> dataObjects)
      Creates Map of dataObjects by specified property.
      static <T extends DataObject,​P>
      java.util.Map<P,​T[]>
      createMapByProperty​(java.lang.String propertyName, java.lang.Class<P> propertyClass, java.util.List<T> dataObjects)
      Creates Map of groups (arrays) of dataObjects by specified property.
      static <T extends DataObject>
      java.util.List<java.lang.String>
      getIds​(java.util.List<T> dataObjects)
      Creates for the List of dataObjects same ordered List of dataObjects' IDs except the case when null id was happened.
      static <T extends DataObject,​P>
      java.util.List<P>
      getProperties​(java.lang.String propertyName, java.lang.Class<P> propertyClass, java.util.List<T> dataObjects)
      Returns for the dataObjects the List that is filled with specified property values of each dataObject.
      • Methods inherited from class java.lang.Object

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

      • getIds

        public static <T extends DataObject> java.util.List<java.lang.String> getIds​(java.util.List<T> dataObjects)
        Creates for the List of dataObjects same ordered List of dataObjects' IDs except the case when null id was happened.
        Parameters:
        dataObjects - - objects for which IDs List is created
        Returns:
        List of ID's
      • getProperties

        public static <T extends DataObject,​P> java.util.List<P> getProperties​(java.lang.String propertyName,
                                                                                     java.lang.Class<P> propertyClass,
                                                                                     java.util.List<T> dataObjects)
        Returns for the dataObjects the List that is filled with specified property values of each dataObject.
        Parameters:
        propertyName - - name of the property to get from dataObjects
        propertyClass - - class of the property
        dataObjects - - dataObjects to get property values.
        Returns:
        List that is filled with specified property values
      • createMapById

        public static <T extends DataObject> java.util.Map<java.lang.String,​T> createMapById​(java.util.List<T> dataObjects)
        Creates Map of dataObjects by their IDs.
        Parameters:
        dataObjects - - dataObjects to create map.
        Returns:
        Map of pairs ID - dataObject
      • createMapByKeyProperty

        public static <T extends DataObject,​P> java.util.Map<P,​T> createMapByKeyProperty​(java.lang.String propertyName,
                                                                                                     java.lang.Class<P> propertyClass,
                                                                                                     java.util.List<T> dataObjects)
        Creates Map of dataObjects by specified property. Property value must be unique (key property) for each dataObject. In other case only one dataObject with not unique property will be added to the map.
        Parameters:
        propertyName - - name of the property by which Map is created
        propertyClass - - class of the property
        dataObjects - - dataObjects to create map.
        Returns:
        Map of pairs Property Value - dataObject
      • createMapByProperty

        public static <T extends DataObject,​P> java.util.Map<P,​T[]> createMapByProperty​(java.lang.String propertyName,
                                                                                                    java.lang.Class<P> propertyClass,
                                                                                                    java.util.List<T> dataObjects)
        Creates Map of groups (arrays) of dataObjects by specified property. DataObjects with equal property values are put to the same group.
        Parameters:
        propertyName - - name of the property by which Map is created
        propertyClass - - class of the property
        dataObjects - - dataObjects to create map.
        Returns:
        Map of pairs Property Value - dataObjects group