@Override public List<String> getSeeAlso() { JavaDoc.JavaDocTagList tags = this.typeDefinition.getJavaDoc(this.registrationContext.getTagHandler()).get("see"); if (tags == null) { tags = ((DecoratedElement) this.typeDefinition.getPackage()).getJavaDoc(this.registrationContext.getTagHandler()).get("see"); } return tags; }
/** * Load the potential accessors for this type definition. * * @param filter The filter. * @return the potential accessors for this type definition. */ protected AccessorBag loadPotentialAccessors(AccessorFilter filter) { if (getKind() == ElementKind.ENUM) { return new AccessorBag(); // ignore properties if enum } AccessorBag bag = new AccessorBag(); aggregatePotentialAccessors(bag, this, filter, this.context.isCollapseTypeHierarchy()); return bag; }
public String getTypeIdValue() { List<JsonSubTypes> subTypes = AnnotationUtils.getAnnotations(JsonSubTypes.class, this); if (!subTypes.isEmpty()) { final Types typeUtils = env.getTypeUtils(); for (JsonSubTypes.Type type : subTypes.get(0).value()) { DecoratedTypeMirror decoratedType = Annotations.mirrorOf(type::value, env); if (typeUtils.isSameType(asType(), decoratedType.getDelegate())) { if (!type.name().isEmpty()) { return type.name(); } } } } JsonTypeName typeName = getAnnotation(JsonTypeName.class); if (typeName != null && !typeName.value().isEmpty()) { return typeName.value(); } return isAbstract() ? "..." : getSimpleName().toString(); }
@Override public List<DataTypeReference> getSubtypes() { ArrayList<DataTypeReference> subtypes = new ArrayList<DataTypeReference>(); for (TypeDefinition td : this.typeDefinition.getContext().getTypeDefinitions()) { if (td instanceof ObjectTypeDefinition && !td.getQualifiedName().contentEquals(this.typeDefinition.getQualifiedName()) && ((DecoratedTypeMirror) td.asType()).isInstanceOf(this.typeDefinition)) { subtypes.add(new DataTypeReferenceImpl(JsonTypeFactory.getJsonType(td.asType(), this.typeDefinition.getContext()), registrationContext)); } } return subtypes.isEmpty() ? null : subtypes; }
public static List<String> findConflictingAccessorNamingErrors(EnunciateJackson1Context context) { List<String> errors = (List<String>) context.getContext().getProperty(CONFLICTING_JAXB_ACCESSOR_NAMING_ERRORS_PROPERTY); if (errors == null) { errors = new ArrayList<String>(); context.getContext().setProperty(CONFLICTING_JAXB_ACCESSOR_NAMING_ERRORS_PROPERTY, errors); for (TypeDefinition typeDefinition : context.getTypeDefinitions()) { Map<String, Accessor> accessorsBySimpleName = new HashMap<String, Accessor>(); for (Accessor accessor : typeDefinition.getAllAccessors()) { String name = accessor.getClientSimpleName(); Accessor conflict = accessorsBySimpleName.get(name); if (conflict != null) { errors.add(String.format("%s: accessor \"%s\" conflicts with accessor \"%s\" of %s: both are named \"%s\".", typeDefinition.getQualifiedName(), accessor, conflict, conflict.getTypeDefinition().getQualifiedName(), name)); } else { accessorsBySimpleName.put(name, accessor); } } } } return errors; } }
jackson1Context = this.jackson1Module.getJacksonContext(); for (com.webcohesion.enunciate.modules.jackson1.model.TypeDefinition typeDefinition : jackson1Context.getTypeDefinitions()) { String pckg = typeDefinition.getPackage().getQualifiedName().toString(); if (!packageToModuleConversions.containsKey(pckg)) { packageToModuleConversions.put(pckg, packageToModule(pckg));
final JsonTypeInfo info = getAnnotation(JsonTypeInfo.class); if (info != null && !info.property().isEmpty()) { bag.typeIdProperty = info.property(); if (superDeclaration != null && (this.context.isIgnored(superDeclaration) || inlineAccessorsOfSuperclasses)) { inlineAccessorsOfSuperclasses = true; aggregatePotentialAccessors(bag, superDeclaration, filter, true); int index = indexOf(fieldElements, mixinField.getSimpleName().toString()); if (index >= 0) { fieldElements.set(index, mixinField); throw new EnunciateException(String.format("%s: %s cannot be JSON unwrapped.", fieldDeclaration, typeMirror)); aggregatePotentialAccessors(bag, (DecoratedTypeElement) ((DeclaredType)typeMirror).asElement(), filter, inlineAccessorsOfSuperclasses); int index = indexOf(propertyElements, mixinProperty.getSimpleName().toString()); if (index >= 0) { propertyElements.set(index, mixinProperty); aggregatePotentialAccessors(bag, element, filter, inlineAccessorsOfSuperclasses); indexOf(bag.fields, propertyDeclaration.getSimpleName().toString()) >= 0 || propsIgnore.contains(propertyDeclaration.getSimpleName().toString())) { bag.properties.removeByName(propertyDeclaration);
protected boolean usesUnmappableElements() { boolean usesUnmappableElements = false; if (this.jacksonModule != null && this.jacksonModule.getJacksonContext() != null) { for (TypeDefinition complexType : this.jacksonModule.getJacksonContext().getTypeDefinitions()) { if (!Character.isUpperCase(complexType.getClientSimpleName().charAt(0))) { warn("%s: Ruby requires your class name to be upper-case. Please rename the class or apply the @org.codehaus.enunciate.ClientName annotation to the class.", positionOf(complexType)); usesUnmappableElements = true; } } } if (this.jackson1Module != null && this.jackson1Module.getJacksonContext() != null) { for (com.webcohesion.enunciate.modules.jackson1.model.TypeDefinition complexType : this.jackson1Module.getJacksonContext().getTypeDefinitions()) { if (!Character.isUpperCase(complexType.getClientSimpleName().charAt(0))) { warn("%s: Ruby requires your class name to be upper-case. Please rename the class or apply the @org.codehaus.enunciate.ClientName annotation to the class.", positionOf(complexType)); usesUnmappableElements = true; } } } return usesUnmappableElements; }
/** * The type of an element accessor can be specified by an annotation. * * @return The accessor type. */ @Override public DecoratedTypeMirror getAccessorType() { if (this.explicitType != null) { return this.explicitType; } JsonType specifiedJsonType = JsonTypeFactory.findSpecifiedType(this, this.context); DecoratedTypeMirror specifiedType = specifiedJsonType instanceof JsonClassType ? (DecoratedTypeMirror) ((JsonClassType) specifiedJsonType).getTypeDefinition().asType() : null; if (specifiedType != null) { return specifiedType; } return super.getAccessorType(); }
jackson1Context = this.jackson1Module.getJacksonContext(); for (com.webcohesion.enunciate.modules.jackson1.model.TypeDefinition typeDefinition : jackson1Context.getTypeDefinitions()) { String pckg = typeDefinition.getPackage().getQualifiedName().toString(); if (!packageToNamespaceConversions.containsKey(pckg)) { packageToNamespaceConversions.put(pckg, packageToNamespace(pckg));
final JsonTypeInfo info = getAnnotation(JsonTypeInfo.class); if (info != null && !info.property().isEmpty()) { bag.typeIdProperty = info.property(); if (superDeclaration != null && (this.context.isIgnored(superDeclaration) || inlineAccessorsOfSuperclasses)) { inlineAccessorsOfSuperclasses = true; aggregatePotentialAccessors(bag, superDeclaration, filter, true); int index = indexOf(fieldElements, mixinField.getSimpleName().toString()); if (index >= 0) { fieldElements.set(index, mixinField); throw new EnunciateException(String.format("%s: %s cannot be JSON unwrapped.", fieldDeclaration, typeMirror)); aggregatePotentialAccessors(bag, (DecoratedTypeElement) ((DeclaredType)typeMirror).asElement(), filter, inlineAccessorsOfSuperclasses); int index = indexOf(propertyElements, mixinProperty.getSimpleName().toString()); if (index >= 0) { propertyElements.set(index, mixinProperty); aggregatePotentialAccessors(bag, element, filter, inlineAccessorsOfSuperclasses); indexOf(bag.fields, propertyDeclaration.getSimpleName().toString()) >= 0 || propsIgnore.contains(propertyDeclaration.getSimpleName().toString())) { bag.properties.removeByName(propertyDeclaration);
protected boolean usesUnmappableElements() { boolean usesUnmappableElements = false; if (this.jacksonModule != null && this.jacksonModule.getJacksonContext() != null) { for (TypeDefinition complexType : this.jacksonModule.getJacksonContext().getTypeDefinitions()) { if (!Character.isUpperCase(complexType.getClientSimpleName().charAt(0))) { warn("%s: PHP requires your class name to be upper-case. Please rename the class or apply the @org.codehaus.enunciate.ClientName annotation to the class.", positionOf(complexType)); usesUnmappableElements = true; } } } if (this.jackson1Module != null && this.jackson1Module.getJacksonContext() != null) { for (com.webcohesion.enunciate.modules.jackson1.model.TypeDefinition complexType : this.jackson1Module.getJacksonContext().getTypeDefinitions()) { if (!Character.isUpperCase(complexType.getClientSimpleName().charAt(0))) { warn("%s: PHP requires your class name to be upper-case. Please rename the class or apply the @org.codehaus.enunciate.ClientName annotation to the class.", positionOf(complexType)); usesUnmappableElements = true; } } } return usesUnmappableElements; }
@Override public List<DataTypeReference> getSubtypes() { ArrayList<DataTypeReference> subtypes = new ArrayList<DataTypeReference>(); for (TypeDefinition td : this.typeDefinition.getContext().getTypeDefinitions()) { if (td instanceof ObjectTypeDefinition && !td.getQualifiedName().contentEquals(this.typeDefinition.getQualifiedName()) && ((DecoratedTypeMirror) td.asType()).isInstanceOf(this.typeDefinition)) { subtypes.add(new DataTypeReferenceImpl(JsonTypeFactory.getJsonType(td.asType(), this.typeDefinition.getContext()), registrationContext)); } } return subtypes.isEmpty() ? null : subtypes; }
public static List<String> findConflictingAccessorNamingErrors(EnunciateJackson1Context context) { List<String> errors = (List<String>) context.getContext().getProperty(CONFLICTING_JAXB_ACCESSOR_NAMING_ERRORS_PROPERTY); if (errors == null) { errors = new ArrayList<String>(); context.getContext().setProperty(CONFLICTING_JAXB_ACCESSOR_NAMING_ERRORS_PROPERTY, errors); for (TypeDefinition typeDefinition : context.getTypeDefinitions()) { Map<String, Accessor> accessorsBySimpleName = new HashMap<String, Accessor>(); for (Accessor accessor : typeDefinition.getAllAccessors()) { String name = accessor.getClientSimpleName(); Accessor conflict = accessorsBySimpleName.get(name); if (conflict != null) { errors.add(String.format("%s: accessor \"%s\" conflicts with accessor \"%s\" of %s: both are named \"%s\".", typeDefinition.getQualifiedName(), accessor, conflict, conflict.getTypeDefinition().getQualifiedName(), name)); } else { accessorsBySimpleName.put(name, accessor); } } } } return errors; } }
/** * The type of an element accessor can be specified by an annotation. * * @return The accessor type. */ @Override public DecoratedTypeMirror getAccessorType() { if (this.explicitType != null) { return this.explicitType; } JsonType specifiedJsonType = JsonTypeFactory.findSpecifiedType(this, this.context); DecoratedTypeMirror specifiedType = specifiedJsonType instanceof JsonClassType ? (DecoratedTypeMirror) ((JsonClassType) specifiedJsonType).getTypeDefinition().asType() : null; if (specifiedType != null) { return specifiedType; } return super.getAccessorType(); }
@Override public List<String> getSeeAlso() { JavaDoc.JavaDocTagList tags = this.typeDefinition.getJavaDoc(this.registrationContext.getTagHandler()).get("see"); if (tags == null) { tags = ((DecoratedElement) this.typeDefinition.getPackage()).getJavaDoc(this.registrationContext.getTagHandler()).get("see"); } return tags; }
jackson1Context = this.jackson1Module.getJacksonContext(); for (com.webcohesion.enunciate.modules.jackson1.model.TypeDefinition typeDefinition : jackson1Context.getTypeDefinitions()) { String pckg = typeDefinition.getPackage().getQualifiedName().toString(); if (!packageToModuleConversions.containsKey(pckg)) { packageToModuleConversions.put(pckg, packageToModule(pckg));