Migrate away from a magic slash to a constant.
My code currently resembles:
return '/' + reference.replace( getConfigSeparator(), '/' );
I'd rather that it resemble:
import static JsonPointer.SEPARATOR;
return SEPARATOR + reference.replace( getConfigSeparator(), SEPARATOR );
That way if JsonPointer ever changed its segment separator character (or added a configuration option for changing it), then my code won't have to change. Also, making a single location for the slash character follows the DRY principle while avoiding a magic value littered throughout the code.
diff --git a/src/main/java/com/fasterxml/jackson/core/JsonPointer.java b/src/main/java/com/fasterxml/jackson/core/JsonPointer.java
index f927336..d731f5b 100644
--- a/src/main/java/com/fasterxml/jackson/core/JsonPointer.java
+++ b/src/main/java/com/fasterxml/jackson/core/JsonPointer.java
@@ -20,6 +20,11 @@
public class JsonPointer
{
/**
+ * Character used to separate segments.
+ */
+ public final static char SEPARATOR = '/';
+
+ /**
* Marker instance used to represent segment that matches current
* node or position (that is, returns true for
* {@link #matches()}).