List of usage examples for java.lang Class getCanonicalName
public String getCanonicalName()
From source file:com.sonicle.webtop.core.app.ComponentsManager.java
public void register(String providerId, Class clazz) { String className = clazz.getCanonicalName(); synchronized (registeredClasses) { if (registeredClasses.contains(clazz)) throw new WTRuntimeException("Class already registered [{0}]", clazz.getCanonicalName()); if (canBeRegistered(clazz)) { registeredClasses.add(clazz); } else {/*ww w .j a v a2 s . c o m*/ throw new WTRuntimeException("Class cannot be registered [{0}]", clazz.getCanonicalName()); } if (isAssignableTo(clazz, RecipientsProviderBase.class)) { recipientsProviderClasses.put(providerId, clazz); } else { throw new WTRuntimeException("Class cannot be registered [{0}]", className); } } }
From source file:com.feilong.framework.netpay.advance.AbstractPaymentAdvanceAdaptor.java
/** * Post construct./*from ww w .ja v a 2 s .c o m*/ * * @throws IllegalArgumentException * the illegal argument exception * @throws IllegalAccessException * the illegal access exception */ @PostConstruct protected void postConstruct() throws IllegalArgumentException, IllegalAccessException { if (log.isDebugEnabled()) { // FieldCallback fc; // ReflectionUtils.doWithFields(getClass(), fc); // ReflectUtils. Map<String, Object> map = FieldUtil.getFieldValueMap(this); Class<? extends AbstractPaymentAdvanceAdaptor> clz = getClass(); log.debug("\n{}\n{}", clz.getCanonicalName(), JsonUtil.format(map)); } }
From source file:info.archinnov.achilles.entity.parsing.validator.EntityParsingValidator.java
public void validateHasIdMeta(Class<?> entityClass, PropertyMeta idMeta) { log.debug("Validate that entity class {} has an id meta", entityClass.getCanonicalName()); Validator.validateBeanMappingFalse(idMeta == null, "The entity '" + entityClass.getCanonicalName() + "' should have at least one field with javax.persistence.Id/javax.persistence.EmbeddedId annotation"); }
From source file:eu.stratosphere.api.java.typeutils.TypeExtractor.java
@SuppressWarnings("unchecked") private static void validateInfo(ArrayList<Type> typeHierarchy, Type type, TypeInformation<?> typeInfo) { if (type == null) { throw new InvalidTypesException("Unknown Error. Type is null."); }//from w w w .j a v a 2s .co m if (typeInfo == null) { throw new InvalidTypesException("Unknown Error. TypeInformation is null."); } if (!(type instanceof TypeVariable<?>)) { // check for basic type if (typeInfo.isBasicType()) { TypeInformation<?> actual = null; // check if basic type at all if (!(type instanceof Class<?>) || (actual = BasicTypeInfo.getInfoFor((Class<?>) type)) == null) { throw new InvalidTypesException("Basic type expected."); } // check if correct basic type if (!typeInfo.equals(actual)) { throw new InvalidTypesException( "Basic type '" + typeInfo + "' expected but was '" + actual + "'."); } } // check for tuple else if (typeInfo.isTupleType()) { // check if tuple at all if (!(type instanceof Class<?> && Tuple.class.isAssignableFrom((Class<?>) type)) && !(type instanceof ParameterizedType && Tuple.class .isAssignableFrom((Class<?>) ((ParameterizedType) type).getRawType()))) { throw new InvalidTypesException("Tuple type expected."); } // do not allow usage of Tuple as type if (type instanceof Class<?> && ((Class<?>) type).equals(Tuple.class)) { throw new InvalidTypesException("Concrete subclass of Tuple expected."); } // go up the hierarchy until we reach immediate child of Tuple (with or without generics) while (!(type instanceof ParameterizedType && ((Class<?>) ((ParameterizedType) type).getRawType()).getSuperclass().equals(Tuple.class)) && !(type instanceof Class<?> && ((Class<?>) type).getSuperclass().equals(Tuple.class))) { typeHierarchy.add(type); // parameterized type if (type instanceof ParameterizedType) { type = ((Class<?>) ((ParameterizedType) type).getRawType()).getGenericSuperclass(); } // class else { type = ((Class<?>) type).getGenericSuperclass(); } } // check if immediate child of Tuple has generics if (type instanceof Class<?>) { throw new InvalidTypesException("Parameterized Tuple type expected."); } TupleTypeInfo<?> tti = (TupleTypeInfo<?>) typeInfo; Type[] subTypes = ((ParameterizedType) type).getActualTypeArguments(); if (subTypes.length != tti.getArity()) { throw new InvalidTypesException( "Tuple arity '" + tti.getArity() + "' expected but was '" + subTypes.length + "'."); } for (int i = 0; i < subTypes.length; i++) { validateInfo(new ArrayList<Type>(typeHierarchy), subTypes[i], ((TupleTypeInfo<?>) typeInfo).getTypeAt(i)); } } // check for Writable else if (typeInfo instanceof WritableTypeInfo<?>) { // check if writable at all if (!(type instanceof Class<?> && Writable.class.isAssignableFrom((Class<?>) type))) { throw new InvalidTypesException("Writable type expected."); } // check writable type contents Class<?> clazz = null; if (((WritableTypeInfo<?>) typeInfo).getTypeClass() != (clazz = (Class<?>) type)) { throw new InvalidTypesException( "Writable type '" + ((WritableTypeInfo<?>) typeInfo).getTypeClass().getCanonicalName() + "' expected but was '" + clazz.getCanonicalName() + "'."); } } // check for basic array else if (typeInfo instanceof BasicArrayTypeInfo<?, ?>) { Type component = null; // check if array at all if (!(type instanceof Class<?> && ((Class<?>) type).isArray() && (component = ((Class<?>) type).getComponentType()) != null) && !(type instanceof GenericArrayType && (component = ((GenericArrayType) type).getGenericComponentType()) != null)) { throw new InvalidTypesException("Array type expected."); } if (component instanceof TypeVariable<?>) { component = materializeTypeVariable(typeHierarchy, (TypeVariable<?>) component); if (component == null) { return; } } validateInfo(typeHierarchy, component, ((BasicArrayTypeInfo<?, ?>) typeInfo).getComponentInfo()); } // check for object array else if (typeInfo instanceof ObjectArrayTypeInfo<?, ?>) { // check if array at all if (!(type instanceof Class<?> && ((Class<?>) type).isArray()) && !(type instanceof GenericArrayType)) { throw new InvalidTypesException("Object array type expected."); } // check component Type component = null; if (type instanceof Class<?>) { component = ((Class<?>) type).getComponentType(); } else { component = ((GenericArrayType) type).getGenericComponentType(); } if (component instanceof TypeVariable<?>) { component = materializeTypeVariable(typeHierarchy, (TypeVariable<?>) component); if (component == null) { return; } } validateInfo(typeHierarchy, component, ((ObjectArrayTypeInfo<?, ?>) typeInfo).getComponentInfo()); } // check for value else if (typeInfo instanceof ValueTypeInfo<?>) { // check if value at all if (!(type instanceof Class<?> && Value.class.isAssignableFrom((Class<?>) type))) { throw new InvalidTypesException("Value type expected."); } TypeInformation<?> actual = null; // check value type contents if (!((ValueTypeInfo<?>) typeInfo) .equals(actual = ValueTypeInfo.getValueTypeInfo((Class<? extends Value>) type))) { throw new InvalidTypesException( "Value type '" + typeInfo + "' expected but was '" + actual + "'."); } } // check for custom object else if (typeInfo instanceof GenericTypeInfo<?>) { Class<?> clazz = null; if (!(type instanceof Class<?> && ((GenericTypeInfo<?>) typeInfo).getTypeClass() == (clazz = (Class<?>) type)) && !(type instanceof ParameterizedType && (clazz = (Class<?>) ((ParameterizedType) type) .getRawType()) == ((GenericTypeInfo<?>) typeInfo).getTypeClass())) { throw new InvalidTypesException("Generic object type '" + ((GenericTypeInfo<?>) typeInfo).getTypeClass().getCanonicalName() + "' expected but was '" + clazz.getCanonicalName() + "'."); } } } else { type = materializeTypeVariable(typeHierarchy, (TypeVariable<?>) type); if (type != null) { validateInfo(typeHierarchy, type, typeInfo); } } }
From source file:com.addthis.codec.jackson.CodecBeanDeserializerModifier.java
@Override public JsonDeserializer<?> modifyDeserializer(DeserializationConfig config, BeanDescription beanDesc, JsonDeserializer<?> deserializer) { JsonDeserializer<?> delegatee = deserializer.getDelegatee(); if (delegatee != null) { JsonDeserializer<?> replacementDelegatee = modifyDeserializer(config, beanDesc, delegatee); return deserializer.replaceDelegatee(replacementDelegatee); } else if (deserializer instanceof BeanDeserializerBase) { BeanDeserializerBase beanDeserializer = (BeanDeserializerBase) deserializer; ObjectNode fieldDefaults = config.getNodeFactory().objectNode(); Iterator<SettableBeanProperty> propertyIterator = beanDeserializer.properties(); while (propertyIterator.hasNext()) { SettableBeanProperty prop = propertyIterator.next(); Class<?> declaringClass = prop.getMember().getDeclaringClass(); String canonicalClassName = declaringClass.getCanonicalName(); if ((canonicalClassName != null) && globalDefaults.hasPath(canonicalClassName)) { Config declarerDefaults = globalDefaults.getConfig(canonicalClassName); String propertyName = prop.getName(); if (declarerDefaults.hasPath(propertyName)) { ConfigValue defaultValue = declarerDefaults.getValue(propertyName); JsonNode fieldDefault = Jackson.configConverter(defaultValue); fieldDefaults.set(propertyName, fieldDefault); }/*from w ww . j a v a 2 s. c o m*/ } } return new CodecBeanDeserializer(beanDeserializer, fieldDefaults); } else { return deserializer; } }
From source file:it.unibas.spicy.persistence.object.operators.GenerateClassModelTree.java
private IClassNode getClassNode(ClassTree classTree, Class currentClass) { if (logger.isDebugEnabled()) logger.debug("Getting class node: " + currentClass.getCanonicalName()); IClassNode currentClassNode = classTree.get(currentClass.getCanonicalName()); if (currentClassNode == null) { currentClassNode = buildClassNode(currentClass); classTree.put(currentClassNode.getName(), currentClassNode); }// ww w . j a va 2s . c om return currentClassNode; }
From source file:com.workday.autoparse.json.parser.JsonParserUtils.java
private static void throwMapException(String name, String key, Class<?> valueClass, Object value) { throw new IllegalStateException( String.format(Locale.US, "Could not convert value at \"%s\" in \"%s\" to %s from %s.", name, key, valueClass.getCanonicalName(), getClassName(value))); }
From source file:it.unibas.spicy.persistence.object.operators.GenerateClassModelTree.java
private IClassNode buildClassNode(Class currentClass) { if (logger.isDebugEnabled()) logger.debug("Creating new class node: " + currentClass.getCanonicalName()); if (!isConstructorNoArgAvailable(currentClass)) { throw new IllegalModelException( "Missing no-arg constructor for class: " + currentClass.getCanonicalName()); }/*from w w w.j ava2 s . c om*/ IClassNode classNode = new ClassNode(currentClass.getCanonicalName()); classNode.setCorrespondingClass(currentClass); return classNode; }
From source file:info.archinnov.achilles.internal.metadata.parsing.EntityParser.java
private void validateEntityAndGetObjectMapper(EntityParsingContext context) { Class<?> entityClass = context.getCurrentEntityClass(); log.debug("Validate entity {}", entityClass.getCanonicalName()); Validator.validateInstantiable(entityClass); ObjectMapper objectMapper = context.getObjectMapperFactory().getMapper(entityClass); Validator.validateNotNull(objectMapper, "No Jackson ObjectMapper found for entity '%s'", entityClass.getCanonicalName()); log.debug("Set default object mapper {} for entity {}", objectMapper.getClass().getCanonicalName(), entityClass.getCanonicalName()); context.setCurrentObjectMapper(objectMapper); }
From source file:org.molasdin.wbase.batis.spring.repository.BatisRepositoryFactoryBean.java
@SuppressWarnings("unchecked") @Override/*from w w w . ja v a 2 s .c o m*/ public F getObject() throws Exception { SpringBatisSupport<M> support = new SpringBatisSupport<M>(mapperClass); support.setTemplate(template); support.setTransactionManager(txManager); BatisRepository<T, M, ?> repo = ConstructorUtils.invokeExactConstructor(repositoryClass, new Object[] { support }, new Class[] { BatisSupport.class }); Class<T> mappedClass = BatisUtil.mappedClass(mapperClass); if (StringUtils.isBlank(mapperId)) { repo.setMapperId(mappedClass.getCanonicalName()); } else { repo.setMapperId(mapperId); } return (F) repo; }