From 6f6769834a03b8f8c87730bb2e418f4d6ca80a74 Mon Sep 17 00:00:00 2001 From: Peter Reilly Date: Fri, 15 Aug 2003 08:40:37 +0000 Subject: [PATCH] move same definition to AntTypeDefinition git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@275099 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/tools/ant/AntTypeDefinition.java | 24 +++++++++++++++++-- .../org/apache/tools/ant/ComponentHelper.java | 10 +------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/main/org/apache/tools/ant/AntTypeDefinition.java b/src/main/org/apache/tools/ant/AntTypeDefinition.java index e39e2a4ea..5a24182da 100644 --- a/src/main/org/apache/tools/ant/AntTypeDefinition.java +++ b/src/main/org/apache/tools/ant/AntTypeDefinition.java @@ -54,6 +54,7 @@ package org.apache.tools.ant; + /** * This class contains all the information * on a particular ant type, @@ -217,7 +218,7 @@ public class AntTypeDefinition { * @return the created object */ public Object create(Project project) { - return icreate(project); + return icreate(project); } /** @@ -326,5 +327,24 @@ public class AntTypeDefinition { "Could not create type " + name + " due to " + t, t); } } -} + /** + * Equality method for this definition + * + * @param other another definition + * @param project the project the definition + * @return true if the definitions are the same + */ + public boolean sameDefinition(AntTypeDefinition other, Project project) { + if (other == null) { + return false; + } + if (other.getClass() != this.getClass()) { + return false; + } + if (!(other.getTypeClass(project).equals(getTypeClass(project)))) { + return false; + } + return other.getExposedClass(project).equals(getExposedClass(project)); + } +} diff --git a/src/main/org/apache/tools/ant/ComponentHelper.java b/src/main/org/apache/tools/ant/ComponentHelper.java index ffadc3991..3d1837168 100644 --- a/src/main/org/apache/tools/ant/ComponentHelper.java +++ b/src/main/org/apache/tools/ant/ComponentHelper.java @@ -651,15 +651,7 @@ public class ComponentHelper { if (!validDefinition(def) || !validDefinition(old)) { return validDefinition(def) == validDefinition(old); } - - if (!(old.getTypeClass(project).equals(def.getTypeClass(project)))) { - return false; - } - if (!(old.getExposedClass(project).equals( - def.getExposedClass(project)))) { - return false; - } - return true; + return def.sameDefinition(old, project); }