@Override public void call(EnunciateContext context) { if ((this.jacksonModule == null || this.jacksonModule.getJacksonContext() == null || this.jacksonModule.getJacksonContext().getTypeDefinitions().isEmpty()) && (this.jackson1Module == null || this.jackson1Module.getJacksonContext() == null || this.jackson1Module.getJacksonContext().getTypeDefinitions().isEmpty())) { info("No Jackson JSON data types: GWT JSON overlays will be generated."); return; } detectAccessorNamingErrors(); File sourceDir = generateClientSources(); packageArtifacts(sourceDir); }
@Override public void call(EnunciateContext context) { this.jacksonContext = new EnunciateJackson1Context(context, isHonorJaxbAnnotations(), getDateFormat(), isCollapseTypeHierarchy(), getMixins(), getExternalExamples(), getDefaultVisibility(), isDisableExamples(), isWrapRootValue(), getPropertyNamingStrategy(), isPropertiesAlphabetical()); DataTypeDetectionStrategy detectionStrategy = getDataTypeDetectionStrategy(); switch (detectionStrategy) { case aggressive: for (Element declaration : context.getApiElements()) { addPotentialJacksonElement(declaration, new LinkedList<Element>()); } break; case local: for (Element declaration : context.getLocalApiElements()) { addPotentialJacksonElement(declaration, new LinkedList<Element>()); } //no break, add explicit includes: default: if (context.hasExplicitIncludes()) { //if we're not aggressive, we only want to add the api elements if they've been explicitly included for (Element declaration : context.getApiElements()) { addPotentialJacksonElement(declaration, new LinkedList<Element>()); } } } }
protected boolean isExplicitTypeDefinition(Element declaration, boolean honorJaxb) { if (declaration.getKind() != ElementKind.CLASS && declaration.getKind() != ElementKind.ENUM) { debug("%s isn't a potential Jackson type because it's not a class or an enum.", declaration); return false; debug("%s isn't a potential Jackson type because its package is annotated as to be ignored.", declaration); return false; if (isThrowable(declaration)) { debug("%s isn't a potential Jackson type because it's an instance of java.lang.Throwable.", declaration); return false; || fqn.startsWith("javax.ws.rs") || fqn.startsWith("javax.jws")) { debug("%s isn't a potential Jackson type because of annotation %s.", declaration, fqn); return false; if (honorJaxb) { if (XmlTransient.class.getName().equals(fqn)) { debug("%s isn't a potential Jackson type because of annotation %s.", declaration, fqn); return false; debug("%s will be considered a Jackson type because we're honoring the %s annotation.", declaration, fqn); explicitXMLTypeOrElement = true; explicitXMLTypeOrElement = explicitXMLTypeOrElement || isJacksonSerializationAnnotation(fqn);
EnunciateJackson1Context jackson1Context = this.jackson1Module != null ? this.jackson1Module.getJacksonContext() : null; MergedJsonContext jsonContext = new MergedJsonContext(jacksonContext, jackson1Context); model.put("packageFor", new ClientPackageForMethod(conversions, this.context)); model.put("generatedCodeLicense", this.enunciate.getConfiguration().readGeneratedCodeLicenseFile()); model.put("annotationValue", new AnnotationValueMethod()); model.put("wrapRootValue", this.jacksonModule == null ? this.jackson1Module.isWrapRootValue() : this.jacksonModule.isWrapRootValue());
@Override public void addDataTypeDefinitions(TypeMirror type, Set<String> declaredMediaTypes, LinkedList<Element> contextStack) { if (MediaTypeUtils.isJsonCompatible(declaredMediaTypes)) { type = this.jacksonContext.resolveSyntheticType((DecoratedTypeMirror) type); this.jacksonContext.addReferencedTypeDefinitions(type, contextStack); } else { debug("Element %s is NOT to be added as a Jackson data type because %s doesn't seem to include JSON.", type, declaredMediaTypes); } }
EnunciateJackson1Context jackson1Context = this.jackson1Module != null ? this.jackson1Module.getJacksonContext() : null; MergedJsonContext jsonContext = new MergedJsonContext(jacksonContext, jackson1Context); model.put("packageFor", new ClientPackageForMethod(conversions, this.context)); model.put("generatedCodeLicense", this.enunciate.getConfiguration().readGeneratedCodeLicenseFile()); model.put("annotationValue", new AnnotationValueMethod()); model.put("wrapRootValue", this.jacksonModule == null ? this.jackson1Module.isWrapRootValue() : this.jacksonModule.isWrapRootValue());
@Override public void addDataTypeDefinitions(TypeMirror type, Set<String> declaredMediaTypes, LinkedList<Element> contextStack) { if (MediaTypeUtils.isJsonCompatible(declaredMediaTypes)) { type = this.jacksonContext.resolveSyntheticType((DecoratedTypeMirror) type); this.jacksonContext.addReferencedTypeDefinitions(type, contextStack); } else { debug("Element %s is NOT to be added as a Jackson data type because %s doesn't seem to include JSON.", type, declaredMediaTypes); } }
@Override public void call(EnunciateContext context) { if ((this.jacksonModule == null || this.jacksonModule.getJacksonContext() == null || this.jacksonModule.getJacksonContext().getTypeDefinitions().isEmpty()) && (this.jackson1Module == null || this.jackson1Module.getJacksonContext() == null || this.jackson1Module.getJacksonContext().getTypeDefinitions().isEmpty())) { info("No Jackson JSON data types: Java JSON client will not be generated."); return; } detectAccessorNamingErrors(); File sourceDir = generateClientSources(); File compileDir = compileClientSources(sourceDir); packageArtifacts(sourceDir, compileDir); }
@Override public void call(EnunciateContext context) { this.jacksonContext = new EnunciateJackson1Context(context, isHonorJaxbAnnotations(), getDateFormat(), isCollapseTypeHierarchy(), getMixins(), getExternalExamples(), getDefaultVisibility(), isDisableExamples(), isWrapRootValue(), getPropertyNamingStrategy(), isPropertiesAlphabetical()); DataTypeDetectionStrategy detectionStrategy = getDataTypeDetectionStrategy(); switch (detectionStrategy) { case aggressive: for (Element declaration : context.getApiElements()) { addPotentialJacksonElement(declaration, new LinkedList<Element>()); } break; case local: for (Element declaration : context.getLocalApiElements()) { addPotentialJacksonElement(declaration, new LinkedList<Element>()); } //no break, add explicit includes: default: if (context.hasExplicitIncludes()) { //if we're not aggressive, we only want to add the api elements if they've been explicitly included for (Element declaration : context.getApiElements()) { addPotentialJacksonElement(declaration, new LinkedList<Element>()); } } } }
protected boolean isExplicitTypeDefinition(Element declaration, boolean honorJaxb) { if (declaration.getKind() != ElementKind.CLASS && declaration.getKind() != ElementKind.ENUM) { debug("%s isn't a potential Jackson type because it's not a class or an enum.", declaration); return false; debug("%s isn't a potential Jackson type because its package is annotated as to be ignored.", declaration); return false; if (isThrowable(declaration)) { debug("%s isn't a potential Jackson type because it's an instance of java.lang.Throwable.", declaration); return false; || fqn.startsWith("javax.ws.rs") || fqn.startsWith("javax.jws")) { debug("%s isn't a potential Jackson type because of annotation %s.", declaration, fqn); return false; if (honorJaxb) { if (XmlTransient.class.getName().equals(fqn)) { debug("%s isn't a potential Jackson type because of annotation %s.", declaration, fqn); return false; debug("%s will be considered a Jackson type because we're honoring the %s annotation.", declaration, fqn); explicitXMLTypeOrElement = true; explicitXMLTypeOrElement = explicitXMLTypeOrElement || isJacksonSerializationAnnotation(fqn);
@Override public void call(EnunciateContext context) { if ((this.jacksonModule == null || this.jacksonModule.getJacksonContext() == null || this.jacksonModule.getJacksonContext().getTypeDefinitions().isEmpty()) && (this.jackson1Module == null || this.jackson1Module.getJacksonContext() == null || this.jackson1Module.getJacksonContext().getTypeDefinitions().isEmpty())) { info("No Jackson JSON data types: Java JSON client will not be generated."); return; } detectAccessorNamingErrors(); File sourceDir = generateClientSources(); File compileDir = compileClientSources(sourceDir); packageArtifacts(sourceDir, compileDir); }
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; }
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; }
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; }
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; }
@Override public void call(EnunciateContext context) { if ((this.jacksonModule == null || this.jacksonModule.getJacksonContext() == null || this.jacksonModule.getJacksonContext().getTypeDefinitions().isEmpty()) && (this.jackson1Module == null || this.jackson1Module.getJacksonContext() == null || this.jackson1Module.getJacksonContext().getTypeDefinitions().isEmpty())) jackson1Context = this.jackson1Module.getJacksonContext(); for (com.webcohesion.enunciate.modules.jackson1.model.TypeDefinition typeDefinition : jackson1Context.getTypeDefinitions()) { String pckg = typeDefinition.getPackage().getQualifiedName().toString();
@Override public void call(EnunciateContext context) { if ((this.jacksonModule == null || this.jacksonModule.getJacksonContext() == null || this.jacksonModule.getJacksonContext().getTypeDefinitions().isEmpty()) && (this.jackson1Module == null || this.jackson1Module.getJacksonContext() == null || this.jackson1Module.getJacksonContext().getTypeDefinitions().isEmpty())) jackson1Context = this.jackson1Module.getJacksonContext(); for (com.webcohesion.enunciate.modules.jackson1.model.TypeDefinition typeDefinition : jackson1Context.getTypeDefinitions()) { String pckg = typeDefinition.getPackage().getQualifiedName().toString();
@Override public void call(EnunciateContext context) { if ((this.jacksonModule == null || this.jacksonModule.getJacksonContext() == null || this.jacksonModule.getJacksonContext().getTypeDefinitions().isEmpty()) && (this.jackson1Module == null || this.jackson1Module.getJacksonContext() == null || this.jackson1Module.getJacksonContext().getTypeDefinitions().isEmpty())) jackson1Context = this.jackson1Module.getJacksonContext(); for (com.webcohesion.enunciate.modules.jackson1.model.TypeDefinition typeDefinition : jackson1Context.getTypeDefinitions()) { String pckg = typeDefinition.getPackage().getQualifiedName().toString();
@Override public void call(EnunciateContext context) { if ((this.jacksonModule == null || this.jacksonModule.getJacksonContext() == null || this.jacksonModule.getJacksonContext().getTypeDefinitions().isEmpty()) && (this.jackson1Module == null || this.jackson1Module.getJacksonContext() == null || this.jackson1Module.getJacksonContext().getTypeDefinitions().isEmpty())) jackson1Context = this.jackson1Module.getJacksonContext(); for (com.webcohesion.enunciate.modules.jackson1.model.TypeDefinition typeDefinition : jackson1Context.getTypeDefinitions()) { String pckg = typeDefinition.getPackage().getQualifiedName().toString();
@Override public void call(EnunciateContext context) { if ((this.jacksonModule == null || this.jacksonModule.getJacksonContext() == null || this.jacksonModule.getJacksonContext().getTypeDefinitions().isEmpty()) && (this.jackson1Module == null || this.jackson1Module.getJacksonContext() == null || this.jackson1Module.getJacksonContext().getTypeDefinitions().isEmpty())) jackson1Context = this.jackson1Module.getJacksonContext(); for (com.webcohesion.enunciate.modules.jackson1.model.TypeDefinition typeDefinition : jackson1Context.getTypeDefinitions()) { String pckg = typeDefinition.getPackage().getQualifiedName().toString();