public String destinationName(EntityReference reference) { if (reference.getListDestination() != null) { return reference.getListDestination().getName(); } else { return reference.getSingleDestination().getName(); } }
public String setterName(EntityReference r) { return "set" + firstLetterUp(r.getName()); }
public String removeNameCollection(EntityReference reference) { String suffix = firstLetterUp(reference.getName()); return "remove" + suffix; }
public String removeName(EntityReference reference) { String suffix = firstLetterUp(reference.getName()); if (suffix.endsWith("s")) suffix = suffix.substring(0, suffix.length() - 1); return "remove" + suffix; }
public boolean isListReference(EntityReference reference) { return reference.getListDestination() != null; }
public String referenceType(EntityReference reference) { if (reference.getListDestination() != null) return ReferenceType.LIST.name(); return ReferenceType.SINGLE.name(); }
private String getInverseNameImpl(EntityReference reference) { if (reference.getInverseName() != null) return reference.getInverseName(); String destinationName = destinationName(reference); Entity entity = (Entity) reference.eContainer(); Model model = (Model) entity.eContainer().eContainer(); Entity destinationEntity = searchEntity(model, destinationName); for (EntityReference destinationEntityReference : destinationEntity.getReferences()) { Entity destEntity; if (destinationEntityReference.getListDestination() != null) destEntity = destinationEntityReference.getListDestination(); else destEntity = destinationEntityReference.getSingleDestination(); if (!destEntity.equals(entity)) continue; if (destinationEntityReference.getInverseName() == null) continue; if (destinationEntityReference.getInverseName().equals(reference.getName())) return destinationEntityReference.getName(); } return null; }
public String entityName(EntityReference entityReference) { Entity entity = (Entity) entityReference.eContainer(); return entity.getName(); }
public String staticName(EntityReference reference) { StringBuilder result = allUpperCase(reference.getName()); return result.toString(); }