DeclaredType declaredMapType = findMapTypeDeclaration(declaredType, context); if (declaredMapType == null) { return null; MapType newMapType = new MapType(declaredType, context.getContext().getProcessingEnvironment()); mapTypes.put(typeSignature, newMapType); TypeMirror mapKeyType = findMapType(keyType, context); newMapType.keyType = mapKeyType == null ? keyType : mapKeyType; TypeMirror mapValueType = findMapType(valueType, context); newMapType.valueType = mapValueType == null ? valueType : mapValueType;
MapType mapType = MapType.findMapType(declaredType, context.getContext()); if (mapType != null) { JsonType keyType = mapType.getKeyType().accept(this, new Context(context.getContext(), false, false, context.getStack())); JsonType valueType = mapType.getValueType().accept(this, new Context(context.getContext(), false, false, context.getStack())); jsonType = new JsonMapType(keyType, valueType);
public DeclaredType findMapType(TypeMirror candidate) { if (this.jacksonContext != null) { DeclaredType mapType = MapType.findMapTypeDeclaration(candidate, this.jacksonContext); if (mapType != null) { return mapType; } } if (this.jackson1Context != null) { DeclaredType mapType = com.webcohesion.enunciate.modules.jackson1.model.util.MapType.findMapTypeDeclaration(candidate, this.jackson1Context); if (mapType != null) { return mapType; } } return null; } }
((AdapterType) declaredType).getAdaptingType().accept(this, context); else if (MapType.findMapType(declaredType, EnunciateJackson1Context.this) == null) { String qualifiedName = declaration.getQualifiedName().toString(); if (Object.class.getName().equals(qualifiedName)) {
MapType mapType = MapType.findMapType(declaredType, context.getContext()); if (mapType != null) { JsonType keyType = mapType.getKeyType().accept(this, new Context(context.getContext(), false, false, context.getStack())); JsonType valueType = mapType.getValueType().accept(this, new Context(context.getContext(), false, false, context.getStack())); jsonType = new JsonMapType(keyType, valueType);
public DeclaredType findMapType(TypeMirror candidate) { if (this.jacksonContext != null) { DeclaredType mapType = MapType.findMapTypeDeclaration(candidate, this.jacksonContext); if (mapType != null) { return mapType; } } if (this.jackson1Context != null) { DeclaredType mapType = com.webcohesion.enunciate.modules.jackson1.model.util.MapType.findMapTypeDeclaration(candidate, this.jackson1Context); if (mapType != null) { return mapType; } } return null; } }
((AdapterType) declaredType).getAdaptingType().accept(this, context); else if (MapType.findMapType(declaredType, EnunciateJackson1Context.this) == null) { String qualifiedName = declaration.getQualifiedName().toString(); if (Object.class.getName().equals(qualifiedName)) {
MapType mapType = MapType.findMapType(accessorType, context); if (mapType != null) { DecoratedTypeMirror keyAs = Annotations.mirrorOf(new Callable<Class<?>>() { JsonType keyType = keyUsing == null ? getJsonType(keyAs == null ? (DecoratedTypeMirror) mapType.getKeyType() : keyAs, context) : KnownJsonType.OBJECT; JsonType valueType = contentUsing == null ? getJsonType(contentAs == null ? (DecoratedTypeMirror) mapType.getValueType() : contentAs, context) : KnownJsonType.OBJECT; return new JsonMapType(keyType, valueType);
DeclaredType declaredMapType = findMapTypeDeclaration(declaredType, context); if (declaredMapType == null) { return null; MapType newMapType = new MapType(declaredType, context.getContext().getProcessingEnvironment()); mapTypes.put(typeSignature, newMapType); TypeMirror mapKeyType = findMapType(keyType, context); newMapType.keyType = mapKeyType == null ? keyType : mapKeyType; TypeMirror mapValueType = findMapType(valueType, context); newMapType.valueType = mapValueType == null ? valueType : mapValueType;
public static DeclaredType findMapTypeDeclaration(TypeMirror typeMirror, EnunciateJackson1Context context) { if (!(typeMirror instanceof DeclaredType)) { return null; } DeclaredType declaredType = (DeclaredType) typeMirror; TypeElement element = (TypeElement) declaredType.asElement(); String fqn = element.getQualifiedName().toString(); if (Map.class.getName().equals(fqn)) { return declaredType; } AdapterType adapterType = JacksonUtil.findAdapterType(element, context); if (adapterType != null) { return findMapTypeDeclaration(adapterType.getAdaptingType(), context); } DeclaredType mapType = null; Types typeUtils = context.getContext().getProcessingEnvironment().getTypeUtils(); List<? extends TypeMirror> supers = typeUtils.directSupertypes(declaredType); for (TypeMirror superInterface : supers) { mapType = findMapTypeDeclaration(superInterface, context); if (mapType != null) { break; } } return mapType; }
/** * The type of the accessor. * * @return The type of the accessor. */ public DecoratedTypeMirror getAccessorType() { DecoratedTypeMirror accessorType = (DecoratedTypeMirror) asType(); accessorType = OptionalUtils.stripOptional(accessorType, this.context.getContext().getProcessingEnvironment()); accessorType = this.context.resolveSyntheticType(accessorType); DecoratedDeclaredType normalizedCollection = JacksonUtil.getNormalizedCollection(accessorType, this.context.getContext().getProcessingEnvironment()); if (normalizedCollection != null) { accessorType = normalizedCollection; } else { MapType mapType = MapType.findMapType(accessorType, this.context); if (mapType != null) { accessorType = mapType; } } return accessorType; }
MapType mapType = MapType.findMapType(accessorType, context); if (mapType != null) { DecoratedTypeMirror keyAs = Annotations.mirrorOf(new Callable<Class<?>>() { JsonType keyType = keyUsing == null ? getJsonType(keyAs == null ? (DecoratedTypeMirror) mapType.getKeyType() : keyAs, context) : KnownJsonType.OBJECT; JsonType valueType = contentUsing == null ? getJsonType(contentAs == null ? (DecoratedTypeMirror) mapType.getValueType() : contentAs, context) : KnownJsonType.OBJECT; return new JsonMapType(keyType, valueType);
public static DeclaredType findMapTypeDeclaration(TypeMirror typeMirror, EnunciateJackson1Context context) { if (!(typeMirror instanceof DeclaredType)) { return null; } DeclaredType declaredType = (DeclaredType) typeMirror; TypeElement element = (TypeElement) declaredType.asElement(); String fqn = element.getQualifiedName().toString(); if (Map.class.getName().equals(fqn)) { return declaredType; } AdapterType adapterType = JacksonUtil.findAdapterType(element, context); if (adapterType != null) { return findMapTypeDeclaration(adapterType.getAdaptingType(), context); } DeclaredType mapType = null; Types typeUtils = context.getContext().getProcessingEnvironment().getTypeUtils(); List<? extends TypeMirror> supers = typeUtils.directSupertypes(declaredType); for (TypeMirror superInterface : supers) { mapType = findMapTypeDeclaration(superInterface, context); if (mapType != null) { break; } } return mapType; }
/** * The type of the accessor. * * @return The type of the accessor. */ public DecoratedTypeMirror getAccessorType() { DecoratedTypeMirror accessorType = (DecoratedTypeMirror) asType(); accessorType = OptionalUtils.stripOptional(accessorType, this.context.getContext().getProcessingEnvironment()); accessorType = this.context.resolveSyntheticType(accessorType); DecoratedDeclaredType normalizedCollection = JacksonUtil.getNormalizedCollection(accessorType, this.context.getContext().getProcessingEnvironment()); if (normalizedCollection != null) { accessorType = normalizedCollection; } else { MapType mapType = MapType.findMapType(accessorType, this.context); if (mapType != null) { accessorType = mapType; } } return accessorType; }
public DecoratedTypeMirror resolveSyntheticType(DecoratedTypeMirror type) { if (type instanceof DeclaredType && !type.isCollection() && MapType.findMapType(type, this) == null) { if (!((DeclaredType) type).getTypeArguments().isEmpty()) { //if type arguments apply, create a new "synthetic" declared type that captures the type arguments. type = new ParameterizedJackson1DeclaredType((DeclaredType) type, getContext().getProcessingEnvironment()); } else if (type.isInterface()) { //if it's an interface, create a "synthetic" type that pretends like it's an abstract class. type = new InterfaceJackson1DeclaredType((DeclaredType) type, getContext().getProcessingEnvironment()); } } else if (type != null) { DecoratedTypeMirror componentType = TypeMirrorUtils.getComponentType(type, getContext().getProcessingEnvironment()); if (componentType != null) { DecoratedTypeMirror resolved = resolveSyntheticType(componentType); if (componentType != resolved) { return new SyntheticJackson1ArrayType(getContext().getProcessingEnvironment().getTypeUtils().getArrayType(resolved), resolved, getContext().getProcessingEnvironment()); } } } return type; }
public DecoratedTypeMirror resolveSyntheticType(DecoratedTypeMirror type) { if (type instanceof DeclaredType && !type.isCollection() && MapType.findMapType(type, this) == null) { if (!((DeclaredType) type).getTypeArguments().isEmpty()) { //if type arguments apply, create a new "synthetic" declared type that captures the type arguments. type = new ParameterizedJackson1DeclaredType((DeclaredType) type, getContext().getProcessingEnvironment()); } else if (type.isInterface()) { //if it's an interface, create a "synthetic" type that pretends like it's an abstract class. type = new InterfaceJackson1DeclaredType((DeclaredType) type, getContext().getProcessingEnvironment()); } } else if (type != null) { DecoratedTypeMirror componentType = TypeMirrorUtils.getComponentType(type, getContext().getProcessingEnvironment()); if (componentType != null) { DecoratedTypeMirror resolved = resolveSyntheticType(componentType); if (componentType != resolved) { return new SyntheticJackson1ArrayType(getContext().getProcessingEnvironment().getTypeUtils().getArrayType(resolved), resolved, getContext().getProcessingEnvironment()); } } } return type; }