TreePruner pruner = (tree!=null) ? new NamedPathPruner(tree) : new ByDepth(1 - depth); p.writeTo(bean,pruner,Flavor.XML.createDataWriter(bean,sw));
public @Override TreePruner accept(Object node, Property prop) { Tree subtree = tree.children.get(prop.name); return subtree != null ? new NamedPathPruner(subtree) : null; }
public @Override TreePruner accept(Object node, Property prop) { if (prop.merge) return this; Tree subtree = tree.children.get(prop.name); if (subtree==null) subtree=tree.children.get("*"); return subtree != null ? new NamedPathPruner(subtree) : null; }
public @Override TreePruner accept(Object node, Property prop) { if (prop.merge) return this; Tree subtree = tree.children.get(prop.name); if (subtree==null) subtree=tree.children.get("*"); return subtree != null ? new NamedPathPruner(subtree) : null; }
if (tree != null) { try { pruner = new NamedPathPruner(tree); } catch (IllegalArgumentException x) { throw new ServletException("Malformed tree expression: " + x, x);
@SuppressWarnings({"unchecked", "rawtypes"}) // API design flaw prevents this from type-checking private static void assertResult(String expected, Object bean, String spec) throws Exception { Model model = new ModelBuilder().get(bean.getClass()); StringWriter w = new StringWriter(); model.writeTo(bean, new NamedPathPruner(spec), Flavor.JSON.createDataWriter(bean, w, config)); assertEquals(expected, w.toString().replace("\\\"", "").replace("\"", "")); }
/** * y is a property from a merged object but that shouldn't be visible to {@link NamedPathPruner}. */ @Test public void merge_pathPrune() throws Exception { StringWriter sw = new StringWriter(); builder.get(B.class).writeTo(b, new NamedPathPruner("z,y"), Flavor.JSON.createDataWriter(b, sw, config)); assertEquals("{'_class':'B','y':20,'z':30}", sw.toString().replace('"','\'')); }
if (tree != null) { try { pruner = new NamedPathPruner(tree); } catch (IllegalArgumentException x) { throw new ServletException("Malformed tree expression: " + x, x);
if (tree != null) { try { pruner = new NamedPathPruner(tree); } catch (IllegalArgumentException x) { throw new ServletException("Malformed tree expression: " + x, x);
TreePruner pruner = (tree!=null) ? new NamedPathPruner(tree) : new ByDepth(1 - depth); p.writeTo(bean,pruner,Flavor.XML.createDataWriter(bean,sw));