@Override protected String getRelationAwareBaseTypeFor(Role role) { if (role.isIndexed() && role.getIndexCardinality() == Role.MULTIPLICITY_MANY) { return RelationMulValuesIndexedAwareSet.class.getName(); } else { return super.getRelationAwareBaseTypeFor(role); } }
private String getSearchForKey(Role role, String retType) { boolean indexMult = role.isIndexed() && role.getIndexCardinality() == Role.MULTIPLICITY_MANY; String fetchMethod = "get" + (indexMult ? "Values" : ""); return "((" + getRelationAwareTypeFor(role) + ") get" + capitalize(role.getName()) + "Set())." + fetchMethod + "(key)"; }
@Override protected String getDefaultCollectionGetterFor(Role role) { if (role.isIndexed() && role.getIndexCardinality() == Role.MULTIPLICITY_MANY) { return makeGenericType(DomainBasedMap.Getter.class.getCanonicalName(), makeGenericType(LINKED_LIST_FULL_CLASS, getTypeFullName(role.getType()))); } else { return super.getDefaultCollectionGetterFor(role); } }
@Override protected String getDefaultCollectionFor(Role role) { if (role.isIndexed() && role.getIndexCardinality() == Role.MULTIPLICITY_MANY) { return makeGenericType(getCollectionToUse(), makeGenericType(LINKED_LIST_FULL_CLASS, role.getType().getFullName())); } else { return super.getDefaultCollectionFor(role); } }
@Override protected void generateStaticKeyFunctionForRole(Role role, PrintWriter out) { if (role.isIndexed()) { onNewline(out); Slot indexedSlot = getIndexedSlot(role); String keyField = role.getIndexProperty(); println(out, generateMapKeyFunction(role.getName(), role.getType().getFullName(), indexedSlot.getSlotType().getFullname(), keyField, role.getIndexCardinality() == Role.MULTIPLICITY_MANY)); onNewline(out); } else { super.generateStaticKeyFunctionForRole(role, out); } }
protected void generateRoleSlotMethodsMultStarIndexed(Role role, PrintWriter out, String methodModifiers, String capitalizedSlotName, String slotAccessExpression, String typeName, String slotName) { Slot indexedSlot = getIndexedSlot(role); String keyField = role.getIndexProperty(); String retType = role.getType().getFullName(); String methodNameSufix = ""; boolean haveMany = role.getIndexCardinality() == Role.MULTIPLICITY_MANY; if (haveMany) { retType = makeGenericType("java.util.Set", retType); } onNewline(out); printMethod(out, "public", retType, "get" + capitalize(role.getName()) + "By" + capitalize(keyField) + methodNameSufix, indexedSlot.getSlotType().getFullname() + " key"); startMethodBody(out); printWords(out, "return", getSearchForKey(role, haveMany ? getCollectionToUse() : retType)); print(out, ";"); endMethodBody(out); }