/** * If a Type is a class, return it as a class. * If it is a ParameterizedType, return the raw type as a class. * Otherwise return null. * @param type * @return */ public static Class<?> getTypeRelatedClass(Type type) { Class<?> directClass = getTypeClass(type, false); if (directClass != null) { return directClass; } if (type instanceof ParameterizedType) { ParameterizedType pType = (ParameterizedType) type; return getTypeRelatedClass(pType.getRawType()); } if (type instanceof GenericArrayType) { GenericArrayType gat = (GenericArrayType) type; Type compType = gat.getGenericComponentType(); Class<?> arrayBaseType = getTypeRelatedClass(compType); // believe it or not, this seems to be the only way to get the // Class object for an array of primitive type. Object instance = Array.newInstance(arrayBaseType, 0); return instance.getClass(); } return null; } }
/** * If a Type is a class, return it as a class. * If it is a ParameterizedType, return the raw type as a class. * Otherwise return null. * @param type * @return */ public static Class<?> getTypeRelatedClass(Type type) { Class<?> directClass = getTypeClass(type, false); if (directClass != null) { return directClass; } if (type instanceof ParameterizedType) { ParameterizedType pType = (ParameterizedType) type; return getTypeRelatedClass(pType.getRawType()); } if (type instanceof GenericArrayType) { GenericArrayType gat = (GenericArrayType) type; Type compType = gat.getGenericComponentType(); Class<?> arrayBaseType = getTypeRelatedClass(compType); // believe it or not, this seems to be the only way to get the // Class object for an array of primitive type. Object instance = Array.newInstance(arrayBaseType, 0); return instance.getClass(); } return null; } }
protected List<Element> findMappings(Type type) { Class<?> clazz = TypeUtil.getTypeClass(type, false); List<Element> mappings = new ArrayList<>(); if (clazz == null) {
protected List<Element> findMappings(Type type) { Class<?> clazz = TypeUtil.getTypeClass(type, false); List<Element> mappings = new ArrayList<>(); if (clazz == null) {
public TypeClassInfo createBasicClassInfo(Type type) { TypeClassInfo info = new TypeClassInfo(); Class<?> typeClass = TypeUtil.getTypeClass(type, false); if (typeClass != null) { info.setDescription("class '" + typeClass.getName() + "'"); } else { info.setDescription("type '" + type + "'"); } info.setType(type); return info; }
public TypeClassInfo createBasicClassInfo(Type type) { TypeClassInfo info = new TypeClassInfo(); Class<?> typeClass = TypeUtil.getTypeClass(type, false); if (typeClass != null) { info.setDescription("class '" + typeClass.getName() + "'"); } else { info.setDescription("type '" + type + "'"); } info.setType(type); return info; }
protected Element findMapping(Type type) { // We are not prepared to find .aegis.xml files for Parameterized types. Class<?> clazz = TypeUtil.getTypeClass(type, false); if (clazz == null) { return null; } Document doc = getDocument(clazz); if (doc == null) { return null; } Element mapping = getMatch(doc, "/mappings/mapping[@uri='" + getTypeMapping().getMappingIdentifierURI() + "']"); if (mapping == null) { mapping = getMatch(doc, "/mappings/mapping[not(@uri)]"); } return mapping; }
protected Element findMapping(Type type) { // We are not prepared to find .aegis.xml files for Parameterized types. Class<?> clazz = TypeUtil.getTypeClass(type, false); if (clazz == null) { return null; } Document doc = getDocument(clazz); if (doc == null) { return null; } Element mapping = getMatch(doc, "/mappings/mapping[@uri='" + getTypeMapping().getMappingIdentifierURI() + "']"); if (mapping == null) { mapping = getMatch(doc, "/mappings/mapping[not(@uri)]"); } return mapping; }
@Override public AegisType createDefaultType(TypeClassInfo info) { BeanType type = new BeanType(); /* * As of this point, we refuse to do this for generics in general. * This might be revisited ... it might turn out to 'just work'. */ Class<?> typeClass = TypeUtil.getTypeClass(info.getType(), false); if (typeClass == null) { throw new DatabindingException("Unable to map generic type " + info.getType()); } type.setSchemaType(createQName(typeClass)); type.setTypeClass(typeClass); type.setTypeMapping(getTypeMapping()); BeanTypeInfo typeInfo = type.getTypeInfo(); typeInfo.setDefaultMinOccurs(getConfiguration().getDefaultMinOccurs()); typeInfo.setExtensibleAttributes(getConfiguration().isDefaultExtensibleAttributes()); typeInfo.setExtensibleElements(getConfiguration().isDefaultExtensibleElements()); return type; } protected AegisType getOrCreateMapKeyType(TypeClassInfo info) {
@Override public AegisType createDefaultType(TypeClassInfo info) { BeanType type = new BeanType(); /* * As of this point, we refuse to do this for generics in general. * This might be revisited ... it might turn out to 'just work'. */ Class<?> typeClass = TypeUtil.getTypeClass(info.getType(), false); if (typeClass == null) { throw new DatabindingException("Unable to map generic type " + info.getType()); } type.setSchemaType(createQName(typeClass)); type.setTypeClass(typeClass); type.setTypeMapping(getTypeMapping()); BeanTypeInfo typeInfo = type.getTypeInfo(); typeInfo.setDefaultMinOccurs(getConfiguration().getDefaultMinOccurs()); typeInfo.setExtensibleAttributes(getConfiguration().isDefaultExtensibleAttributes()); typeInfo.setExtensibleElements(getConfiguration().isDefaultExtensibleElements()); return type; } protected AegisType getOrCreateMapKeyType(TypeClassInfo info) {