/** * If propertyDefinition.order is <= 0 or > Map.size() it will be set to the current number of * propDefs for the map (placing it at the end). Otherwise, it will be inserted, incrementing the * order of existing Map entries. * * @param propertyDefinition */ public void put(PropertyDefinition propertyDefinition) { Map<String, PropertyDefinition> map = getMap(); if (map.isEmpty()) { propertyDefinition.setOrder(0); } else { int order = propertyDefinition.getOrder(); int size = map.size(); if ((order <= 0) || (order >= size)) { propertyDefinition.setOrder(size); } else { // insert into existing ordering by bumping up existing entries for (PropertyDefinition p : map.values()) { if (p.getOrder() >= order) { p.setOrder(p.getOrder() + 1); } } } } map.put(propertyDefinition.getName(), propertyDefinition); propertyDefinition.setParentPropertyMapDefinition(this); }