// if (setter == null)
// return;
//
// JClass []paramTypes = setter.getParameterTypes();
JType type;
ClassLoader loader = getSourceType().getPersistenceUnit().getTempClassLoader();
if (! getEntitySourceType().isFieldAccess()) {
type = JTypeWrapper.create(getGetterMethod().getGenericReturnType(),
loader);
}
else {
Field field = EntityType.getField(getBeanClass(), getName());
type = JTypeWrapper.create(field.getGenericType(),
loader);
}
out.println();
// commented out: jpa/0s2d
// out.print("public void " + setter.getName() + "(");
// out.print(getJavaTypeName() + " value)");
out.print("public void " + getSetterName() + "(");
out.print(type.getName() + " value)");
out.println("{");
out.pushDepth();
// out.println("if (" + generateSuperGetterMethod() + " == value)");
// out.println(" return;");
// out.println();
//
// jpa/0j57 needs to generate the following snippet:
//
// _caucho___caucho_get_xAnnualReviews
// = new com.caucho.amber.collection.CollectionImpl<qa.XAnnualReview>(__caucho_session, null);
// _caucho___caucho_get_xAnnualReviews.addAll(0, value);
//
// jpa/0j57:
out.println("if (__caucho_session == null) {");
out.pushDepth();
out.println(generateSuperSetter("this", "value") + ";");
out.popDepth();
out.println("} else {");
out.pushDepth();
out.println("try {");
out.pushDepth();
String var = "_caucho_field_" + getGetterName();
out.print(var + " = new ");
type = getJavaType();
boolean isSet = type.isAssignableTo(Set.class);
boolean isMap = false;
if (!isSet) {
isMap = type.isAssignableTo(Map.class);
}
JType []paramArgs = type.getActualTypeArguments();
JType param = paramArgs.length > 0 ? paramArgs[0] : null;
JType param2 = paramArgs.length > 1 ? paramArgs[1] : null;
String collectionImpl;
if (isSet)
collectionImpl = "com.caucho.amber.collection.SetImpl";
else if (isMap)
collectionImpl = "com.caucho.amber.collection.MapImpl";
else
collectionImpl = "com.caucho.amber.collection.CollectionImpl";
out.print(collectionImpl);
if (param != null) {
out.print("<");
out.print(param.getPrintName());
if (isMap) {
if (param2 != null) {
out.print(", ");
out.print(param2.getPrintName());
}
}
out.print(">");
}