List of usage examples for java.lang Class getCanonicalName
public String getCanonicalName()
From source file:com.ctriposs.rest4j.tools.idlgen.Rest4JDoclet.java
/** * Query Javadoc {@link ClassDoc} for the specified resource class. * * @param resourceClass resource class to be queried * @return corresponding {@link ClassDoc} *///from w ww .ja v a2s. c o m public static ClassDoc getClassDoc(long docletId, Class<?> resourceClass) { final DocInfo docInfo = _docInfo.get(docletId); if (docInfo == null) { return null; } return docInfo.getClassDoc(resourceClass.getCanonicalName()); }
From source file:com.evolveum.midpoint.prism.xml.XsdTypeMapper.java
public static QName toXsdType(Class javaClass) { QName xsdType = getJavaToXsdMapping(javaClass); if (xsdType == null) { throw new IllegalArgumentException("No XSD mapping for Java type " + javaClass.getCanonicalName()); }/* w w w .j av a2 s . c o m*/ return xsdType; }
From source file:springobjectmapper.ReflectionHelper.java
public static Field getAnnotatedField(Class<?> c, Class<? extends Annotation> annotationType) { for (Field field : getFields(c)) { Annotation annotation = field.getAnnotation(annotationType); if (annotation != null) { return field; }//from www.ja v a2s . com } throw new RuntimeException("Field with annotation " + annotationType.getCanonicalName() + " was not found on type " + c.getName() + "!"); }
From source file:com.sqewd.open.dal.services.EntitySchema.java
public static EntitySchema loadSchema(StructEntityReflect enref) throws Exception { EntitySchema entity = new EntitySchema(); Class<?> type = Class.forName(enref.Class); entity.name = enref.Entity;/*from www . ja v a2s. c om*/ AbstractPersister pers = DataManager.get().getPersister(type); entity.persister = pers.getClass().getCanonicalName(); entity.classname = type.getCanonicalName(); if (type.isAnnotationPresent(JsonRootName.class)) { JsonRootName re = type.getAnnotation(JsonRootName.class); entity.jsonname = re.value(); } entity.properties = new ArrayList<PropertySchema>(); for (StructAttributeReflect attr : enref.Attributes) { PropertySchema pdef = PropertySchema.load(type, attr.Field.getName()); if (pdef != null) entity.properties.add(pdef); } return entity; }
From source file:de.micromata.genome.util.runtime.AssertUtils.java
/** * Gets the stack above./* w w w . j av a 2 s .co m*/ * * @param above the above * @return the stack above */ public static StackTraceElement getStackAbove(final Class<?> above) { final StackTraceElement[] stel = Thread.currentThread().getStackTrace(); boolean foundFirst = false; final String clsName = above.getCanonicalName(); for (int i = 0; i < stel.length; ++i) { final StackTraceElement s = stel[i]; final String scn = s.getClassName(); if (clsName.equals(scn) == false) { if (foundFirst == true) { return s; } } else { foundFirst = true; } } if (above.getSuperclass() != null) { return getStackAbove(above.getSuperclass()); } return null; }
From source file:fi.hsl.parkandride.itest.AbstractIntegrationTest.java
public static ResponseSpecification assertResponse(HttpStatus status, Class<?> exClass) { Matcher<Integer> statusMatcher = (status == null) ? is(greaterThanOrEqualTo(HttpStatus.BAD_REQUEST.value())) : is(status.value());//from w w w . j a v a2 s.co m return new ResponseSpecBuilder().expectStatusCode(statusMatcher).expectBody("status", statusMatcher) .expectBody("exception", is(exClass.getCanonicalName())) .expectBody("timestamp", new ISO8601UTCTimestampMatcher()).build(); }
From source file:com.feilong.core.lang.ClassUtilTest.java
/** * class info map for LOGGER./* w w w .j a v a2 s . c o m*/ * * @param klass * the klass * @return <code>klass</code> nullempty, {@link Collections#emptyMap()}<br> */ public static Map<String, Object> getClassInfoMapForLog(Class<?> klass) { if (isNullOrEmpty(klass)) { return Collections.emptyMap(); } Map<String, Object> map = new LinkedHashMap<String, Object>(); map.put("clz.getCanonicalName()", klass.getCanonicalName());//"com.feilong.core.date.DatePattern" map.put("clz.getName()", klass.getName());//"com.feilong.core.date.DatePattern" map.put("clz.getSimpleName()", klass.getSimpleName());//"DatePattern" map.put("clz.getComponentType()", klass.getComponentType()); // ?"". ,voidboolean?byte?char?short?int?long?float double?. map.put("clz.isPrimitive()", klass.isPrimitive()); // ?"".,. map.put("clz.isLocalClass()", klass.isLocalClass()); // ?"?".?,?,?"""??". map.put("clz.isMemberClass()", klass.isMemberClass()); //isSynthetic()?Class?"??".java??false,?true.,JVM???,java??"??"? map.put("clz.isSynthetic()", klass.isSynthetic()); map.put("clz.isArray()", klass.isArray()); map.put("clz.isAnnotation()", klass.isAnnotation()); //??true. map.put("clz.isAnonymousClass()", klass.isAnonymousClass()); map.put("clz.isEnum()", klass.isEnum()); return map; }
From source file:com.gvmax.common.util.JsonUtils.java
/** * Converts a json string into an object. If any of the parameters are null * this method returns null./*from w w w . ja v a 2 s . c o m*/ * * @param json * The json string. * @param valueType * The required object type. * @return The object or null * @throws IOException * Can throw IOExceptions */ public static <T> T fromJson(String json, Class<T> valueType) throws IOException { if (json == null || valueType == null) { return null; } try { return mapper.readValue(json, valueType); } catch (Exception e) { throw new IOException( "error converting json to '" + valueType.getCanonicalName() + "', json=" + json + "'", e); } }
From source file:com.darkstar.beanCartography.utils.NameUtils.java
/** * Return all types of fields declared by the passed source object's class. * If getParentFields is false then only return those fields declared by * the object's class passed. Otherwise, return all fields up the parent * hierarchy./*w w w . j a va2 s . co m*/ * * @param source object that is the source of the lookup. * @param includeSuperClasses if true follow the inheritance hierarchy. * @return A map containing a list of field objects for each class encountered. */ public static <T> Map<String, List<Field>> getFields(T source, boolean includeSuperClasses) { Preconditions.checkNotNull(source, "source cannot be null!"); Map<String, List<Field>> resultMap = new HashMap<>(); Class<?> clazz = source.getClass(); List<Field> resultList; do { resultList = new ArrayList<>(); getClassFields(clazz, resultList, false); resultMap.put(clazz.getCanonicalName(), resultList); clazz = clazz.getSuperclass(); } while (clazz != null && includeSuperClasses); return resultMap; }
From source file:com.joliciel.talismane.utils.PerformanceMonitor.java
/** * Get a monitor for the class provided. * @param clazz// ww w.j av a 2 s . c o m * @return */ public static PerformanceMonitor getMonitor(@SuppressWarnings("rawtypes") Class clazz) { return getMonitor(clazz.getCanonicalName(), clazz.getSimpleName()); }