// if (setter == null)
// return;
//
// JType type = getGetterMethod().getGenericReturnType();
JType type;
ClassLoader loader
= getSourceType().getPersistenceUnit().getTempClassLoader();
if (! getSourceType().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/0s2i
// out.print("public void " + setter.getName() + "(");
out.print("public void " + getSetterName() + "(");
out.println(type.getPrintName() + " value)");
out.println("{");
out.pushDepth();
out.println("if (" + generateSuperGetter("this") + " == value)");
out.println(" return;");
out.println();
//
// jpa/0s2j 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/0s2j:
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(">");
}