Skip to content

Commit

Permalink
#473 - Decreased class data abstraction coupling.
Browse files Browse the repository at this point in the history
  • Loading branch information
vzurauskas committed Jun 11, 2020
1 parent 3846ce0 commit 89453f2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 39 deletions.
8 changes: 3 additions & 5 deletions src/main/java/org/jpeek/graph/XmlGraph.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
package org.jpeek.graph;

import com.jcabi.xml.XML;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import org.cactoos.list.ListOf;
Expand Down Expand Up @@ -71,11 +70,10 @@ public List<Node> nodes() {
* @param pname Package of the class this graph is for
* @param cname Class in the skeleton this graph is for
* @return List of nodes
* @throws IOException If fails
*/
private static List<Node> build(
final Skeleton skeleton, final String pname, final String cname
) throws IOException {
) {
final Map<XML, Node> byxml = new org.cactoos.map.Sticky<>(
method -> method,
method -> new Node.Simple(
Expand All @@ -85,7 +83,7 @@ private static List<Node> build(
new Joined("", "//package[@id=", pname).toString()
).get(0)
.nodes(
new Joined("", "//class[@id=" + cname).toString()
new Joined("", "//class[@id=", cname).toString()
).get(0),
method
).asString()
Expand All @@ -103,7 +101,7 @@ private static List<Node> build(
final List<XML> calls = entry.getKey().nodes("ops/op[@code='call']");
final Node caller = entry.getValue();
for (final XML call : calls) {
final String name = new XmlMethodCall(call).asString();
final String name = new XmlMethodCall(call).toString();
if (byname.containsKey(name)) {
final Node callee = byname.get(name);
caller.connections().add(callee);
Expand Down
20 changes: 3 additions & 17 deletions src/main/java/org/jpeek/graph/XmlMethodArgs.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,36 +24,22 @@
package org.jpeek.graph;

import com.jcabi.xml.XML;
import java.io.IOException;
import org.cactoos.Text;
import org.cactoos.text.Joined;
import org.cactoos.text.TextEnvelope;

/**
* Serialize method arguments to a string.
*
* @since 1.0
*/
public final class XmlMethodArgs implements Text {

/**
* XML Method.
*/
private final XML method;
public final class XmlMethodArgs extends TextEnvelope {

/**
* Ctor.
*
* @param method Method as XML
*/
XmlMethodArgs(final XML method) {
this.method = method;
}

@Override
public String asString() throws IOException {
return new Joined(
":",
this.method.xpath("args/arg/@type")
).asString();
super(new Joined(":", method.xpath("args/arg/@type")));
}
}
25 changes: 8 additions & 17 deletions src/main/java/org/jpeek/graph/XmlMethodCall.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,36 +24,27 @@
package org.jpeek.graph;

import com.jcabi.xml.XML;
import java.io.IOException;
import org.cactoos.Text;
import org.cactoos.text.Joined;
import org.cactoos.text.TextEnvelope;

/**
* Serialize method call to a string.
*
* @since 1.0
*/
public final class XmlMethodCall implements Text {

/**
* XML Call operation.
*/
private final XML call;
public final class XmlMethodCall extends TextEnvelope {

/**
* Ctor.
*
* @param call Call operation as XML.
*/
XmlMethodCall(final XML call) {
this.call = call;
}

@Override
public String asString() throws IOException {
return new Joined(
"", this.call.xpath("op/name/text()").get(0),
".", new XmlMethodArgs(this.call.nodes("op").get(0)).asString()
).asString();
super(
new Joined(
"", call.xpath("op/name/text()").get(0),
".", new XmlMethodArgs(call.nodes("op").get(0)).toString()
)
);
}
}

0 comments on commit 89453f2

Please # to comment.