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:
Jason Tedor 2016-05-04 09:18:30 -04:00
parent 2dea449949
commit 9fe5ce9342
1 changed files with 6 additions and 13 deletions

View File

@ -25,9 +25,6 @@ import java.util.Map;
import static java.util.Collections.emptyMap;
import static java.util.Collections.unmodifiableMap;
/**
*
*/
public class PathTrie<T> {
public interface Decoder {
@ -36,18 +33,14 @@ public class PathTrie<T> {
private final Decoder decoder;
private final TrieNode root;
private final String separator;
private T rootValue;
public PathTrie(Decoder decoder) {
this('/', "*", decoder);
}
private static final String SEPARATOR = "/";
private static final String WILDCARD = "*";
public PathTrie(char separator, String wildcard, Decoder decoder) {
public PathTrie(Decoder decoder) {
this.decoder = decoder;
final String separatorAsString = new String(new char[]{separator});
this.separator = separatorAsString;
root = new TrieNode(separatorAsString, null, wildcard);
root = new TrieNode(SEPARATOR, null, WILDCARD);
}
public class TrieNode {
@ -195,7 +188,7 @@ public class PathTrie<T> {
}
public void insert(String path, T value) {
String[] strings = path.split(separator);
String[] strings = path.split(SEPARATOR);
if (strings.length == 0) {
rootValue = value;
return;
@ -216,7 +209,7 @@ public class PathTrie<T> {
if (path.length() == 0) {
return rootValue;
}
String[] strings = path.split(separator);
String[] strings = path.split(SEPARATOR);
if (strings.length == 0) {
return rootValue;
}