public JsonContext(final JsonSerializer jsonSerializer, final Appendable appendable) { super(appendable, jsonSerializer.strictStringEncoding); this.jsonSerializer = jsonSerializer; this.bag = new ArrayList<>(); this.path = new Path(); this.excludeNulls = jsonSerializer.excludeNulls; this.excludeEmpty = jsonSerializer.excludeEmpty; this.serializerResolver = jsonSerializer.serializerResolver; }
@Override public Path clone() { CharSequence[] clonedPaths = new CharSequence[paths.length]; System.arraycopy(paths, 0, clonedPaths, 0, paths.length); return new Path(clonedPaths, index, altPath != null ? altPath.clone() : null); } }
@Test void testPathMatching() { assertTrue(new PathQuery("hello", true).matches(Path.parse("hello"))); assertFalse(new PathQuery("hello", true).matches(Path.parse("boom"))); assertTrue(new PathQuery("hello.world", true).matches(Path.parse("hello.world"))); assertFalse(new PathQuery("hello", true).matches(new Path())); assertTrue(new PathQuery("hello.*.world", true).matches(Path.parse("hello.jupiter.world"))); assertTrue(new PathQuery("hello.*.world", true).matches(Path.parse("hello.earth.moon.world"))); assertTrue(new PathQuery("*.class", true).matches(Path.parse("foo.class"))); assertTrue(new PathQuery("*.class", true).matches(Path.parse("foo.bar.tzar.class"))); assertFalse(new PathQuery("*.class", true).matches(Path.parse("foo.bar.tzar"))); assertTrue(new PathQuery("*", true).matches(Path.parse("a.b.c.d"))); assertTrue(new PathQuery("*.class.*", true).matches(Path.parse("a.b.class.d"))); assertTrue(new PathQuery("*", true).matches(Path.parse("123.asd.234s.fsdre"))); assertTrue(new PathQuery("*.*", true).matches(Path.parse("billy.bong.class.yeker"))); }
@Test void testPaths() { Path path = new Path();