List of usage examples for java.lang Class getSimpleName
public String getSimpleName()
From source file:com.github.rodionmoiseev.c10n.test.utils.UsingTmpDir.java
public UsingTmpDir(Class<?> clazz) { this(systemTmpDir(clazz.getSimpleName())); }
From source file:py.una.pol.karaku.test.configuration.TestBeanCreator.java
public String getName(Class<?> beanClass) { return beanClass.getSimpleName().substring(0, 1).toLowerCase() + beanClass.getSimpleName().substring(1); }
From source file:org.yardstickframework.report.jfreechart.JFreeChartGraphPlotter.java
/** * @param entry Entry.//from w w w . jav a2 s . c om * @param probeCls Probe class. * @return check if file is the given probe result file. */ private static <T> boolean isProbeResultFile(Map.Entry<String, T> entry, Class probeCls) { return entry.getKey().equals(probeCls.getSimpleName() + INPUT_FILE_EXTENSION); }
From source file:com.yahoo.elide.graphql.NonEntityDictionary.java
/** * Add given class to dictionary.//from ww w. j ava2s .c om * * @param cls Entity bean class */ @Override public void bindEntity(Class<?> cls) { String type = WordUtils.uncapitalize(cls.getSimpleName()); Class<?> duplicate = bindJsonApiToEntity.put(type, cls); if (duplicate != null && !duplicate.equals(cls)) { log.error("Duplicate binding {} for {}, {}", type, cls, duplicate); throw new DuplicateMappingException(type + " " + cls.getName() + ":" + duplicate.getName()); } entityBindings.put(cls, new EntityBinding(this, cls, type, type)); }
From source file:com.evolveum.midpoint.gui.api.util.WebModelServiceUtils.java
@Nullable public static <T extends ObjectType> PrismObject<T> loadObject(ObjectReferenceType objectReference, ModelServiceLocator page, Task task, OperationResult result) { Class<T> type = page.getPrismContext().getSchemaRegistry().determineClassForType(objectReference.getType()); String oid = objectReference.getOid(); Collection<SelectorOptions<GetOperationOptions>> options = null; LOGGER.debug("Loading {} with oid {}, options {}", type.getSimpleName(), oid, options); OperationResult subResult;/* w w w .j a v a 2 s . com*/ if (result != null) { subResult = result.createMinorSubresult(OPERATION_LOAD_OBJECT); } else { subResult = new OperationResult(OPERATION_LOAD_OBJECT); } PrismObject<T> object = null; try { if (options == null) { options = SelectorOptions.createCollection(GetOperationOptions.createResolveNames()); } else { GetOperationOptions getOpts = SelectorOptions.findRootOptions(options); if (getOpts == null) { options.add(new SelectorOptions<>(GetOperationOptions.createResolveNames())); } else { getOpts.setResolveNames(Boolean.TRUE); } } object = page.getModelService().getObject(type, oid, options, task, subResult); } catch (AuthorizationException e) { // Not authorized to access the object. This is probably caused by a reference that // point to an object that the current user cannot read. This is no big deal. // Just do not display that object. subResult.recordHandledError(e); LOGGER.debug("User {} is not authorized to read {} {}", task.getOwner() != null ? task.getOwner().getName() : null, type.getSimpleName(), oid); return null; } catch (ObjectNotFoundException e) { // Object does not exist. It was deleted in the meanwhile, or not created yet. This could happen quite often. subResult.recordHandledError(e); LOGGER.debug("{} {} does not exist", type.getSimpleName(), oid, e); return null; } catch (Exception ex) { subResult.recordFatalError("WebModelUtils.couldntLoadObject", ex); LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load object", ex); } finally { subResult.computeStatus(); } // TODO reconsider this part: until recently, the condition was always 'false' if (WebComponentUtil.showResultInPage(subResult)) { if (page instanceof PageBase) { ((PageBase) page).showResult(subResult); } } LOGGER.debug("Loaded {} with result {}", object, subResult); return object; }
From source file:it.unibo.alchemist.language.EnvironmentBuilder.java
@SuppressWarnings("unchecked") private static Object parseAndCreate(final Class<?> clazz, final String val, final Map<String, Object> env, final RandomGenerator random) throws InstantiationException, IllegalAccessException, InvocationTargetException { if (clazz.isAssignableFrom(RandomGenerator.class) && val.equalsIgnoreCase("random")) { L.debug("Random detected! Class " + clazz.getSimpleName() + ", param: " + val); if (random == null) { L.error("Random instatiation required, but RandomGenerator not yet defined."); }//from w w w .ja v a 2 s. com return random; } if (clazz.isPrimitive() || PrimitiveUtils.classIsWrapper(clazz)) { L.debug(val + " is a primitive or a wrapper: " + clazz); if ((clazz.isAssignableFrom(Boolean.TYPE) || clazz.isAssignableFrom(Boolean.class)) && (val.equalsIgnoreCase("true") || val.equalsIgnoreCase("false"))) { return Boolean.parseBoolean(val); } /* * If Number is in clazz's hierarchy */ if (PrimitiveUtils.classIsNumber(clazz)) { final Optional<Number> num = extractNumber(val); if (num.isPresent()) { final Optional<Number> castNum = PrimitiveUtils.castIfNeeded(clazz, num.get()); /* * If method requires Object or unsupported Number, return * what was parsed. */ return castNum.orElse(num.get()); } } if (Character.TYPE.equals(clazz) || Character.class.equals(clazz)) { return val.charAt(0); } } if (List.class.isAssignableFrom(clazz) && val.startsWith("[") && val.endsWith("]")) { final List<Constructor<List<?>>> l = unsafeExtractConstructors(clazz); @SuppressWarnings("rawtypes") final List list = tryToBuild(l, new ArrayList<String>(0), env, random); final StringTokenizer strt = new StringTokenizer(val.substring(1, val.length() - 1), ",; "); while (strt.hasMoreTokens()) { final String sub = strt.nextToken(); final Object o = tryToParse(sub, env, random); if (o == null) { L.debug("WARNING: list elemnt skipped: " + sub); } else { list.add(o); } } return list; } L.debug(val + " is not a primitive: " + clazz + ". Searching it in the environment..."); final Object o = env.get(val); if (o != null && clazz.isInstance(o)) { return o; } if (Time.class.isAssignableFrom(clazz)) { return new DoubleTime(Double.parseDouble(val)); } if (clazz.isAssignableFrom(String.class)) { L.debug("String detected! Passing " + val + " back."); return val; } L.debug(val + " not found or class not compatible, unable to go further."); return null; }
From source file:com.chortitzer.industria.web.dao.lab.DaoImpl_lab.java
@SuppressWarnings("unchecked") @Override//from www . ja v a 2 s . c o m public <T> List<T> getAll(Class<T> klass) { return em.createQuery("Select t from " + klass.getSimpleName() + " t").getResultList(); }
From source file:com.yiji.openapi.sdk.util.Reflections.java
public static Set<String> getSimpleFieldNames(Class<?> pojoClass) { Set<String> propertyNames = new HashSet<String>(); Class<?> clazz = pojoClass; do {/*from ww w .ja v a 2 s . c o m*/ Field[] fields = clazz.getDeclaredFields(); for (Field field : fields) { if (!Modifier.isStatic(field.getModifiers()) && (field.getType().isPrimitive() || isWrapClass(field.getType()) || field.getType().isAssignableFrom(Timestamp.class) || field.getType().isAssignableFrom(Date.class) || field.getType().isAssignableFrom(String.class) || field.getType().isAssignableFrom(Calendar.class))) { propertyNames.add(field.getName()); } } clazz = clazz.getSuperclass(); } while (clazz != null && !clazz.getSimpleName().equalsIgnoreCase("Object")); return propertyNames; }
From source file:pt.webdetails.cpf.SimpleContentGenerator.java
/** * Get a map of all public methods with the Exposed annotation. * Map is not thread-safe and should be used read-only. * @param classe Class where to find methods * @param log classe's logger/*from w ww.j a v a 2 s . c om*/ * @param lowerCase if keys should be in lower case. * @return map of all public methods with the Exposed annotation */ protected static Map<String, Method> getExposedMethods(Class<?> classe, boolean lowerCase) { HashMap<String, Method> exposedMethods = new HashMap<String, Method>(); Log log = LogFactory.getLog(classe); for (Method method : classe.getMethods()) { if (method.getAnnotation(Exposed.class) != null) { String methodKey = method.getName().toLowerCase(); if (exposedMethods.containsKey(methodKey)) { log.error("Method " + method + " differs from " + exposedMethods.get(methodKey) + " only in case and will override calls to it!!"); } log.debug("registering " + classe.getSimpleName() + "." + method.getName()); exposedMethods.put(methodKey, method); } } return exposedMethods; }
From source file:com.lzhao.framework.spring_hibernate.base.dao.DaoImpl.java
public List<T> findAll(Class<T> clazz) { return (List<T>) em.createQuery("FROM " + clazz.getSimpleName()).getResultList(); }