From fb2d68ff3c95e833250cc056958c1f9fcc7136ce Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Thu, 10 Nov 2011 14:44:43 -0500 Subject: [PATCH] move newKey and newPath to Path from PathBuilder --- .../java/com/typesafe/config/impl/Path.java | 10 +++++++ .../com/typesafe/config/impl/PathBuilder.java | 10 ------- .../com/typesafe/config/impl/PathTest.scala | 28 +++++++++---------- .../com/typesafe/config/impl/TestUtils.scala | 4 +-- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/main/java/com/typesafe/config/impl/Path.java b/src/main/java/com/typesafe/config/impl/Path.java index d5364f3e..f256ef64 100644 --- a/src/main/java/com/typesafe/config/impl/Path.java +++ b/src/main/java/com/typesafe/config/impl/Path.java @@ -95,4 +95,14 @@ final class Path { appendToStringBuilder(sb); return sb.toString(); } + + static Path newKey(String key) { + return new Path(key, null); + } + + static Path newPath(String path) { + PathBuilder pb = new PathBuilder(); + pb.appendPath(path); + return pb.result(); + } } diff --git a/src/main/java/com/typesafe/config/impl/PathBuilder.java b/src/main/java/com/typesafe/config/impl/PathBuilder.java index 8b0a2e61..5dd8a4fe 100644 --- a/src/main/java/com/typesafe/config/impl/PathBuilder.java +++ b/src/main/java/com/typesafe/config/impl/PathBuilder.java @@ -54,14 +54,4 @@ final class PathBuilder { } return result; } - - static Path newPath(String path) { - PathBuilder pb = new PathBuilder(); - pb.appendPath(path); - return pb.result(); - } - - static Path newKey(String key) { - return new Path(key, null); - } } diff --git a/src/test/scala/com/typesafe/config/impl/PathTest.scala b/src/test/scala/com/typesafe/config/impl/PathTest.scala index e77b70cb..cded51ec 100644 --- a/src/test/scala/com/typesafe/config/impl/PathTest.scala +++ b/src/test/scala/com/typesafe/config/impl/PathTest.scala @@ -8,12 +8,12 @@ class PathTest extends TestUtils { @Test def pathEquality() { // note: foo.bar is a single key here - val a = PathBuilder.newKey("foo.bar") - val sameAsA = PathBuilder.newKey("foo.bar") - val differentKey = PathBuilder.newKey("hello") + val a = Path.newKey("foo.bar") + val sameAsA = Path.newKey("foo.bar") + val differentKey = Path.newKey("hello") // here foo.bar is two elements - val twoElements = PathBuilder.newPath("foo.bar") - val sameAsTwoElements = PathBuilder.newPath("foo.bar") + val twoElements = Path.newPath("foo.bar") + val sameAsTwoElements = Path.newPath("foo.bar") checkEqualObjects(a, a) checkEqualObjects(a, sameAsA) @@ -24,18 +24,18 @@ class PathTest extends TestUtils { @Test def pathToString() { - assertEquals("Path(foo)", PathBuilder.newPath("foo").toString()) - assertEquals("Path(foo.bar)", PathBuilder.newPath("foo.bar").toString()) - assertEquals("Path(foo.\"bar*\")", PathBuilder.newPath("foo.bar*").toString()) - assertEquals("Path(\"foo.bar\")", PathBuilder.newKey("foo.bar").toString()) + assertEquals("Path(foo)", Path.newPath("foo").toString()) + assertEquals("Path(foo.bar)", Path.newPath("foo.bar").toString()) + assertEquals("Path(foo.\"bar*\")", Path.newPath("foo.bar*").toString()) + assertEquals("Path(\"foo.bar\")", Path.newKey("foo.bar").toString()) } @Test def pathRender() { - assertEquals("foo", PathBuilder.newPath("foo").render()) - assertEquals("foo.bar", PathBuilder.newPath("foo.bar").render()) - assertEquals("foo.\"bar*\"", PathBuilder.newPath("foo.bar*").render()) - assertEquals("\"foo.bar\"", PathBuilder.newKey("foo.bar").render()) - assertEquals("foo bar", PathBuilder.newKey("foo bar").render()) + assertEquals("foo", Path.newPath("foo").render()) + assertEquals("foo.bar", Path.newPath("foo.bar").render()) + assertEquals("foo.\"bar*\"", Path.newPath("foo.bar*").render()) + assertEquals("\"foo.bar\"", Path.newKey("foo.bar").render()) + assertEquals("foo bar", Path.newKey("foo bar").render()) } } diff --git a/src/test/scala/com/typesafe/config/impl/TestUtils.scala b/src/test/scala/com/typesafe/config/impl/TestUtils.scala index 64086dad..11567d46 100644 --- a/src/test/scala/com/typesafe/config/impl/TestUtils.scala +++ b/src/test/scala/com/typesafe/config/impl/TestUtils.scala @@ -238,13 +238,13 @@ abstract trait TestUtils { } protected def subst(ref: String) = { - val pieces = java.util.Collections.singletonList[Object](PathBuilder.newPath(ref)) + val pieces = java.util.Collections.singletonList[Object](Path.newPath(ref)) new ConfigSubstitution(fakeOrigin(), pieces) } protected def substInString(ref: String) = { import scala.collection.JavaConverters._ - val pieces = List("start<", PathBuilder.newPath(ref), ">end") + val pieces = List("start<", Path.newPath(ref), ">end") new ConfigSubstitution(fakeOrigin(), pieces.asJava) }