}
/** <p>Generates the innner class CacheData.</p>
*/
protected JavaInnerClass getCacheDataClass(JavaSource pSource) {
JavaInnerClass jic = pSource.newJavaInnerClass("CacheData", JavaSource.PRIVATE);
JavaField name = jic.newJavaField("name", String.class, JavaSource.PRIVATE);
name.setFinal(true);
JavaField values = jic.newJavaField("values", Object[].class, JavaSource.PRIVATE);
values.setFinal(true);
JavaConstructor jcon = jic.newJavaConstructor(JavaSource.PRIVATE);
DirectAccessible pName = jcon.addParam(String.class, "pName");
DirectAccessible pValues = jcon.addParam(Object[].class, "pValues");
jcon.addLine(name, " = ", pName, ";");
jcon.addLine(values, " = ", pValues, ";");
JavaMethod getNameMethod = jic.newJavaMethod("getName", String.class, JavaSource.PUBLIC);
getNameMethod.addLine("return ", name, ";");
JavaMethod getValuesMethod = jic.newJavaMethod("getValues", Object[].class, JavaSource.PUBLIC);
getValuesMethod.addLine("return ", values, ";");
{
JavaMethod jm = jic.newJavaMethod("toString", String.class, JavaSource.PUBLIC);
LocalJavaField sb = jm.newJavaField(StringBuffer.class, "sb");
sb.addLine("new ", StringBuffer.class, "(", name, ")");
DirectAccessible loopVar = jm.addForArray(values);
jm.addLine(sb, ".append(", JavaSource.getQuoted(", "), ").append(",
values, "[", loopVar, "]);");
jm.addEndFor();
jm.addLine("return ", sb, ".toString();");
}
{
JavaMethod jm = jic.newJavaMethod("hashCode", int.class, JavaSource.PUBLIC);
LocalJavaField hashCodeResult = jm.newJavaField(int.class, "result");
hashCodeResult.addLine(name, ".hashCode() + ", values, ".length;");
DirectAccessible loopVar = jm.addForArray(values);
LocalJavaField o = jm.newJavaField(Object.class, "o");
o.addLine(values, "[", loopVar, "]");
jm.addIf(o, " != null");
jm.addLine(hashCodeResult, " += ", o, ".hashCode();");
jm.addEndIf();
jm.addEndFor();
jm.addLine("return ", hashCodeResult, ";");
}
{
JavaMethod jm = jic.newJavaMethod("equals", boolean.class, JavaSource.PUBLIC);
DirectAccessible o = jm.addParam(Object.class, "o");
jm.addIf(o, " == null || !(", o, " instanceof ", jic.getQName(), ")");
jm.addLine("return false;");
jm.addEndIf();
LocalJavaField other = jm.newJavaField(jic.getQName(), "other");
other.addLine("(", jic.getQName(), ") ", o);
jm.addIf("!", name, ".equals(", other, ".name) || ", values, ".length != ",
other, ".values.length");
jm.addLine("return false;");
jm.addEndIf();
DirectAccessible loopVar = jm.addForArray(values);