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; } }
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; }
/** * Narrows the existing declaration down to its adapting declaration, if it's being adapted. Otherwise, the original declaration will be returned. * * @param declaration The declaration to narrow. * @return The narrowed declaration. */ protected TypeElement narrowToAdaptingType(TypeElement declaration) { AdapterType adapterType = JacksonUtil.findAdapterType(declaration, this); if (adapterType != null) { TypeMirror adaptingType = adapterType.getAdaptingType(); if (adaptingType.getKind() != TypeKind.DECLARED) { return declaration; } else { TypeElement adaptingDeclaration = (TypeElement) ((DeclaredType) adaptingType).asElement(); if (adaptingDeclaration == null) { throw new EnunciateException(String.format("Class %s is being adapted by a type (%s) that doesn't seem to be on the classpath.", declaration.getQualifiedName(), adaptingType)); } return adaptingDeclaration; } } return declaration; }
protected void detectAccessorNamingErrors() { if (this.jacksonModule != null) { List<String> namingConflicts = JacksonCodeErrors.findConflictingAccessorNamingErrors(this.jacksonModule.getJacksonContext()); if (namingConflicts != null && !namingConflicts.isEmpty()) { error("Jackson naming conflicts have been found:"); for (String namingConflict : namingConflicts) { error(namingConflict); } error("These naming conflicts are often between the field and it's associated property, in which case you need to use one or both of the following strategies to avoid the conflicts:"); error("1. Explicitly exclude one or the other."); error("2. Put the annotations on the property instead of the field."); throw new EnunciateException("Jackson naming conflicts detected."); } } if (this.jackson1Module != null) { List<String> namingConflicts = Jackson1CodeErrors.findConflictingAccessorNamingErrors(this.jackson1Module.getJacksonContext()); if (namingConflicts != null && !namingConflicts.isEmpty()) { error("Jackson naming conflicts have been found:"); for (String namingConflict : namingConflicts) { error(namingConflict); } error("These naming conflicts are often between the field and it's associated property, in which case you need to use one or both of the following strategies to avoid the conflicts:"); error("1. Explicitly exclude one or the other."); error("2. Put the annotations on the property instead of the field."); throw new EnunciateException("Jackson naming conflicts detected."); } } }
/** * 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; }
/** * Narrows the existing declaration down to its adapting declaration, if it's being adapted. Otherwise, the original declaration will be returned. * * @param declaration The declaration to narrow. * @return The narrowed declaration. */ protected TypeElement narrowToAdaptingType(TypeElement declaration) { AdapterType adapterType = JacksonUtil.findAdapterType(declaration, this); if (adapterType != null) { TypeMirror adaptingType = adapterType.getAdaptingType(); if (adaptingType.getKind() != TypeKind.DECLARED) { return declaration; } else { TypeElement adaptingDeclaration = (TypeElement) ((DeclaredType) adaptingType).asElement(); if (adaptingDeclaration == null) { throw new EnunciateException(String.format("Class %s is being adapted by a type (%s) that doesn't seem to be on the classpath.", declaration.getQualifiedName(), adaptingType)); } return adaptingDeclaration; } } return declaration; }
protected void detectAccessorNamingErrors() { if (this.jacksonModule != null) { List<String> namingConflicts = JacksonCodeErrors.findConflictingAccessorNamingErrors(this.jacksonModule.getJacksonContext()); if (namingConflicts != null && !namingConflicts.isEmpty()) { error("Jackson naming conflicts have been found:"); for (String namingConflict : namingConflicts) { error(namingConflict); } error("These naming conflicts are often between the field and it's associated property, in which case you need to use one or both of the following strategies to avoid the conflicts:"); error("1. Explicitly exclude one or the other."); error("2. Put the annotations on the property instead of the field."); throw new EnunciateException("Jackson naming conflicts detected."); } } if (this.jackson1Module != null) { List<String> namingConflicts = Jackson1CodeErrors.findConflictingAccessorNamingErrors(this.jackson1Module.getJacksonContext()); if (namingConflicts != null && !namingConflicts.isEmpty()) { error("Jackson naming conflicts have been found:"); for (String namingConflict : namingConflicts) { error(namingConflict); } error("These naming conflicts are often between the field and it's associated property, in which case you need to use one or both of the following strategies to avoid the conflicts:"); error("1. Explicitly exclude one or the other."); error("2. Put the annotations on the property instead of the field."); throw new EnunciateException("Jackson naming conflicts detected."); } } }
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; }
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; } }
/** * 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 TypeMirror findAdaptingType(TypeElement declaration) { if (this.jacksonContext != null) { AdapterType adapterType = JacksonUtil.findAdapterType(declaration, this.jacksonContext); if (adapterType != null) { return adapterType.getAdaptingType(); } } if (this.jackson1Context != null) { com.webcohesion.enunciate.modules.jackson1.model.adapters.AdapterType otherAdapterType = com.webcohesion.enunciate.modules.jackson1.model.util.JacksonUtil.findAdapterType(declaration, this.jackson1Context); if (otherAdapterType != null) { return otherAdapterType.getAdaptingType(); } } return null; }
protected void detectAccessorNamingErrors() { if (this.jacksonModule != null) { List<String> namingConflicts = JacksonCodeErrors.findConflictingAccessorNamingErrors(this.jacksonModule.getJacksonContext()); if (namingConflicts != null && !namingConflicts.isEmpty()) { error("Jackson naming conflicts have been found:"); for (String namingConflict : namingConflicts) { error(namingConflict); } error("These naming conflicts are often between the field and it's associated property, in which case you need to use one or both of the following strategies to avoid the conflicts:"); error("1. Explicitly exclude one or the other."); error("2. Put the annotations on the property instead of the field."); throw new EnunciateException("Jackson naming conflicts detected."); } } if (this.jackson1Module != null) { List<String> namingConflicts = Jackson1CodeErrors.findConflictingAccessorNamingErrors(this.jackson1Module.getJacksonContext()); if (namingConflicts != null && !namingConflicts.isEmpty()) { error("Jackson naming conflicts have been found:"); for (String namingConflict : namingConflicts) { error(namingConflict); } error("These naming conflicts are often between the field and it's associated property, in which case you need to use one or both of the following strategies to avoid the conflicts:"); error("1. Explicitly exclude one or the other."); error("2. Put the annotations on the property instead of the field."); throw new EnunciateException("Jackson naming conflicts detected."); } } }
public TypeMirror findAdaptingType(TypeElement declaration) { if (this.jacksonContext != null) { AdapterType adapterType = JacksonUtil.findAdapterType(declaration, this.jacksonContext); if (adapterType != null) { return adapterType.getAdaptingType(); } } if (this.jackson1Context != null) { com.webcohesion.enunciate.modules.jackson1.model.adapters.AdapterType otherAdapterType = com.webcohesion.enunciate.modules.jackson1.model.util.JacksonUtil.findAdapterType(declaration, this.jackson1Context); if (otherAdapterType != null) { return otherAdapterType.getAdaptingType(); } } return null; }
protected void detectAccessorNamingErrors() { if (this.jacksonModule != null) { List<String> namingConflicts = JacksonCodeErrors.findConflictingAccessorNamingErrors(this.jacksonModule.getJacksonContext()); if (namingConflicts != null && !namingConflicts.isEmpty()) { error("Jackson naming conflicts have been found:"); for (String namingConflict : namingConflicts) { error(namingConflict); } error("These naming conflicts are often between the field and it's associated property, in which case you need to use one or both of the following strategies to avoid the conflicts:"); error("1. Explicitly exclude one or the other."); error("2. Put the annotations on the property instead of the field."); throw new EnunciateException("Jackson naming conflicts detected."); } } if (this.jackson1Module != null) { List<String> namingConflicts = Jackson1CodeErrors.findConflictingAccessorNamingErrors(this.jackson1Module.getJacksonContext()); if (namingConflicts != null && !namingConflicts.isEmpty()) { error("Jackson naming conflicts have been found:"); for (String namingConflict : namingConflicts) { error(namingConflict); } error("These naming conflicts are often between the field and it's associated property, in which case you need to use one or both of the following strategies to avoid the conflicts:"); error("1. Explicitly exclude one or the other."); error("2. Put the annotations on the property instead of the field."); throw new EnunciateException("Jackson naming conflicts detected."); } } }
public TypeMirror findAdaptingType(TypeElement declaration) { if (this.jacksonContext != null) { AdapterType adapterType = JacksonUtil.findAdapterType(declaration, this.jacksonContext); if (adapterType != null) { return adapterType.getAdaptingType(); } } if (this.jackson1Context != null) { com.webcohesion.enunciate.modules.jackson1.model.adapters.AdapterType otherAdapterType = com.webcohesion.enunciate.modules.jackson1.model.util.JacksonUtil.findAdapterType(declaration, this.jackson1Context); if (otherAdapterType != null) { return otherAdapterType.getAdaptingType(); } } return null; }
protected void detectAccessorNamingErrors() { if (this.jacksonModule != null) { List<String> namingConflicts = JacksonCodeErrors.findConflictingAccessorNamingErrors(this.jacksonModule.getJacksonContext()); if (namingConflicts != null && !namingConflicts.isEmpty()) { error("Jackson naming conflicts have been found:"); for (String namingConflict : namingConflicts) { error(namingConflict); } error("These naming conflicts are often between the field and it's associated property, in which case you need to use one or both of the following strategies to avoid the conflicts:"); error("1. Explicitly exclude one or the other."); error("2. Put the annotations on the property instead of the field."); throw new EnunciateException("Jackson naming conflicts detected."); } } if (this.jackson1Module != null) { List<String> namingConflicts = Jackson1CodeErrors.findConflictingAccessorNamingErrors(this.jackson1Module.getJacksonContext()); if (namingConflicts != null && !namingConflicts.isEmpty()) { error("Jackson naming conflicts have been found:"); for (String namingConflict : namingConflicts) { error(namingConflict); } error("These naming conflicts are often between the field and it's associated property, in which case you need to use one or both of the following strategies to avoid the conflicts:"); error("1. Explicitly exclude one or the other."); error("2. Put the annotations on the property instead of the field."); throw new EnunciateException("Jackson naming conflicts detected."); } } }
public Accessor(javax.lang.model.element.Element delegate, TypeDefinition typeDef, EnunciateJackson1Context context) { super(delegate, context.getContext().getProcessingEnvironment()); this.typeDefinition = typeDef; this.facets.addAll(Facet.gatherFacets(delegate, context.getContext())); this.facets.addAll(typeDef.getFacets()); this.context = context; this.adapterType = JacksonUtil.findAdapterType(this, context); }
protected void detectAccessorNamingErrors() { if (this.jacksonModule != null) { List<String> namingConflicts = JacksonCodeErrors.findConflictingAccessorNamingErrors(this.jacksonModule.getJacksonContext()); if (namingConflicts != null && !namingConflicts.isEmpty()) { error("Jackson naming conflicts have been found:"); for (String namingConflict : namingConflicts) { error(namingConflict); } error("These naming conflicts are often between the field and it's associated property, in which case you need to use one or both of the following strategies to avoid the conflicts:"); error("1. Explicitly exclude one or the other."); error("2. Put the annotations on the property instead of the field."); throw new EnunciateException("Jackson naming conflicts detected."); } } if (this.jackson1Module != null) { List<String> namingConflicts = Jackson1CodeErrors.findConflictingAccessorNamingErrors(this.jackson1Module.getJacksonContext()); if (namingConflicts != null && !namingConflicts.isEmpty()) { error("Jackson naming conflicts have been found:"); for (String namingConflict : namingConflicts) { error(namingConflict); } error("These naming conflicts are often between the field and it's associated property, in which case you need to use one or both of the following strategies to avoid the conflicts:"); error("1. Explicitly exclude one or the other."); error("2. Put the annotations on the property instead of the field."); throw new EnunciateException("Jackson naming conflicts detected."); } } }
public Accessor(javax.lang.model.element.Element delegate, TypeDefinition typeDef, EnunciateJackson1Context context) { super(delegate, context.getContext().getProcessingEnvironment()); this.typeDefinition = typeDef; this.facets.addAll(Facet.gatherFacets(delegate, context.getContext())); this.facets.addAll(typeDef.getFacets()); this.context = context; this.adapterType = JacksonUtil.findAdapterType(this, context); }
protected void detectAccessorNamingErrors() { if (this.jacksonModule != null) { List<String> namingConflicts = JacksonCodeErrors.findConflictingAccessorNamingErrors(this.jacksonModule.getJacksonContext()); if (namingConflicts != null && !namingConflicts.isEmpty()) { error("Jackson naming conflicts have been found:"); for (String namingConflict : namingConflicts) { error(namingConflict); } error("These naming conflicts are often between the field and it's associated property, in which case you need to use one or both of the following strategies to avoid the conflicts:"); error("1. Explicitly exclude one or the other."); error("2. Put the annotations on the property instead of the field."); throw new EnunciateException("Jackson naming conflicts detected."); } } if (this.jackson1Module != null) { List<String> namingConflicts = Jackson1CodeErrors.findConflictingAccessorNamingErrors(this.jackson1Module.getJacksonContext()); if (namingConflicts != null && !namingConflicts.isEmpty()) { error("Jackson naming conflicts have been found:"); for (String namingConflict : namingConflicts) { error(namingConflict); } error("These naming conflicts are often between the field and it's associated property, in which case you need to use one or both of the following strategies to avoid the conflicts:"); error("1. Explicitly exclude one or the other."); error("2. Put the annotations on the property instead of the field."); throw new EnunciateException("Jackson naming conflicts detected."); } } }