protected String getRoleHandlerName(Role role, boolean otherClass) { StringBuilder buf = new StringBuilder(); if (otherClass) { buf.append(getTypeFullName(role.getOtherRole().getType())); buf.append("."); } buf.append("role$$"); buf.append(role.getName()); return buf.toString(); }
protected String getDefaultCollectionGetterFor(Role role) { return makeGenericType(DomainBasedMap.Getter.class.getCanonicalName(), getTypeFullName(role.getType())); }
protected String getSetTypeDeclarationFor(Role role) { String elemType = getTypeFullName(role.getType()); return makeGenericType("java.util.Set", elemType); }
protected String getConcreteSetTypeDeclarationFor(Role role) { String elemType = getTypeFullName(role.getType()); String thisType = getTypeFullName(role.getOtherRole().getType()); return makeGenericType(getRelationAwareBaseTypeFor(role), thisType, elemType); }
protected String getRoleType(Role role) { return makeGenericType(getRoleBaseType(role), getTypeFullName(role.getOtherRole().getType()), getTypeFullName(role.getType())); }
protected String getRelationAwareTypeFor(Role role) { String elemType = getTypeFullName(role.getType()); String thisType = getTypeFullName(role.getOtherRole().getType()); return makeGenericType(getRelationAwareBaseTypeFor(role), thisType, elemType); }
protected void generateRelationGetter(String getterName, Role role, PrintWriter out) { String paramListType = makeGenericType("java.util.Set", getTypeFullName(role.getType())); generateRelationGetter(getterName, role, paramListType, out); }
protected String getCollectionTypeFor(Role role) { boolean indexed = (role.getIndexProperty() != null); boolean ordered = role.isOrdered(); if (indexed && ordered) { throw new Error("Can't handle roles that are both indexed and ordered"); } String elemsType = getTypeFullName(role.getType()); if (indexed) { // FIXME: the type of the key should correspond to the type of the index property return makeGenericType("java.util.Map", "java.lang.Object", elemsType); } else { return makeGenericType("java.util.Set", elemsType); } }
protected void generateStaticRoleSlotsMultOne(Role role, Role otherRole, PrintWriter out) { printMethod(out, "public", getTypeFullName(role.getType()), "getValue", makeArg(getTypeFullName(otherRole.getType()), "o1")); startMethodBody(out); generateStaticRoleSlotsMultOneGetterBody(role, otherRole, out); endMethodBody(out); printMethod(out, "public", "void", "setValue", makeArg(getTypeFullName(otherRole.getType()), "o1"), makeArg(getTypeFullName(role.getType()), "o2")); startMethodBody(out); generateStaticRoleSlotsMultOneSetterBody(role, otherRole, out); endMethodBody(out); }
protected void generateRoleSlotMethodsMultOne(Role role, PrintWriter out) { String typeName = getTypeFullName(role.getType()); String slotName = role.getName(); // public getter generateRoleSlotMethodsMultOneGetter(chooseVisibilityModifier(role), slotName, typeName, out); // public setter generateRoleSlotMethodsMultOneSetter(role, out); }
protected void generateRoleSlot(Role role, PrintWriter out) { onNewline(out); if (role.getMultiplicityUpper() == 1) { printWords(out, "private", getTypeFullName(role.getType()), role.getName()); } else { printWords(out, "private", getDefaultCollectionFor(role), role.getName()); } println(out, ";"); }
protected void generateRoleMethodGetInverseRole(Role role, Role otherRole, PrintWriter out) { // the getInverseRole method String inverseRoleType = makeGenericType("pt.ist.fenixframework.dml.runtime.Role", getTypeFullName(role.getType()), getTypeFullName(otherRole.getType())); printMethod(out, "public", inverseRoleType, "getInverseRole"); startMethodBody(out); print(out, "return "); if (otherRole.getName() == null) { print(out, "new "); print(out, getRoleType(otherRole)); print(out, "(this)"); } else { print(out, getRoleHandlerName(otherRole, true)); } print(out, ";"); endMethodBody(out); }
protected void generateStaticRoleSlotsMultStar(Role role, Role otherRole, PrintWriter out) { print(out, "public "); print(out, makeGenericType("pt.ist.fenixframework.dml.runtime.RelationBaseSet", getTypeFullName(role.getType()))); print(out, " "); print(out, "getSet("); print(out, getTypeFullName(otherRole.getType())); print(out, " o1)"); startMethodBody(out); print(out, "return (" + getConcreteSetTypeDeclarationFor(role) + ") (("); print(out, otherRole.getType().getBaseName()); print(out, ") o1)."); print(out, role.getName()); print(out, ";"); endMethodBody(out); }
protected void generateRoleSlotMethodsMultOneSetter(Role role, PrintWriter out) { String typeName = getTypeFullName(role.getType()); String slotName = role.getName(); String capitalizedSlotName = capitalize(slotName); String setterName = "set" + capitalizedSlotName; String methodModifiers = getMethodModifiers(role); newline(out); printMethod(out, methodModifiers, "void", setterName, makeArg(typeName, slotName)); startMethodBody(out); if (isDefaultCodeGenerator()) { printUnsupported(out); } else { generateRelationAddMethodCall(role, slotName, null, out); } endMethodBody(out); }
protected void generateRelationGetterBody(Role role, PrintWriter out) { print(out, "return "); print(out, "new "); print(out, getRelationAwareTypeFor(role)); print(out, "(("); print(out, getTypeFullName(role.getOtherRole().getType())); print(out, ")this, "); print(out, getRelationMethodNameFor(role)); print(out, ", "); print(out, role.getName()); print(out, ", "); print(out, "keyFunction$$"); print(out, role.getName()); print(out, ");"); }
"<" + getTypeFullName((isDirectRelation ? otherRole : role).getType()) + "," + getTypeFullName((isDirectRelation ? role : otherRole).getType()) + ">";
protected void generateRoleSlotMethodsMultStar(Role role, PrintWriter out) { boolean isOrdered = role.isOrdered(); String typeName = getTypeFullName(role.getType()); String slotName = role.getName(); String capitalizedSlotName = capitalize(slotName);
print(out, slotAccessExpression); println(out, ";"); print(out, getTypeFullName(role.getType())); println(out, " el1 = collection.get(index1);"); println(out, "collection.set(index1, collection.get(index2));");