From 367de26fdba6baa12265dd614110ac618063dce4 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 3 Apr 2015 23:22:13 +0200 Subject: FieldInfo, MethodInfo: Add toString() --- api/src/main/java/org/osjava/jardiff/FieldInfo.java | 11 +++++++++-- api/src/main/java/org/osjava/jardiff/MethodInfo.java | 10 ++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/api/src/main/java/org/osjava/jardiff/FieldInfo.java b/api/src/main/java/org/osjava/jardiff/FieldInfo.java index ef86ea7..c159ba9 100644 --- a/api/src/main/java/org/osjava/jardiff/FieldInfo.java +++ b/api/src/main/java/org/osjava/jardiff/FieldInfo.java @@ -16,6 +16,8 @@ */ package org.osjava.jardiff; +import java.util.Arrays; + /** * Information about a field of a class. * @@ -47,8 +49,8 @@ public final class FieldInfo extends AbstractInfo * @param signature The signature of this field. * @param value The initial value of the field. */ - public FieldInfo(int access, String name, String desc, String signature, - Object value) { + public FieldInfo(final int access, final String name, final String desc, final String signature, + final Object value) { super(access, name); this.desc = desc; this.signature = signature; @@ -73,4 +75,9 @@ public final class FieldInfo extends AbstractInfo public final Object getValue() { return value; } + + public String toString() { + final String t = null != value ? value.getClass().getName() : null; + return "desc["+desc+"], sig["+signature+"], value[type "+t+", data "+value; + } } diff --git a/api/src/main/java/org/osjava/jardiff/MethodInfo.java b/api/src/main/java/org/osjava/jardiff/MethodInfo.java index 0a59c60..797faa4 100644 --- a/api/src/main/java/org/osjava/jardiff/MethodInfo.java +++ b/api/src/main/java/org/osjava/jardiff/MethodInfo.java @@ -16,6 +16,8 @@ */ package org.osjava.jardiff; +import java.util.Arrays; + /** * A class to hold information about a method. * @@ -46,8 +48,8 @@ public final class MethodInfo extends AbstractInfo * @param signature The signature of the method. * @param exceptions The exceptions thrown by the method. */ - public MethodInfo(int access, String name, String desc, String signature, - String[] exceptions) { + public MethodInfo(final int access, final String name, final String desc, final String signature, + final String[] exceptions) { super(access, name); this.desc = desc; this.signature = signature; @@ -72,4 +74,8 @@ public final class MethodInfo extends AbstractInfo public final String[] getExceptions() { return exceptions; } + + public String toString() { + return "desc["+desc+"], sig["+signature+"], throws "+(null != exceptions ? Arrays.asList(exceptions) : "nil"); + } } -- cgit v1.2.3