Map a primitive class type to it's real object wrapper

@param clazz The primitive type class
@return The object wrapper class
168825
private Class mapPrimitive(Class clazz) {
		if (clazz == Integer.TYPE) {
			return Integer.class;
		}
		if (clazz == Double.TYPE) {
			return Double.class;
		}
		if (clazz == Float.TYPE) {
			return Float.class;
		}
		if (clazz == Boolean.TYPE) {
			return Boolean.class;
		}
		if (clazz == Long.TYPE) {
			return Long.class;
		}
		
		throw new RuntimeException("Unsupported primitive: "+clazz);
	}
904175
public static Map<String, PropertyDescriptor> mapPropertyDescriptors(Class<?> clazz) {
        PropertyDescriptor[] properties = propertyDescriptors(clazz);
        Map<String, PropertyDescriptor> mappedProperties = new HashMap<String, PropertyDescriptor>();

        for (PropertyDescriptor property : properties) {
            if ("class".equals(property.getName()) == false) {
                mappedProperties.put(property.getName(), property);
            }
        }

        return mappedProperties;
    }
244070
public static boolean isPrimitiveWrapper(Class<?> clazz) {
		if (null == clazz) {
			return false;
		}
		return BasicType.wrapperPrimitiveMap.containsKey(clazz);
	}
268828
public <T> Clazz<T> FindClazz( Class<T> clazz )
	{
		if( clazzz == null )
			return null;

		for( Clazz<?> c : clazzz.values() )
			if( c.getReflectedClass() == clazz )
			{
				@SuppressWarnings( "unchecked" )
				Clazz<T> result = (Clazz<T>) c;
				return result;
			}

		return null;
	}
1297573
public static Builder forClass(Class clazz) {
        if (clazz == null) {
            throw new IllegalArgumentException("class can not be null");
        }
        return new Builder(Collections.singletonList(clazz));
    }
1017896
public static <T> Clazz<T> Clazz( Class<T> clazz )
	{
		return impl.Clazz( clazz );
	}
932079
private static IObjectSerializer getSerializer( Class clazz )
  {
    Iterator<Map.Entry<Class, IObjectSerializer>> iterator = serializers.entrySet().iterator();
    IObjectSerializer serializer = DEFAULT_SERIALIZER;

    while( iterator.hasNext() )
    {
      Map.Entry<Class, IObjectSerializer> entry = iterator.next();

      if( entry.getKey().isAssignableFrom( clazz ) )
      {
        serializer = entry.getValue();
        break;
      }
    }

    return serializer;
  }
668889
public static List<Class<?>> getAllClasses(Class<?> clazz) {
        List<Class<?>> types = new ArrayList<>();
        while (clazz != null) {
            types.add(clazz);
            clazz = clazz.getSuperclass();
        }
        return types;
    }
565015
public static Set<Class<? extends Annotation>> getStereotypes(final Class<?> clazz) {
        final Set<Class<? extends Annotation>> ret = new HashSet<>();

        final Set<Annotation> annotations = getAnnotations(clazz.getAnnotations(), Stereotype.class);
        if (annotations.isEmpty()) {
            return ret;
        }

        for (final Annotation annotation : annotations) {
            ret.add(annotation.annotationType());
        }

        return ret;
    }
680994
@SuppressWarnings("unchecked")
    private static <T> T cast(Object obj, Class<T> clazz) {
        if (obj == null) {
            return null;
        }
        if (clazz == null) {
            throw new IllegalArgumentException("parameter 'Class<T> clazz' is not allowed to be null.");
        }
        if (clazz.isEnum() && obj instanceof String) {
            Class<Enum> enumClazz = (Class<Enum>) clazz;
            return (T) Enum.valueOf(enumClazz, obj.toString());
        }
        if (clazz.isPrimitive()) {
            if (clazz == Integer.TYPE) {
                clazz = (Class<T>) Integer.class;
            } else if (clazz == Long.TYPE) {
                clazz = (Class<T>) Long.class;
            } else if (clazz == Short.TYPE) {
                clazz = (Class<T>) Short.class;
            } else if (clazz == Double.TYPE) {
                clazz = (Class<T>) Double.class;
            } else if (clazz == Float.TYPE) {
                clazz = (Class<T>) Float.class;
            } else if (clazz == Character.TYPE) {
                clazz = (Class<T>) Character.class;
            } else if (clazz == Byte.TYPE) {
                clazz = (Class<T>) Byte.class;
            } else if (clazz == Boolean.TYPE) {
                clazz = (Class<T>) Boolean.class;
            }
        }
        return clazz.cast(obj);
    }
645703
public <T> Clazz<T> Clazz( Class<T> clazz )
	{
		_ensureMap();

		@SuppressWarnings( "unchecked" )
		Clazz<T> res = (Clazz<T>) clazzz.get( clazz );
		if( res == null )
			throw new IllegalArgumentException( "Class not supported by ClassInfo : " + clazz.getName() );

		return res;
	}
