/** Returns AttributeGroup corresponding to the passed (possibly nested) attribute. */ public CoreAttributeGroup getGroup(String attributeNameOrPath) { CoreAttributeItem item = getItem(CoreAttributeConverter.convert(attributeNameOrPath), false); if (item != null) { return item.getGroup(); } if (hasInheritance()) { return this.superClassGroup.getGroup(attributeNameOrPath); } return null; }
/** Return if the attribute is defined in the group. */ public boolean containsAttribute(String attributeNameOrPath) { String[] path = CoreAttributeConverter.convert(attributeNameOrPath); if (getItem(path, false) != null) { return true; } if (this.hasInheritance() && this.superClassGroup != null) { return this.superClassGroup.containsAttribute(attributeNameOrPath); } return false; }
/** * INTERNAL: Lookup the {@link org.eclipse.persistence.internal.queries.AttributeItem * AttributeItem} for the provided attribute name or path. * * @return item or null * @throws IllegalArgumentException if name is not valid attribute name or path */ public ATTRIBUTE_ITEM getItem(String attributeNameOrPath) { return getItem(CoreAttributeConverter.convert(attributeNameOrPath), false); }
// Old prototype to keep 2.5 API. Use CoreAttributeConverter.convert internally. protected String[] convert(String... nameOrPath) { return CoreAttributeConverter.convert(nameOrPath); }
/** * Add a basic attribute or nested attribute with each String representing the key of an attribute * of type Map on the path to what needs to be included in the AttributeGroup. * * <p>Example: <code> * group.addAttribute("firstName", group1);<br> * group.addAttribute("manager.address", group2); * </code> Note that existing group corresponding to attributeNameOrPath will be overridden with * the passed group. * * @param attributeNameOrPath A simple attribute, array or attributes forming a path to a Map key * @param group - an AttributeGroup to be added. */ public void addAttributeKey(String attributeNameOrPath, CoreAttributeGroup group) { CoreAttributeItem item = getItem(CoreAttributeConverter.convert(attributeNameOrPath), true); item.addKeyGroup(group); }
/** * Add an attribute and the corresponding list of AttributeGroups. Multiple groups are added in * the case of inheritance * * <p> * * @param attributeNameOrPath A simple attribute, array or attributes forming a path * @param groups - a collection of AttributeGroups to be added. */ public void addAttribute( String attributeNameOrPath, Collection<? extends CoreAttributeGroup> groups) { CoreAttributeItem item = getItem(CoreAttributeConverter.convert(attributeNameOrPath), true); item.addGroups(groups); }