Tabnine Logo
ConstructorUtils
Code IndexAdd Tabnine to your IDE (free)

How to use
ConstructorUtils
in
org.azeckoski.reflectutils

Best Java code snippets using org.azeckoski.reflectutils.ConstructorUtils (Showing top 20 results out of 315)

origin: org.azeckoski/reflectutils

  implementationType = Vector.class;
} else if (implementationType.isInterface()) {
  implementationType = ConstructorUtils.getClassFromInterface(implementationType);
convert = getConstructorUtils().constructClass(implementationType);
if ( ConstructorUtils.isClassArray(fromType) ) {
    convert.add( aVal );
} else if ( ConstructorUtils.isClassCollection(fromType) ) {
} else if ( ConstructorUtils.isClassMap(fromType) ) {
origin: azeckoski/reflectutils

/**
 * @param type any class
 * @return true if this class is a bean of some kind (i.e. not primitive, immutable, or a holder like a map)
 */
public static boolean isClassBean(Class<?> type) {
  checkNull(type);
  boolean bean = true;
  if ( isClassSimple(type) || isClassObjectHolder(type) ) {
    bean = false;
  }
  return bean;
}
origin: org.azeckoski/reflectutils

/**
 * Set the singleton instance of the class which will be stored statically
 * @param instance the instance to use as the singleton instance
 */
public static ConstructorUtils setInstance(ConstructorUtils newInstance) {
  ConstructorUtils instance = newInstance;
  if (instance == null) {
    instance = new ConstructorUtils();
    instance.singleton = true;
  }
  ConstructorUtils.timesCreated++;
  instanceStorage = new SoftReference<ConstructorUtils>(instance);
  return instance;
}
origin: org.azeckoski/reflectutils

/**
 * @param type any class
 * @return true if this is a collection, map, or array, 
 * something that holds a bunch of objects (e.g. {@link Map}, {@link Set}, {@link List}, array)
 */
public static boolean isClassObjectHolder(Class<?> type) {
  checkNull(type);
  boolean holder = false;
  if ( isClassArray(type) || isClassCollection(type) || isClassMap(type) ) {
    holder = true;
  }
  return holder;
}
origin: org.azeckoski/reflectutils

/**
 * @param type any class
 * @return true if this class is a primitive or other simple class (like String or immutable)
 */
public static boolean isClassSimple(Class<?> type) {
  checkNull(type);
  boolean simple = false;
  if ( isClassPrimitive(type) 
      || getImmutableTypes().contains(type)) {
    simple = true;
  }
  return simple;
}
origin: org.azeckoski/reflectutils

  implementationType = ArrayOrderedMap.class;
convert = (Map<String, Object>) getConstructorUtils().constructClass(implementationType);
if ( ConstructorUtils.isClassArray(fromType) ) {
    convert.put(i+"", aVal);
} else if ( ConstructorUtils.isClassCollection(fromType) ) {
    i++;
} else if ( ConstructorUtils.isClassMap(fromType) ) {
  if (ConstructorUtils.isClassSimple(fromType)) {
    convert.put("data", toConvert);
  } else {
origin: org.azeckoski/reflectutils

Class<?> type = ConstructorUtils.getWrapper(object.getClass());
if ( ConstructorUtils.isClassSimple(type) ) {
    sb.append(QUOT);
} else if ( ConstructorUtils.isClassArray(type) ) {
} else if ( ConstructorUtils.isClassCollection(type) ) {
origin: org.azeckoski/reflectutils

type = ConstructorUtils.getClassFromInterface(type);
T newC = null;
if ( isClassPrimitive(type) ) {
  if (getPrimitiveDefaults().containsKey(type)) {
    newC = (T) getPrimitiveDefaults().get(type);
} else if ( isClassArray(type) ) {
  Class<?> componentType = getTypeFromArray(type);
  try {
    newC = (T) Array.newInstance(componentType, 0);
    if ( ConstructorUtils.isClassBean(type) ) {
      constructors = getClassDataCacher().getClassData(type).getConstructors();
    } else {
origin: org.azeckoski/reflectutils

Class<?> beanClass = bean.getClass();
if (ConstructorUtils.isClassSimple(beanClass) 
    || ConstructorUtils.isClassSpecial(beanClass)) {
        if ( ConstructorUtils.isClassBean(componentType) 
            && CopyDestination.MAP.equals(dest)) {
        copy = getConstructorUtils().constructClass(beanClass); // make new list
        for (Object element : (Collection) bean) {
          Object clone = internalDeepClone(element, dest, maxDepth, null, currentDepth, ignoreNulls, ignoreTransient);
        copy = getConstructorUtils().constructClass(beanClass); // make new map
        for (Object key : ((Map) bean).keySet()) {
          if ( fieldNamesToSkip != null
          copy = getConstructorUtils().constructClass(beanClass); // make new bean
origin: org.azeckoski/reflectutils

Class<T> toType = type;
type = (Class<T>) ConstructorUtils.getTypeFromInnerCollection(type);
  } else if (SortedMap.class.isAssignableFrom(type)) {
    toType = (Class<T>) TreeMap.class;
  } else if ( isClassList(type) ) {
  } else if ( isClassMap(type) ) {
    toType = (Class<T>) ArrayOrderedMap.class;
  } else if ( isClassCollection(type) ) {
    toType = (Class<T>) Vector.class;
origin: org.azeckoski/reflectutils

if ( ConstructorUtils.isClassArray(fromType) ) {
} else if ( ConstructorUtils.isClassCollection(fromType) ) {
    i++;
} else if ( ConstructorUtils.isClassMap(fromType) ) {
origin: org.azeckoski/reflectutils

/**
 * A simple but efficient method for getting the interfaces for a class type,
 * this has some shortcuts for the common types like maps, lists, etc.<br/>
 * Only returns the interfaces for the current type and not for all nested types
 * 
 * @param type any class type
 * @return the list of interfaces (empty if none)
 */
public static List<Class<?>> getInterfacesForClass(Class<?> type) {
  ArrayList<Class<?>> interfaces = new ArrayList<Class<?>>();
  // find the actual interfaces from the class itself
  for (Class<?> iface : type.getInterfaces()) {
    interfaces.add(iface);
  }
  // add in the collection interface if this is a collection
  if ( isClassCollection(type) ) {
    if ( isClassList(type) ) {
      interfaces.add(List.class);
    } else if ( Set.class.isAssignableFrom(type)) {
      interfaces.add(Set.class);
    }
    interfaces.add(Collection.class);
  } else if ( isClassMap(type) ) {
    interfaces.add(Map.class);
  }
  return interfaces;
}
origin: org.azeckoski/reflectutils

if ( ConstructorUtils.isClassMap(type)) {
  Map<String, Object> m = (Map)container.getContainer();
  if (m.containsKey(key)) {
    m.put(key, value);
} else if ( ConstructorUtils.isClassCollection(type)) {
  Collection collection = ((Collection)container.getContainer());
  collection.add(value);
origin: org.azeckoski/reflectutils

if (ConstructorUtils.getImmutableTypes().contains(destClass)) {
} else if (ConstructorUtils.isClassSpecial(origClass)) {
if (autoConvert && ! ConstructorUtils.isClassBean(origClass) ) {
origin: org.azeckoski/reflectutils

  throw new IllegalArgumentException("Invalid indexedObject, cannot be null");
if ( ConstructorUtils.isClassArray(indexedObject.getClass()) ) {
    throw new IllegalArgumentException("Failed to set index ("+index+") for array of size ("+Array.getLength(indexedObject)+") to value: " + value, e);
} else if ( ConstructorUtils.isClassList(indexedObject.getClass()) ) {
origin: azeckoski/reflectutils

if (fieldAdapterManager.isAdaptableObject(obj)) {
  fieldType = fieldAdapterManager.getFieldAdapter().getFieldType(obj, targetName);
} else if ( ConstructorUtils.isClassObjectHolder(obj.getClass()) 
    || Object.class.equals(obj.getClass()) ) {
  if ( ConstructorUtils.isClassArray(fieldType) ) {
origin: org.azeckoski/reflectutils

/**
 * Get the wrapper class for this class if there is one
 * @param beanClass any class
 * @return the wrapper class if there is one OR just returns the given class
 */
public static Class<?> getWrapper(final Class<?> beanClass) {
  Class<?> wrapper = null;
  if (beanClass != null) {
    if ( isClassPrimitive(beanClass) ) {
      wrapper = getPrimitiveToWrapper().get(beanClass);
    } else if ( isClassArray(beanClass) && beanClass.getComponentType().isPrimitive()) {
      wrapper = getPrimitiveToWrapper().get(beanClass);
    } else {
      wrapper = beanClass;
    }
    if (wrapper == null) {
      wrapper = beanClass;
    }
  }
  return wrapper;
}
origin: azeckoski/reflectutils

Object value = entry.getValue();
try {
  if ( ConstructorUtils.isClassSimple(targetType) ) {
        dest = getConstructorUtils().constructClass(targetType);
origin: org.azeckoski/reflectutils

  newC = constructClass(type);
} else {
  int paramsCount = params.length;
    constructors = getClassDataCacher().getClassData(type).getConstructors();
  } catch (IllegalArgumentException e) {
    try {
        if ( classEquals(paramTypes[j], cParamTypes[j]) ) {
          matching = true;
        } else {
          if ( classAssignable(cParamTypes[j], paramTypes[j]) ) {
origin: org.sakaiproject.kernel/sakai-kernel-impl

/**
 * Determine if an object is a map
 * @param object any object
 * @return true if the object is a map
 */
private boolean isObjectMap(Object object) {
  boolean map = false;
  if (object != null) {
    Class clazz = object.getClass();
    map = ConstructorUtils.isClassMap(clazz);
  }
  return map;
}
org.azeckoski.reflectutilsConstructorUtils

Javadoc

Class which provides methods for dealing with class constructors, also provides access to all the public constructors for a class

Most used methods

  • isClassBean
  • isClassMap
  • isClassSimple
  • isClassArray
  • isClassCollection
  • <init>
    Empty constructor WARNING: use the #getInstance() method to get this rather than recreating it over
  • checkNull
  • classAssignable
    Checks if assignFrom is assignable to assignTo (i.e. this is OK: assignFrom b; assignTo a = (assignT
  • classEquals
    Will compare 2 classes for equality which will make a friendly comparison of types and will happily
  • constructClass
    Construct an object for the class of the given type with the given params (arguments), arguments mus
  • getClassDataCacher
  • getClassFromInterface
    Gets a valid class which can be constructed from an interface or special cases which cannot be const
  • getClassDataCacher,
  • getClassFromInterface,
  • getDefaultValue,
  • getExtendAndInterfacesForClass,
  • getImmutableDefaults,
  • getImmutableTypes,
  • getInstance,
  • getInterfacesForClass,
  • getPrimitiveDefaults,
  • getPrimitiveToWrapper

Popular in Java

  • Parsing JSON documents to java classes using gson
  • setScale (BigDecimal)
  • putExtra (Intent)
  • getContentResolver (Context)
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • Menu (java.awt)
  • Point (java.awt)
    A point representing a location in (x,y) coordinate space, specified in integer precision.
  • TimeZone (java.util)
    TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • JPanel (javax.swing)
  • 21 Best IntelliJ Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now