Remove arbitrary separator/wildcard from PathTrie
PathTrie has a constructor that allows for an arbitrary separtor and wildcard, but this constructor is unused and internally we always use '/' as the separator and '*' as the wildcard. There are no tests for the case where the separator differs from the default separator and wildcard. This commit removes this constructor and now all instances of PathTrie have the default separator and wildcard.
This commit is contained in:
parent
2dea449949
commit
9fe5ce9342
|
@ -25,9 +25,6 @@ import java.util.Map;
|
||||||
import static java.util.Collections.emptyMap;
|
import static java.util.Collections.emptyMap;
|
||||||
import static java.util.Collections.unmodifiableMap;
|
import static java.util.Collections.unmodifiableMap;
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class PathTrie<T> {
|
public class PathTrie<T> {
|
||||||
|
|
||||||
public interface Decoder {
|
public interface Decoder {
|
||||||
|
@ -36,18 +33,14 @@ public class PathTrie<T> {
|
||||||
|
|
||||||
private final Decoder decoder;
|
private final Decoder decoder;
|
||||||
private final TrieNode root;
|
private final TrieNode root;
|
||||||
private final String separator;
|
|
||||||
private T rootValue;
|
private T rootValue;
|
||||||
|
|
||||||
public PathTrie(Decoder decoder) {
|
private static final String SEPARATOR = "/";
|
||||||
this('/', "*", decoder);
|
private static final String WILDCARD = "*";
|
||||||
}
|
|
||||||
|
|
||||||
public PathTrie(char separator, String wildcard, Decoder decoder) {
|
public PathTrie(Decoder decoder) {
|
||||||
this.decoder = decoder;
|
this.decoder = decoder;
|
||||||
final String separatorAsString = new String(new char[]{separator});
|
root = new TrieNode(SEPARATOR, null, WILDCARD);
|
||||||
this.separator = separatorAsString;
|
|
||||||
root = new TrieNode(separatorAsString, null, wildcard);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TrieNode {
|
public class TrieNode {
|
||||||
|
@ -195,7 +188,7 @@ public class PathTrie<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void insert(String path, T value) {
|
public void insert(String path, T value) {
|
||||||
String[] strings = path.split(separator);
|
String[] strings = path.split(SEPARATOR);
|
||||||
if (strings.length == 0) {
|
if (strings.length == 0) {
|
||||||
rootValue = value;
|
rootValue = value;
|
||||||
return;
|
return;
|
||||||
|
@ -216,7 +209,7 @@ public class PathTrie<T> {
|
||||||
if (path.length() == 0) {
|
if (path.length() == 0) {
|
||||||
return rootValue;
|
return rootValue;
|
||||||
}
|
}
|
||||||
String[] strings = path.split(separator);
|
String[] strings = path.split(SEPARATOR);
|
||||||
if (strings.length == 0) {
|
if (strings.length == 0) {
|
||||||
return rootValue;
|
return rootValue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue