Class ClassUtils

java.lang.Object
me.gilbva.shrike.container.ClassUtils

public class ClassUtils
extends java.lang.Object
Utility method for class and type handling.
Author:
Gilberto Vento
  • Constructor Summary

    Constructors 
    Constructor Description
    ClassUtils()  
  • Method Summary

    Modifier and Type Method Description
    static java.util.Map createMap​(java.lang.Class mapCls, java.lang.Object[] data)
    Given a map type this method will return the appropied instance for it.
    static java.lang.reflect.Type parameterType​(java.lang.reflect.Type service, int index)
    Returns the specified parameter from the ParameterizedType.
    static java.util.Collection<java.lang.Class<?>> toClasses​(java.util.Collection instances)
    Gets a collection with all the classes of the objects from the especified collection.

    Methods inherited from class java.lang.Object

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

  • Method Details

    • parameterType

      public static java.lang.reflect.Type parameterType​(java.lang.reflect.Type service, int index)
      Returns the specified parameter from the ParameterizedType.
      Parameters:
      service - The ParameterizedType type to search the parameter.
      index - The index of the actual parameter.
      Returns:
      If service is a ParameterizedType and the parameter is available it will return it, or null otherwise.
    • toClasses

      public static java.util.Collection<java.lang.Class<?>> toClasses​(java.util.Collection instances)
      Gets a collection with all the classes of the objects from the especified collection.
      Parameters:
      instances - The objects to obtain it´s classes from.
      Returns:
      A Collection object with all the classes of the object´s in the collection passed.
    • createMap

      public static java.util.Map createMap​(java.lang.Class mapCls, java.lang.Object[] data) throws java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.IllegalArgumentException, java.lang.reflect.InvocationTargetException
      Given a map type this method will return the appropied instance for it.
       SomeService                       = null
       SomeService[]                     = null
       List<SomeService>           = null
       List<SomeService>[]         = null
       Map<Class, SomeService>     = Map
       MyListImpl<SomeService>     = null
       HashMap<Class, SomeService> = HashMapl
       
      Parameters:
      mapCls - The clss for the map.
      data - The data for the map.
      Returns:
      The map.
      Throws:
      java.lang.InstantiationException - if the collection cannot be instance.
      java.lang.IllegalAccessException - security exception.
      java.lang.reflect.InvocationTargetException - construct error.
      java.lang.IllegalArgumentException