diff options
Diffstat (limited to 'src/main/javassist/ClassMap.java')
-rw-r--r-- | src/main/javassist/ClassMap.java | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/main/javassist/ClassMap.java b/src/main/javassist/ClassMap.java index 98e5cc9e..28f646f0 100644 --- a/src/main/javassist/ClassMap.java +++ b/src/main/javassist/ClassMap.java @@ -82,7 +82,7 @@ public class ClassMap extends java.util.HashMap { * <code>oldname</code> to <code>newname</code>. See * <code>fix</code> method. * - * @param oldname the original class name + * @param oldname the original class name. * @param newname the substituted class name. * @see #fix(String) */ @@ -96,6 +96,25 @@ public class ClassMap extends java.util.HashMap { super.put(oldname2, toJvmName(newname)); } + /** + * Is equivalent to <code>put()</code> except that + * the given mapping is not recorded into the hashtable + * if another mapping from <code>oldname</code> is + * already included. + * + * @param oldname the original class name. + * @param newname the substituted class name. + */ + public void putIfNone(String oldname, String newname) { + if (oldname == newname) + return; + + String oldname2 = toJvmName(oldname); + String s = (String)get(oldname2); + if (s == null) + super.put(oldname2, toJvmName(newname)); + } + protected final void put0(Object oldname, Object newname) { super.put(oldname, newname); } |