use of com.webcohesion.enunciate.javac.decorations.element.DecoratedExecutableElement in project enunciate by stoicflame.
the class AccessorFilter method accept.
/**
* Whether to accept the given member declaration as an accessor.
*
* @param element The declaration to filter.
* @return Whether to accept the given member declaration as an accessor.
*/
public boolean accept(DecoratedElement<?> element) {
if (context.isIgnored(element)) {
return false;
}
if (element.getAnnotation(com.fasterxml.jackson.annotation.JsonProperty.class) != null) {
// if there's an explicit json property annotation, we'll include it.
return true;
}
if (this.honorJaxb) {
if (element.getAnnotation(XmlTransient.class) != null) {
return false;
}
for (String annotationName : element.getAnnotations().keySet()) {
if (annotationName.startsWith("javax.xml.bind.annotation")) {
// if the property has an explicit annotation, we'll include it.
return true;
}
}
}
String name = element.getSimpleName().toString();
if ("".equals(name)) {
return false;
}
if (this.propertiesToIgnore.contains(name)) {
return false;
}
if (element instanceof PropertyElement) {
PropertyElement property = ((PropertyElement) element);
DecoratedExecutableElement getter = property.getGetter();
if (getter == null) {
// needs a getter.
return false;
}
if (!isVisible(findGetterVisibility(getter), getter)) {
return false;
}
DecoratedExecutableElement setter = property.getSetter();
if (setter != null && !isVisible(findSetterVisibility(), setter)) {
return false;
}
return true;
} else if (element instanceof DecoratedVariableElement) {
if (!isVisible(findFieldVisibility(), element)) {
return false;
}
if (element.isStatic() || element.isTransient()) {
return false;
}
return true;
}
return false;
}
use of com.webcohesion.enunciate.javac.decorations.element.DecoratedExecutableElement in project enunciate by stoicflame.
the class LombokDecoration method visitType.
@Override
public Void visitType(TypeElement e, DecoratedProcessingEnvironment env) {
DecoratedTypeElement typeElement = (DecoratedTypeElement) e;
List<DecoratedExecutableElement> methods = getLombokMethodDecorations(typeElement, env);
typeElement.getMethods().addAll(methods);
return null;
}
use of com.webcohesion.enunciate.javac.decorations.element.DecoratedExecutableElement in project enunciate by stoicflame.
the class LombokDecoration method getLombokMethodDecorations.
private List<DecoratedExecutableElement> getLombokMethodDecorations(DecoratedTypeElement element, DecoratedProcessingEnvironment env) {
List<DecoratedExecutableElement> methods = CACHE.get(element.getQualifiedName().toString());
if (methods == null) {
methods = new ArrayList<DecoratedExecutableElement>();
CACHE.put(element.getQualifiedName().toString(), methods);
List<? extends VariableElement> fields = element.getFields();
for (VariableElement field : fields) {
if (shouldGenerateGetter(element, field)) {
methods.add(new DecoratedExecutableElement(new LombokGeneratedGetter(field, env), env));
}
if (shouldGenerateSetter(element, field)) {
methods.add(new DecoratedExecutableElement(new LombokGeneratedSetter(field, env), env));
}
}
}
return methods;
}
use of com.webcohesion.enunciate.javac.decorations.element.DecoratedExecutableElement in project enunciate by stoicflame.
the class TypeDefinition method overridesAnother.
/**
* Whether the given method declaration overrides any method.
*
* @param method The method declaration.
* @return Whether the given method declaration overrides any method.
*/
protected boolean overridesAnother(DecoratedExecutableElement method) {
if (method == null) {
return false;
}
final TypeElement declaringType = (TypeElement) method.getEnclosingElement();
TypeElement superType = (TypeElement) this.env.getTypeUtils().asElement(declaringType.getSuperclass());
if (superType != null && superType.getAnnotation(XmlTransient.class) == null) {
// ignore transient supertypes.
while (superType != null && !Object.class.getName().equals(superType.getQualifiedName().toString())) {
List<ExecutableElement> methods = ElementFilter.methodsIn(superType.getEnclosedElements());
for (ExecutableElement candidate : methods) {
if (this.env.getElementUtils().overrides(method, candidate, declaringType)) {
return true;
}
}
superType = (TypeElement) this.env.getTypeUtils().asElement(superType.getSuperclass());
}
}
return false;
}
use of com.webcohesion.enunciate.javac.decorations.element.DecoratedExecutableElement in project enunciate by stoicflame.
the class AccessorFilter method accept.
/**
* Whether to accept the given member declaration as an accessor.
*
* @param element The declaration to filter.
* @return Whether to accept the given member declaration as an accessor.
*/
public boolean accept(DecoratedElement<?> element) {
if (AnnotationUtils.isIgnored(element)) {
return false;
}
if (element.getAnnotation(XmlTransient.class) != null) {
return false;
}
if (element instanceof PropertyElement) {
PropertyElement property = ((PropertyElement) element);
if ("".equals(property.getPropertyName())) {
return false;
}
for (String annotationName : property.getAnnotations().keySet()) {
if (annotationName.startsWith("javax.xml.bind.annotation")) {
// if the property has an explicit annotation, we'll include it.
return true;
}
}
DecoratedExecutableElement getter = property.getGetter();
if (getter == null) {
// needs a getter.
return false;
}
DecoratedExecutableElement setter = property.getSetter();
if (setter == null) {
// needs a setter.
return false;
}
if (!getter.isPublic()) {
// we only have to worry about public methods ("properties" are only defined by public accessor methods).
return false;
}
if (!setter.isPublic()) {
// we only have to worry about public methods ("properties" are only defined by public accessor methods).
return false;
}
return (((accessType != XmlAccessType.NONE) && (accessType != XmlAccessType.FIELD)) || (explicitlyDeclaredAccessor(element)));
} else if (element instanceof DecoratedVariableElement) {
if (element.isStatic() || element.isTransient()) {
return false;
}
if ((accessType == XmlAccessType.NONE) || (accessType == XmlAccessType.PROPERTY)) {
return explicitlyDeclaredAccessor(element);
}
if (accessType == XmlAccessType.PUBLIC_MEMBER) {
return (element.isPublic() || (explicitlyDeclaredAccessor(element)));
}
// the accessType is FIELD. Include it.
return true;
}
return false;
}
Aggregations