Skip to content

Commit

Permalink
Fix Qulice warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
kniazkov committed Feb 27, 2024
1 parent 866b577 commit 0dbbde9
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
*
* @since 1.1.0
*/
class BottomUpMappingAlgorithm {
@SuppressWarnings("PMD.TooManyMethods")
class BottomUpAlgorithm {
/**
* Set of node hashes.
*/
Expand Down Expand Up @@ -96,7 +97,7 @@ class BottomUpMappingAlgorithm {
* @param left Root node of the 'left' tree
* @param right Root node of the 'right' tree
*/
BottomUpMappingAlgorithm(final Node left, final Node right) {
BottomUpAlgorithm(final Node left, final Node right) {
this.hashes = new AbsoluteHash();
this.depth = new Depth();
this.parents = new HashMap<>();
Expand Down Expand Up @@ -128,27 +129,7 @@ void execute() {
* @return Result of mapping
*/
Mapping getResult() {
return new Mapping() {
@Override
public Node getRight(final Node node) {
return BottomUpMappingAlgorithm.this.ltr.get(node);
}

@Override
public Node getLeft(final Node node) {
return BottomUpMappingAlgorithm.this.rtl.get(node);
}

@Override
public Map<Node, Node> getReplaced() {
return Collections.unmodifiableMap(BottomUpMappingAlgorithm.this.replaced);
}

@Override
public Set<Node> getDeleted() {
return Collections.unmodifiableSet(BottomUpMappingAlgorithm.this.deleted);
}
};
return new Result(this);
}

/**
Expand Down Expand Up @@ -362,4 +343,44 @@ private void mapChildrenIfDeleted(final Node before) {
}
}
}

/**
* Mapping result.
*
* @since 1.1.0
*/
private static final class Result implements Mapping {
/**
* Structure from which the mapping results can be taken.
*/
private final BottomUpAlgorithm data;

/**
* Constructor.
* @param data Structure from which the mapping results can be taken
*/
private Result(final BottomUpAlgorithm data) {
this.data = data;
}

@Override
public Node getRight(final Node node) {
return this.data.ltr.get(node);
}

@Override
public Node getLeft(final Node node) {
return this.data.rtl.get(node);
}

@Override
public Map<Node, Node> getReplaced() {
return Collections.unmodifiableMap(this.data.replaced);
}

@Override
public Set<Node> getDeleted() {
return Collections.unmodifiableSet(this.data.deleted);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
public final class BottomUpMapper implements Mapper {
@Override
public Mapping map(final Node left, final Node right) {
final BottomUpMappingAlgorithm algorithm = new BottomUpMappingAlgorithm(left, right);
final BottomUpAlgorithm algorithm = new BottomUpAlgorithm(left, right);
algorithm.execute();
return algorithm.getResult();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
*
* @since 1.1.0
*/
@SuppressWarnings("PMD.ProhibitPublicStaticMethods")
@SuppressWarnings({"PMD.ProhibitPublicStaticMethods", "PMD.TooManyMethods"})
public final class LittleTrees {
/**
* Private constructor.
Expand Down

0 comments on commit 0dbbde9

Please sign in to comment.