From 98fcf6a799b0a72d91e85109c26ab5e6019dd3bf Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Mon, 11 Jul 2022 11:45:59 +0300 Subject: [PATCH] #103 deps polished --- pom.xml | 5 +++++ src/main/java/org/xembly/Directives.java | 4 ++-- src/main/java/org/xembly/ParsingException.java | 8 -------- src/main/java/org/xembly/RemoveDirective.java | 2 +- src/main/java/org/xembly/Xembler.java | 2 +- src/main/java/org/xembly/XmlContentException.java | 9 --------- src/main/java/org/xembly/XpathDirective.java | 7 +------ src/test/java/org/xembly/AddIfDirectiveTest.java | 3 +-- src/test/java/org/xembly/AttrDirectiveTest.java | 5 ++--- src/test/java/org/xembly/PiDirectiveTest.java | 3 +-- src/test/java/org/xembly/RemoveDirectiveTest.java | 3 +-- src/test/java/org/xembly/SetDirectiveTest.java | 3 +-- src/test/java/org/xembly/XemblerTest.java | 12 +++--------- src/test/java/org/xembly/XpathDirectiveTest.java | 4 ++-- src/test/java/org/xembly/XsetDirectiveTest.java | 3 +-- 15 files changed, 22 insertions(+), 51 deletions(-) diff --git a/pom.xml b/pom.xml index 099a7ed..7a8187e 100644 --- a/pom.xml +++ b/pom.xml @@ -93,6 +93,11 @@ OF THE POSSIBILITY OF SUCH DAMAGE. lombok 1.18.24 + + org.antlr + antlr4-runtime + 4.9.2 + org.mockito mockito-core diff --git a/src/main/java/org/xembly/Directives.java b/src/main/java/org/xembly/Directives.java index c105b4b..1bb6063 100644 --- a/src/main/java/org/xembly/Directives.java +++ b/src/main/java/org/xembly/Directives.java @@ -234,8 +234,8 @@ public Directives append(final Iterable dirs) { * Appends the {@link Node node}. * @param node The node to append * @return This object - * @see #append(java.lang.Iterable) - * @see Directives#copyOf(org.w3c.dom.Node) + * @see #append(Iterable) + * @see Directives#copyOf(Node) * @since 0.23 */ public Directives append(final Node node) { diff --git a/src/main/java/org/xembly/ParsingException.java b/src/main/java/org/xembly/ParsingException.java index f2f7014..0425c3e 100644 --- a/src/main/java/org/xembly/ParsingException.java +++ b/src/main/java/org/xembly/ParsingException.java @@ -41,14 +41,6 @@ final class ParsingException extends RuntimeException { */ private static final long serialVersionUID = 0x6547f999eaf6efb9L; - /** - * Public ctor. - * @param cause Cause of it - */ - ParsingException(final String cause) { - super(cause); - } - /** * Public ctor. * @param cause Cause of it diff --git a/src/main/java/org/xembly/RemoveDirective.java b/src/main/java/org/xembly/RemoveDirective.java index f781719..1f54dbb 100644 --- a/src/main/java/org/xembly/RemoveDirective.java +++ b/src/main/java/org/xembly/RemoveDirective.java @@ -69,7 +69,7 @@ public Directive.Cursor exec(final Node dom, @SuppressWarnings("aibolit.P13") private static Node parent(final Node node) { final Node parent; - if (node.getNodeType() == Node.ATTRIBUTE_NODE) { + if ((int) node.getNodeType() == (int) Node.ATTRIBUTE_NODE) { final Attr attr = Attr.class.cast(node); parent = attr.getOwnerElement(); Element.class.cast(parent).removeAttributeNode(attr); diff --git a/src/main/java/org/xembly/Xembler.java b/src/main/java/org/xembly/Xembler.java index c9f9ac2..8de3133 100644 --- a/src/main/java/org/xembly/Xembler.java +++ b/src/main/java/org/xembly/Xembler.java @@ -76,7 +76,7 @@ * a necessity to catch checked exceptions. * Use {@code *Quietly()} methods for that: * {@link #xmlQuietly()}, {@link #domQuietly()}, - * and {@link #applyQuietly(org.w3c.dom.Node)}. + * and {@link #applyQuietly(Node)}. * * @since 0.1 * @checkstyle ClassDataAbstractionCouplingCheck (500 lines) diff --git a/src/main/java/org/xembly/XmlContentException.java b/src/main/java/org/xembly/XmlContentException.java index 9ec62cb..b6a08aa 100644 --- a/src/main/java/org/xembly/XmlContentException.java +++ b/src/main/java/org/xembly/XmlContentException.java @@ -49,13 +49,4 @@ final class XmlContentException extends Exception { super(cause); } - /** - * Public ctor. - * @param cause Cause of it - * @param thr Original throwable - */ - XmlContentException(final String cause, final Throwable thr) { - super(cause, thr); - } - } diff --git a/src/main/java/org/xembly/XpathDirective.java b/src/main/java/org/xembly/XpathDirective.java index ab00656..b24f303 100644 --- a/src/main/java/org/xembly/XpathDirective.java +++ b/src/main/java/org/xembly/XpathDirective.java @@ -58,12 +58,7 @@ final class XpathDirective implements Directive { * XPath factory. */ private static final ThreadLocal FACTORY = - new ThreadLocal() { - @Override - protected XPathFactory initialValue() { - return XPathFactory.newInstance(); - } - }; + ThreadLocal.withInitial(XPathFactory::newInstance); /** * Pattern to match root-only XPath queries. diff --git a/src/test/java/org/xembly/AddIfDirectiveTest.java b/src/test/java/org/xembly/AddIfDirectiveTest.java index 9d467a6..418e28e 100644 --- a/src/test/java/org/xembly/AddIfDirectiveTest.java +++ b/src/test/java/org/xembly/AddIfDirectiveTest.java @@ -36,7 +36,6 @@ import org.junit.jupiter.api.Test; import org.w3c.dom.Document; import org.w3c.dom.Element; -import org.w3c.dom.Node; /** * Test case for {@link AddIfDirective}. @@ -83,7 +82,7 @@ public void addsDomNodesDirectly() throws Exception { root.appendChild(dom.createProcessingInstruction("a12", "22")); dom.appendChild(root); new AddIfDirective("b").exec( - dom, new DomCursor(Collections.singleton(root)), + dom, new DomCursor(Collections.singleton(root)), new DomStack() ); MatcherAssert.assertThat( diff --git a/src/test/java/org/xembly/AttrDirectiveTest.java b/src/test/java/org/xembly/AttrDirectiveTest.java index 9ac57d4..c40b910 100644 --- a/src/test/java/org/xembly/AttrDirectiveTest.java +++ b/src/test/java/org/xembly/AttrDirectiveTest.java @@ -37,7 +37,6 @@ import org.junit.jupiter.api.Test; import org.w3c.dom.Document; import org.w3c.dom.Element; -import org.w3c.dom.Node; /** * Test case for {@link AddDirective}. @@ -88,7 +87,7 @@ public void addsDomAttributesDirectly() throws Exception { root.appendChild(second); dom.appendChild(root); new AttrDirective("x", "y").exec( - dom, new DomCursor(Collections.singletonList(second)), + dom, new DomCursor(Collections.singletonList(second)), new DomStack() ); MatcherAssert.assertThat( @@ -109,7 +108,7 @@ public void addsCaseSensitiveAttributesDirectly() throws Exception { final Element root = dom.createElement("f"); dom.appendChild(root); new AttrDirective("Price", "\u20ac50").exec( - dom, new DomCursor(Collections.singletonList(root)), + dom, new DomCursor(Collections.singletonList(root)), new DomStack() ); MatcherAssert.assertThat( diff --git a/src/test/java/org/xembly/PiDirectiveTest.java b/src/test/java/org/xembly/PiDirectiveTest.java index 28a1512..fe77a3b 100644 --- a/src/test/java/org/xembly/PiDirectiveTest.java +++ b/src/test/java/org/xembly/PiDirectiveTest.java @@ -38,7 +38,6 @@ import org.junit.jupiter.api.Test; import org.w3c.dom.Document; import org.w3c.dom.Element; -import org.w3c.dom.Node; /** * Test case for {@link PiDirective}. @@ -84,7 +83,7 @@ public void addsProcessingInstructionsDirectlyToDom() throws Exception { final Element root = dom.createElement("xxx"); dom.appendChild(root); new PiDirective("x", "y").exec( - dom, new DomCursor(Collections.emptyList()), + dom, new DomCursor(Collections.emptyList()), new DomStack() ); MatcherAssert.assertThat( diff --git a/src/test/java/org/xembly/RemoveDirectiveTest.java b/src/test/java/org/xembly/RemoveDirectiveTest.java index 2319930..2209662 100644 --- a/src/test/java/org/xembly/RemoveDirectiveTest.java +++ b/src/test/java/org/xembly/RemoveDirectiveTest.java @@ -37,7 +37,6 @@ import org.junit.jupiter.api.Test; import org.w3c.dom.Document; import org.w3c.dom.Element; -import org.w3c.dom.Node; /** * Test case for {@link RemoveDirective}. @@ -88,7 +87,7 @@ public void removesDomNodesDirectly() throws Exception { root.appendChild(second); dom.appendChild(root); new RemoveDirective().exec( - dom, new DomCursor(Collections.singletonList(first)), + dom, new DomCursor(Collections.singletonList(first)), new DomStack() ); MatcherAssert.assertThat( diff --git a/src/test/java/org/xembly/SetDirectiveTest.java b/src/test/java/org/xembly/SetDirectiveTest.java index 27c0274..874b9ef 100644 --- a/src/test/java/org/xembly/SetDirectiveTest.java +++ b/src/test/java/org/xembly/SetDirectiveTest.java @@ -38,7 +38,6 @@ import org.junit.jupiter.api.Test; import org.w3c.dom.Document; import org.w3c.dom.Element; -import org.w3c.dom.Node; /** * Test case for {@link SetDirective}. @@ -99,7 +98,7 @@ public void setsTextDirectlyIntoDomNodes() throws Exception { root.appendChild(second); dom.appendChild(root); new SetDirective("alpha").exec( - dom, new DomCursor(Arrays.asList(first, second)), + dom, new DomCursor(Arrays.asList(first, second)), new DomStack() ); MatcherAssert.assertThat( diff --git a/src/test/java/org/xembly/XemblerTest.java b/src/test/java/org/xembly/XemblerTest.java index 6697eef..64fefb4 100644 --- a/src/test/java/org/xembly/XemblerTest.java +++ b/src/test/java/org/xembly/XemblerTest.java @@ -274,14 +274,8 @@ public void concurrentInvocationWithNoExceptions() throws Exception { * @param document DOM object * @return Callable object */ - private static Callable callable( - final Xembler xembler, final Node document - ) { - return new Callable() { - @Override - public Node call() throws Exception { - return xembler.apply(document); - } - }; + private static Callable callable(final Xembler xembler, + final Node document) { + return () -> xembler.apply(document); } } diff --git a/src/test/java/org/xembly/XpathDirectiveTest.java b/src/test/java/org/xembly/XpathDirectiveTest.java index 358d071..a3d7db0 100644 --- a/src/test/java/org/xembly/XpathDirectiveTest.java +++ b/src/test/java/org/xembly/XpathDirectiveTest.java @@ -110,7 +110,7 @@ public void findsNodesByXpathDirectly() throws Exception { MatcherAssert.assertThat( new XpathDirective("/*").exec( dom, - new DomCursor(Collections.singletonList(first)), + new DomCursor(Collections.singletonList(first)), new DomStack() ), Matchers.hasItem(root) @@ -128,7 +128,7 @@ public void findsNodesInEmptyDom() throws Exception { MatcherAssert.assertThat( new XpathDirective("/some-root").exec( dom, - new DomCursor(Collections.emptyList()), + new DomCursor(Collections.emptyList()), new DomStack() ), Matchers.emptyIterable() diff --git a/src/test/java/org/xembly/XsetDirectiveTest.java b/src/test/java/org/xembly/XsetDirectiveTest.java index 206ffa0..f867185 100644 --- a/src/test/java/org/xembly/XsetDirectiveTest.java +++ b/src/test/java/org/xembly/XsetDirectiveTest.java @@ -37,7 +37,6 @@ import org.junit.jupiter.api.Test; import org.w3c.dom.Document; import org.w3c.dom.Element; -import org.w3c.dom.Node; /** * Test case for {@link XsetDirective}. @@ -92,7 +91,7 @@ public void setsTextDirectlyIntoDomNodes() throws Exception { root.appendChild(second); dom.appendChild(root); new XsetDirective("sum(/xxx/*/text()) + 5").exec( - dom, new DomCursor(Collections.singletonList(first)), + dom, new DomCursor(Collections.singletonList(first)), new DomStack() ); MatcherAssert.assertThat(