Search in sources :

Example 1 with JApiImplementedInterface

use of japicmp.model.JApiImplementedInterface in project japicmp-gradle-plugin by melix.

the class Violation method describe.

public static String describe(JApiCompatibility member) {
    if (member instanceof JApiAnnotation) {
        return "Annotation " + ((JApiAnnotation) member).getFullyQualifiedName();
    }
    if (member instanceof JApiAnnotationElement) {
        return "Annotation element " + ((JApiAnnotationElement) member).getName();
    }
    if (member instanceof JApiConstructor) {
        JApiConstructor method = (JApiConstructor) member;
        Optional<CtConstructor> changedMethod = method.getNewConstructor();
        if (!changedMethod.isPresent()) {
            changedMethod = method.getOldConstructor();
        }
        return "Constructor " + (changedMethod.isPresent() ? changedMethod.get().getLongName() : method.getName());
    }
    if (member instanceof JApiMethod) {
        JApiMethod method = (JApiMethod) member;
        Optional<CtMethod> changedMethod = method.getNewMethod();
        if (!changedMethod.isPresent()) {
            changedMethod = method.getOldMethod();
        }
        return "Method " + (changedMethod.isPresent() ? changedMethod.get().getLongName() : method.getName());
    }
    if (member instanceof JApiField) {
        return "Field " + ((JApiField) member).getName();
    }
    if (member instanceof JApiClass) {
        return "Class " + ((JApiClass) member).getFullyQualifiedName();
    }
    if (member instanceof JApiSuperclass) {
        Optional<JApiClass> jApiClass = ((JApiSuperclass) member).getJApiClass();
        return "Superclass " + (jApiClass.isPresent() ? jApiClass.get() : "[removed]");
    }
    if (member instanceof JApiImplementedInterface) {
        return "Implemented interface " + ((JApiImplementedInterface) member).getFullyQualifiedName();
    }
    return member.toString();
}
Also used : JApiConstructor(japicmp.model.JApiConstructor) JApiMethod(japicmp.model.JApiMethod) JApiImplementedInterface(japicmp.model.JApiImplementedInterface) JApiSuperclass(japicmp.model.JApiSuperclass) JApiField(japicmp.model.JApiField) CtConstructor(javassist.CtConstructor) JApiClass(japicmp.model.JApiClass) JApiAnnotation(japicmp.model.JApiAnnotation) JApiAnnotationElement(japicmp.model.JApiAnnotationElement) CtMethod(javassist.CtMethod)

Example 2 with JApiImplementedInterface

use of japicmp.model.JApiImplementedInterface in project japicmp-gradle-plugin by melix.

the class ViolationsGenerator method processClass.

private void processClass(final JApiClass clazz, final Context context) {
    String oldClass = context.currentClass;
    try {
        context.currentClass = clazz.getFullyQualifiedName();
        processAllChanges(clazz, context);
        for (JApiField field : clazz.getFields()) {
            processAllChanges(field, context);
        }
        for (JApiMethod method : clazz.getMethods()) {
            processAllChanges(method, context);
        }
        for (JApiConstructor constructor : clazz.getConstructors()) {
            processAllChanges(constructor, context);
        }
        for (JApiImplementedInterface anInterface : clazz.getInterfaces()) {
            processAllChanges(anInterface, context);
        }
    } finally {
        context.currentClass = oldClass;
    }
}
Also used : JApiConstructor(japicmp.model.JApiConstructor) JApiMethod(japicmp.model.JApiMethod) JApiImplementedInterface(japicmp.model.JApiImplementedInterface) JApiField(japicmp.model.JApiField)

Aggregations

JApiConstructor (japicmp.model.JApiConstructor)2 JApiField (japicmp.model.JApiField)2 JApiImplementedInterface (japicmp.model.JApiImplementedInterface)2 JApiMethod (japicmp.model.JApiMethod)2 JApiAnnotation (japicmp.model.JApiAnnotation)1 JApiAnnotationElement (japicmp.model.JApiAnnotationElement)1 JApiClass (japicmp.model.JApiClass)1 JApiSuperclass (japicmp.model.JApiSuperclass)1 CtConstructor (javassist.CtConstructor)1 CtMethod (javassist.CtMethod)1