/*
private method to look for config objects on a classmap.  The objects can be either a type string
or a Class<?> object.  This is done to facilitate lazy loading of config objects.
@param id
@param classMap
@return
769565
private <T> Class<? extends T> getObjectFromClassMap(String id, Map<String, Object> classMap)
    {
        Object obj = classMap.get(id);
        
        if(obj == null)
        {
            return null;    //object for this id wasn't found on the map
        }
        
        if(obj instanceof Class<?>)
        {
            return (Class<? extends T>)obj;
        }
        else if (obj instanceof String )
        {
            Class<?> clazz = ClassUtils.simpleClassForName((String)obj);
            classMap.put(id, clazz);
            return (Class<? extends T>)clazz;
        }
        
        //object stored in the map for this id is an invalid type.  remove it and return null
        classMap.remove(id);
        return null;        
    }
1252327
@Override
    public Object find(Class entityClass, Object key)
    {
        return find(entityClass, key, null);
    }
929595
public final void setTypeMap(Map<String, Class<?>> typeMap) throws SQLException 
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            Tr.debug(this, tc, "Set TypeMap to " + typeMap); 
        try{
            sqlConn.setTypeMap(typeMap);
        } catch(SQLFeatureNotSupportedException nse){
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                Tr.debug(this, tc, "supportsGetTypeMap false due to ", nse);
            mcf.supportsGetTypeMap = false;
            throw nse;
        } catch(UnsupportedOperationException uoe){
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                Tr.debug(this, tc, "supportsGetTypeMap false due to ", uoe);
            mcf.supportsGetTypeMap = false;
            throw uoe;
        }
        connectionPropertyChanged = true; 
    }
518413
public static Map<String, Class<? extends ParaObject>> getCoreClassesMap() {
		if (CORE_CLASSES.isEmpty()) {
			try {
				CORE_PARA_CLASSES.putAll(SCANNER.getComponentClasses(ParaObject.class.getPackage().getName()));
				CORE_CLASSES.putAll(CORE_PARA_CLASSES);
				if (!Config.CORE_PACKAGE_NAME.isEmpty()) {
					CORE_CLASSES.putAll(SCANNER.getComponentClasses(Config.CORE_PACKAGE_NAME));
				}
				logger.debug("Found {} ParaObject classes: {}", CORE_CLASSES.size(), CORE_CLASSES);
			} catch (Exception ex) {
				logger.error(null, ex);
			}
		}
		return Collections.unmodifiableMap(CORE_CLASSES);
	}
1066163
public <T extends ValueMap> List<T> getList(Object key, Class<T> clazz) {
    Object value = get(key);
    if (value instanceof List) {
      List list = (List) value;
      try {
        ArrayList<T> real = new ArrayList<>();
        for (Object item : list) {
          T typedValue = coerceToValueMap(item, clazz);
          if (typedValue != null) {
            real.add(typedValue);
          }
        }
        return real;
      } catch (Exception ignored) {
      }
    }
    return null;
  }
676294
@SuppressWarnings("unchecked")
    public final FindableDocument<? extends GedObject, ? extends GedDocument<?>>
        get(final Class<? extends GedObject> clazz) {
        return (FindableDocument<? extends GedObject, ? extends GedDocument<?>>)
                classToRepoMap .get(clazz);
    }
529367
@Override
    public void visitClassContext(ClassContext classContext) {
        if (mapInterface != null) {
            this.clsContext = classContext;
            classContext.getJavaClass().accept(this);
        }
    }
836828
private ClassRecord getClassRecord(Integer classId) {
		if (!this.classRecords.containsKey(classId)) {
			ClassRecord classRecord = new ClassRecord();
			this.classRecords.put(classId, classRecord);
			return classRecord;
		} else {
			return this.classRecords.get(classId);
		}
	}
19285
public <T> JsonReaderI<T> getMapper(Class<T> type) {
		// look for cached Mapper
		@SuppressWarnings("unchecked")
		JsonReaderI<T> map = (JsonReaderI<T>) cache.get(type);
		if (map != null)
			return map;
		/*
		 * Special handle
		 */
		if (type instanceof Class) {
			if (Map.class.isAssignableFrom(type))
				map = new DefaultMapperCollection<T>(this, type);
			else if (List.class.isAssignableFrom(type))
				map = new DefaultMapperCollection<T>(this, type);
			if (map != null) {
				cache.put(type, map);
				return map;
			}
		}

		if (type.isArray())
			map = new ArraysMapper.GenericMapper<T>(this, type);
		else if (List.class.isAssignableFrom(type))
			map = new CollectionMapper.ListClass<T>(this, type);
		else if (Map.class.isAssignableFrom(type))
			map = new CollectionMapper.MapClass<T>(this, type);
		else
			// use bean class
			map = new BeansMapper.Bean<T>(this, type);
		cache.putIfAbsent(type, map);
		return map;
	}
