[jboss-cvs] JBossAS SVN: r104651 - projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon May 10 22:34:46 EDT 2010
Author: jeff.zhang
Date: 2010-05-10 22:34:46 -0400 (Mon, 10 May 2010)
New Revision: 104651
Modified:
projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/AbstractCodeGen.java
projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/PropsCodeGen.java
Log:
[JBJCA-316] config-properties in hashCode/equals
Modified: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/AbstractCodeGen.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/AbstractCodeGen.java 2010-05-11 02:05:51 UTC (rev 104650)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/AbstractCodeGen.java 2010-05-11 02:34:46 UTC (rev 104651)
@@ -160,7 +160,7 @@
* @param name string
* @return String name string
*/
- String upcaseFisrt(String name)
+ String upcaseFirst(String name)
{
StringBuilder sb = new StringBuilder();
sb.append(name.substring(0, 1).toUpperCase(Locale.ENGLISH));
Modified: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/PropsCodeGen.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/PropsCodeGen.java 2010-05-11 02:05:51 UTC (rev 104650)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/PropsCodeGen.java 2010-05-11 02:34:46 UTC (rev 104651)
@@ -63,7 +63,7 @@
for (int i = 0; i < getConfigProps(def).size(); i++)
{
String name = getConfigProps(def).get(i).getName();
- String upcaseName = upcaseFisrt(name);
+ String upcaseName = upcaseFirst(name);
//set
writeIndent(out, indent);
out.write("public void set" +
@@ -116,9 +116,18 @@
for (int i = 0; i < getConfigProps(def).size(); i++)
{
writeIndent(out, indent + 1);
- out.write("result = 31 * result + " + getConfigProps(def).get(i).getName() + ".hashCode();");
-
+ out.write("if (" + getConfigProps(def).get(i).getName() + " != null)");
writeEol(out);
+ writeIndent(out, indent + 2);
+ out.write("result += 31 * result + 7 * " + getConfigProps(def).get(i).getName() + ".hashCode();");
+ writeEol(out);
+ writeIndent(out, indent + 1);
+
+ out.write("else");
+ writeEol(out);
+ writeIndent(out, indent + 2);
+ out.write("result += 31 * result + 7;");
+ writeEol(out);
}
writeIndent(out, indent + 1);
out.write("return result;");
@@ -164,23 +173,30 @@
writeIndent(out, indent + 1);
out.write(getClassName(def) + " obj = (" + getClassName(def) + ")other;");
writeEol(out);
+
writeIndent(out, indent + 1);
- out.write("return ");
- if (getConfigProps(def).size() == 0)
- {
- out.write("true");
- }
+ out.write("boolean result = true; ");
+ writeEol(out);
+
for (int i = 0; i < getConfigProps(def).size(); i++)
{
- if (i != 0)
- {
- writeEol(out);
- writeIndent(out, indent + 2);
- out.write("&& ");
- }
- out.write(getConfigProps(def).get(i).getName() + ".equals(obj." + getConfigProps(def).get(i).getName() + ")");
+ writeIndent(out, indent + 1);
+ out.write("if (result && " + getConfigProps(def).get(i).getName() + " == null)");
+ writeEol(out);
+ writeIndent(out, indent + 2);
+ out.write("result = obj.get" + upcaseFirst(getConfigProps(def).get(i).getName()) + "() == null;");
+ writeEol(out);
+
+ writeIndent(out, indent + 1);
+ out.write("else");
+ writeEol(out);
+ writeIndent(out, indent + 2);
+ out.write("result = " + getConfigProps(def).get(i).getName() + ".equals(obj.get" +
+ upcaseFirst(getConfigProps(def).get(i).getName()) + "());");
+ writeEol(out);
}
- out.write(";");
+ writeIndent(out, indent + 1);
+ out.write("return result;");
writeRightCurlyBracket(out, indent);
writeEol(out);
}
More information about the jboss-cvs-commits
mailing list