@Test public void byNameAndAttributes_QName() { Element control = doc.createElement(FOO); control.setAttribute(BAR, BAR); Element equal = doc.createElement(FOO); equal.setAttribute(BAR, BAR); Element noAttributes = doc.createElement(FOO); Element differentValue = doc.createElement(FOO); differentValue.setAttribute(BAR, FOO); Element differentName = doc.createElement(FOO); differentName.setAttribute(FOO, FOO); Element differentNS = doc.createElement(FOO); differentNS.setAttributeNS(SOME_URI, BAR, BAR); assertTrue(ElementSelectors.byNameAndAttributes(new QName(BAR)) .canBeCompared(control, equal)); assertFalse(ElementSelectors.byNameAndAttributes(new QName(BAR)) .canBeCompared(control, noAttributes)); assertTrue(ElementSelectors.byNameAndAttributes(new QName(FOO)) .canBeCompared(control, noAttributes)); assertTrue(ElementSelectors.byNameAndAttributes(new QName[] {}) .canBeCompared(control, noAttributes)); assertFalse(ElementSelectors.byNameAndAttributes(new QName(BAR)) .canBeCompared(noAttributes, control)); assertFalse(ElementSelectors.byNameAndAttributes(new QName(BAR)) .canBeCompared(control, differentValue)); assertFalse(ElementSelectors.byNameAndAttributes(new QName(BAR)) .canBeCompared(control, differentName)); assertFalse(ElementSelectors.byNameAndAttributes(new QName(BAR)) .canBeCompared(control, differentNS)); }
public static ElementSelector byNameAndAttributes(String... attribs) { if (attribs == null) { throw new IllegalArgumentException(ATTRIBUTES_MUST_NOT_BE_NULL); } if (any(Arrays.asList(attribs), new IsNullPredicate())) { throw new IllegalArgumentException(ATTRIBUTES_MUST_NOT_CONTAIN_NULL_VALUES); } QName[] qs = new QName[attribs.length]; for (int i = 0; i < attribs.length; i++) { qs[i] = new QName(attribs[i]); } return byNameAndAttributes(qs); }
ElementSelectors { public static ElementSelector byNameAndAttributes(String... attribs) { if (attribs == null) { throw new IllegalArgumentException(ATTRIBUTES_MUST_NOT_BE_NULL); } if (any(Arrays.asList(attribs), new IsNullPredicate())) { throw new IllegalArgumentException(ATTRIBUTES_MUST_NOT_CONTAIN_NULL_VALUES); } QName[] qs = new QName[attribs.length]; for (int i = 0; i < attribs.length; i++) { qs[i] = new QName(attribs[i]); } return byNameAndAttributes(qs); } }
ElementSelectors { public static ElementSelector byNameAndAttributes(String... attribs) { if (attribs == null) { throw new IllegalArgumentException(ATTRIBUTES_MUST_NOT_BE_NULL); } if (any(Arrays.asList(attribs), new IsNullPredicate())) { throw new IllegalArgumentException(ATTRIBUTES_MUST_NOT_CONTAIN_NULL_VALUES); } QName[] qs = new QName[attribs.length]; for (int i = 0; i < attribs.length; i++) { qs[i] = new QName(attribs[i]); } return byNameAndAttributes(qs); } private  ElementSelectors(); }
ElementSelectors { public static ElementSelector byNameAndAttributes(String... attribs) { if (attribs == null) { throw new IllegalArgumentException(ATTRIBUTES_MUST_NOT_BE_NULL); } if (any(Arrays.asList(attribs), new IsNullPredicate())) { throw new IllegalArgumentException(ATTRIBUTES_MUST_NOT_CONTAIN_NULL_VALUES); } QName[] qs = new QName[attribs.length]; for (int i = 0; i < attribs.length; i++) { qs[i] = new QName(attribs[i]); } return byNameAndAttributes(qs); } private  ElementSelectors(); static ElementSelector byNameAndAttributes(String... attribs); static ElementSelector byNameAndAttributesControlNS(final String... attribs); static ElementSelector byNameAndAttributes(final QName... attribs); static ElementSelector not(final ElementSelector es); static ElementSelector or(final ElementSelector... selectors); static ElementSelector and(final ElementSelector... selectors); static ElementSelector xor(final ElementSelector es1,
                                      final ElementSelector es2); static ElementSelector conditionalSelector(final Predicate<? super Element> predicate,
                                                      final ElementSelector es); static ElementSelector selectorForElementNamed(final String expectedName,
                                                          final ElementSelector es); static ElementSelector selectorForElementNamed(final QName expectedName,
                                                          final ElementSelector es); static ElementSelector byXPath(String xpath, ElementSelector childSelector); static ElementSelector byXPath(final String xpath,
                                          Map<String, String> prefix2Uri,
                                          ElementSelector childSelector); static ConditionalSelectorBuilder conditionalBuilder(); }
ElementSelectors { public static ElementSelector byNameAndAttributes(String... attribs) { if (attribs == null) { throw new IllegalArgumentException(ATTRIBUTES_MUST_NOT_BE_NULL); } if (any(Arrays.asList(attribs), new IsNullPredicate())) { throw new IllegalArgumentException(ATTRIBUTES_MUST_NOT_CONTAIN_NULL_VALUES); } QName[] qs = new QName[attribs.length]; for (int i = 0; i < attribs.length; i++) { qs[i] = new QName(attribs[i]); } return byNameAndAttributes(qs); } private  ElementSelectors(); static ElementSelector byNameAndAttributes(String... attribs); static ElementSelector byNameAndAttributesControlNS(final String... attribs); static ElementSelector byNameAndAttributes(final QName... attribs); static ElementSelector not(final ElementSelector es); static ElementSelector or(final ElementSelector... selectors); static ElementSelector and(final ElementSelector... selectors); static ElementSelector xor(final ElementSelector es1,
                                      final ElementSelector es2); static ElementSelector conditionalSelector(final Predicate<? super Element> predicate,
                                                      final ElementSelector es); static ElementSelector selectorForElementNamed(final String expectedName,
                                                          final ElementSelector es); static ElementSelector selectorForElementNamed(final QName expectedName,
                                                          final ElementSelector es); static ElementSelector byXPath(String xpath, ElementSelector childSelector); static ElementSelector byXPath(final String xpath,
                                          Map<String, String> prefix2Uri,
                                          ElementSelector childSelector); static ConditionalSelectorBuilder conditionalBuilder(); static final ElementSelector Default; static final ElementSelector byName; static final ElementSelector byNameAndText; static final ElementSelector byNameAndAllAttributes; }