From b471ac5e8ccc7bef2a5249dc325ad577740307f7 Mon Sep 17 00:00:00 2001 From: Peter Reilly Date: Tue, 12 Dec 2006 22:15:30 +0000 Subject: [PATCH] stop making MacroDef#TemplateElement extend MacroDef#Member - BC reasons, and remore MacroDef#Member git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@486365 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/tools/ant/taskdefs/MacroDef.java | 164 +++++++----------- 1 file changed, 67 insertions(+), 97 deletions(-) diff --git a/src/main/org/apache/tools/ant/taskdefs/MacroDef.java b/src/main/org/apache/tools/ant/taskdefs/MacroDef.java index 5d9e81808..90246f3b2 100644 --- a/src/main/org/apache/tools/ant/taskdefs/MacroDef.java +++ b/src/main/org/apache/tools/ant/taskdefs/MacroDef.java @@ -319,96 +319,6 @@ public class MacroDef extends AntlibDefinition { log("creating macro " + name, Project.MSG_VERBOSE); } - /** - * Base class for a macro's attributes, elements, and text element. - * - * @since ant 1.7 - */ - public static class Member { - - private String name; - private String description; - - /** - * Sets the name of this member. - * - * @param name the name of the attribute - */ - public void setName(String name) { - if (!isValidName(name)) { - throw new BuildException( - "Illegal name [" + name + "] for macro member"); - } - this.name = name.toLowerCase(Locale.US); - } - - /** - * Gets the name of this macro member. - * - * @return the name of the member. - */ - public String getName() { - return name; - } - - /** - * Sets a textual description of this member, - * for build documentation purposes only. - * - * @param desc Description of the element. - * @since ant 1.6.1 - */ - public void setDescription(String desc) { - description = desc; - } - - /** - * Gets the description of this member. - * - * @return the description of the element, or null if - * no description is available. - * @since ant 1.6.1 - */ - public String getDescription() { - return description; - } - - /** - * equality method. - * - * @param obj an Object value - * @return a boolean value - */ - public boolean equals(Object obj) { - if (obj == this) { - return true; - } - if (obj != null && obj.getClass().equals(getClass())) { - return equals((Member) obj); - } - return false; - } - - /** - * Equality method once it has been ascertain the object - * to compare to is not ourselves and is of the same type. - * - * @param m macro member guaranteed to be of the same type as this. - * @return a boolean value - */ - protected boolean equals(Member m) { - return (name == null) ? m.name == null : name.equals(m.name); - } - - /** - * Gets the hash code of this member, consistent with equals. - * @return a hash code value for this object. - */ - public int hashCode() { - return objectHashCode(name); - } - - } /** * An attribute for the MacroDef task. @@ -631,11 +541,57 @@ public class MacroDef extends AntlibDefinition { /** * A nested element for the MacroDef task. */ - public static class TemplateElement extends Member { + public static class TemplateElement { + private String name; + private String description; private boolean optional = false; private boolean implicit = false; + /** + * Sets the name of this element. + * + * @param name the name of the element + */ + public void setName(String name) { + if (!isValidName(name)) { + throw new BuildException( + "Illegal name [" + name + "] for macro element"); + } + this.name = name.toLowerCase(Locale.US); + } + + /** + * Gets the name of this element. + * + * @return the name of the element. + */ + public String getName() { + return name; + } + + /** + * Sets a textual description of this element, + * for build documentation purposes only. + * + * @param desc Description of the element. + * @since ant 1.6.1 + */ + public void setDescription(String desc) { + description = desc; + } + + /** + * Gets the description of this element. + * + * @return the description of the element, or null if + * no description is available. + * @since ant 1.6.1 + */ + public String getDescription() { + return description; + } + /** * Sets whether this element is optional. * @@ -674,18 +630,32 @@ public class MacroDef extends AntlibDefinition { return implicit; } - /** {@inheritDoc}. */ - protected boolean equals(Member m) { - TemplateElement t = (TemplateElement) m; - return super.equals(m) - && optional == t.optional && implicit == t.implicit; + /** + * equality method. + * + * @param obj an Object value + * @return a boolean value + */ + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (obj == null || !obj.getClass().equals(getClass())) { + return false; + } + TemplateElement t = (TemplateElement) obj; + return + (name == null ? t.name == null : name.equals(t.name)) + && optional == t.optional + && implicit == t.implicit; } /** * @return a hash code value for this object. */ public int hashCode() { - return super.hashCode() + (optional ? 1 : 0) + (implicit ? 1 : 0); + return objectHashCode(name) + + (optional ? 1 : 0) + (implicit ? 1 : 0); } } // END static class TemplateElement