1264639
private static Class<?> getClassWithCaching(String className,
      Configuration conf) {
    Class<?> classs = cachedClassObjects.get(className);
    if (classs == null) {
      try {
        classs = conf.getClassByName(className);
        if (cachedClassObjects.size() < CACHE_MAX_SIZE) {
          cachedClassObjects.put(className, classs);
        }
      } catch (ClassNotFoundException e) {
        throw new RuntimeException("readObject can't find class " + className,
            e);
      }
    }
    // for sanity check if the class is not null
    if (classs == null) {
      throw new RuntimeException("readObject can't find class " + className);
    }
    return classs;
  }
954151
public static Object mapToObject(Map<String, String> map, Class<?> c) {

        Method m = null;
        Object obj = null;

        try {
            obj = c.newInstance();
        } catch (InstantiationException | IllegalAccessException e) {
            log.info("instance create fail : " + c.getName());
            return null;
        }

        for (Map.Entry<String, String> entry : map.entrySet()) {

            if (entry.getValue() == null || entry.getValue().trim().isEmpty()) {
                continue;
            }

            if (entry.getValue().equalsIgnoreCase("undefined")) {
                continue;
            }

            try {
                m = findMethod(c, getSetMethodName(entry.getKey()));
                if (m == null) {
                    log.info("not found mapping method : " + entry.getKey());
                    continue;
                }
                try {
                    m.invoke(obj, castValue(m, m.getParameterTypes()[0], entry.getValue()));
                } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
                    log.info("method invoke error : " + m.getName());
                }
            } catch (SecurityException e) {
                log.info("security exception : " + e.getMessage());
            }
        }

        return obj;
    }
991217
public static <E> JsonMapper<E> mapperFor(Class<E> cls) throws NoSuchMapperException {
        JsonMapper<E> mapper = getMapper(cls);

        if (mapper == null) {
            throw new NoSuchMapperException(cls);
        } else {
            return mapper;
        }
    }
642002
public <P extends ParaObject> P findById(String id) {
		MultivaluedMap<String, String> params = new MultivaluedHashMap<>();
		params.putSingle(Config._ID, id);
		List<P> list = getItems(find("id", params));
		return list.isEmpty() ? null : list.get(0);
	}
577639
public <T> Map<String, T> findByTypeWithName(Class<T> type) {
        return BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, type);
    }
330644
LoadClass getClassByID(long classObjectID) {
        long[] offset = new long[] { startOffset };

        while (offset[0] < endOffset) {
            long start = offset[0];
            long classID = readLoadClassID(offset);

            if (classID == classObjectID) {
                return new LoadClass(this, start);
            }
        }

        return null;
    }
50697
public static <T> IRelationalJMapper<T> getRelationalMapper(final Class<T> configuredClass){
		return getRelationalMapper(configuredClass, undefinedXML());
	}
72150
@SuppressWarnings("unchecked")
        public static <T> ClassSup<T> cls(String clsName) {
                try {
                        return mapper.get(clsName, () -> (ClassSup<T>) cls(Class.forName(clsName)));
                } catch (Exception e) {
                        throw $(e);
                }
        }