288698
public static ReloadableType getRType(Class<?> clazz) {
		//		ReloadableType rtype = null;
		WeakReference<ReloadableType> ref = classToRType.get(clazz);
		ReloadableType rtype = null;
		if (ref != null) {
			rtype = ref.get();
		}
		if (rtype == null) {

			if (!theOldWay) {
				// 'theOldWay' attempts to grab the field from the type via reflection.  This usually works except
				// in cases where the class is not resolved yet since it can cause the class to resolve and its
				// static initializer to run.  This was happening on a grails compile where the compiler is
				// loading dependencies (but not initializing them).  Instead we can use this route of
				// discovering the type registry and locating the reloadable type.  This does some map lookups
				// which may be a problem, but once discovered, it is cached in the weak ref so that shouldn't
				// be an ongoing perf problem.

				// TODO testcases for something that is reloaded without having been resolved
				ClassLoader cl = clazz.getClassLoader();
				TypeRegistry tr = TypeRegistry.getTypeRegistryFor(cl);
				if (tr == null) {
					classToRType.put(clazz, ReloadableType.NOT_RELOADABLE_TYPE_REF);
				}
				else {
					rtype = tr.getReloadableType(clazz.getName().replace('.', '/'));
					if (rtype == null) {
						classToRType.put(clazz, ReloadableType.NOT_RELOADABLE_TYPE_REF);
					}
					else {
						classToRType.put(clazz, new WeakReference<ReloadableType>(rtype));
					}
				}
			}
			else {
				// need to work it out
				Field rtypeField;
				try {
					//				System.out.println("discovering field for " + clazz.getName());
					// TODO cache somewhere - will need a clazz>Field cache
					rtypeField = clazz.getDeclaredField(Constants.fReloadableTypeFieldName);
				}
				catch (NoSuchFieldException nsfe) {
					classToRType.put(clazz, ReloadableType.NOT_RELOADABLE_TYPE_REF);
					// expensive if constantly discovering this
					return null;
				}
				try {
					rtypeField.setAccessible(true);
					rtype = (ReloadableType) rtypeField.get(null);
					if (rtype == null) {
						classToRType.put(clazz, ReloadableType.NOT_RELOADABLE_TYPE_REF);
						throw new ReloadException("ReloadableType field '" + Constants.fReloadableTypeFieldName
								+ "' is 'null' on type " + clazz.getName());
					}
					else {
						classToRType.put(clazz, new WeakReference<ReloadableType>(rtype));
					}
				}
				catch (Exception e) {
					throw new ReloadException("Unable to access ReloadableType field '"
							+ Constants.fReloadableTypeFieldName
							+ "' on type " + clazz.getName(), e);
				}
			}
		}
		else if (rtype == ReloadableType.NOT_RELOADABLE_TYPE) {
			return null;
		}
		return rtype;
	}
932281
public static <T> T getDefaultWrapperValue(Class<T> clazz) {
        if (clazz == Short.class) {
            return (T) Short.valueOf((short) 0);
        } else if (clazz == Integer.class) {
            return (T) Integer.valueOf(0);
        } else if (clazz == Long.class) {
            return (T) Long.valueOf(0L);
        } else if (clazz == Double.class) {
            return (T) Double.valueOf(0d);
        } else if (clazz == Float.class) {
            return (T) Float.valueOf(0f);
        } else if (clazz == Byte.class) {
            return (T) Byte.valueOf((byte) 0);
        } else if (clazz == Character.class) {
            return (T) Character.valueOf((char) 0);
        } else if (clazz == Boolean.class) {
            return (T) Boolean.FALSE;
        }
        return null;
    }
181433
public static Class<?> resolvePrimitiveIfNecessary(Class<?> clazz) {
		Assert.notNull(clazz, "Class must not be null");
		return (clazz.isPrimitive() && clazz != void.class? primitiveTypeToWrapperMap.get(clazz) : clazz);
	}
1304166
public Map<String, EmbeddableType> getEmbeddables(Class clazz)
    {
        Map<String, EmbeddableType> embeddableAttibutes = new HashMap<String, EmbeddableType>();

        if (entityTypes != null)
        {
            EntityType entity = entityTypes.get(clazz);
            Iterator<Attribute> iter = entity.getAttributes().iterator();
            while (iter.hasNext())
            {
                Attribute attribute = iter.next();
                if (isEmbeddable(((AbstractAttribute) attribute).getBindableJavaType()))
                {
                    embeddableAttibutes.put(attribute.getName(),
                            embeddable(((AbstractAttribute) attribute).getBindableJavaType()));
                }
            }
        }
        return embeddableAttibutes;
    }
675408
public static Map<String, List<Method>> getDeclaredMethodsRecursively(Class clazz) {
        final Map<String, List<Method>> current = Arrays
            .stream(clazz.getDeclaredMethods())
            .filter(m -> !m.getName().startsWith("lambda"))
            .collect(Collectors.groupingBy(Method::getName));
        for (Class interfaceClazz : clazz.getInterfaces()) {
            getDeclaredMethodsRecursively(interfaceClazz).forEach(current::putIfAbsent);
        }
        if (clazz.getSuperclass() != null) {
            getDeclaredMethodsRecursively(clazz.getSuperclass()).forEach(current::putIfAbsent);
        }
        return current;
    }
167826
public static String getDescriptor(final Class<?> clazz) {
    StringBuilder stringBuilder = new StringBuilder();
    appendDescriptor(stringBuilder, clazz);
    return stringBuilder.toString();
  }