public static List<? extends DomElement> getIdentitySiblings(DomElement element) { final GenericDomValue nameDomElement = element.getGenericInfo().getNameDomElement(element); if (nameDomElement == null) return Collections.emptyList(); final NameValue nameValue = nameDomElement.getAnnotation(NameValue.class); if (nameValue == null || !nameValue.unique()) return Collections.emptyList(); final String stringValue = ElementPresentationManager.getElementName(element); if (stringValue == null) return Collections.emptyList(); final DomElement scope = element.getManager().getIdentityScope(element); if (scope == null) return Collections.emptyList(); final DomGenericInfo domGenericInfo = scope.getGenericInfo(); final String tagName = element.getXmlElementName(); final DomCollectionChildDescription childDescription = domGenericInfo.getCollectionChildDescription(tagName, element.getXmlElementNamespaceKey()); if (childDescription != null) { final ArrayList<DomElement> list = new ArrayList<>(childDescription.getValues(scope)); list.remove(element); return list; } return Collections.emptyList(); }
@Nullable public static DomElement findDuplicateNamedValue(DomElement element, String newName) { return ElementPresentationManager.findByName(getIdentitySiblings(element), newName); }