Search in sources :

Example 1 with JApiSuperclass

use of japicmp.model.JApiSuperclass 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)

Aggregations

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