@Override public JSON getDescriptor(ApplicationMetaModel application) { RouterMetaModel router = getRoutes(application, false); if (router != null) { ArrayList<RouteMetaModel> list = new ArrayList<RouteMetaModel>(router.routes); Collections.sort(list, new Comparator<RouteMetaModel>() { @Override public int compare(RouteMetaModel o1, RouteMetaModel o2) { return ((Integer)o1.priority).compareTo(o2.priority); } }); return new JSON().map("routes", list); } return null; } }
@Override public JSON toJSON() { JSON json = new JSON(); json.map("values", getChildren(ControllerMetaModel.class)); return json; }
@Override public JSON getDescriptor(ApplicationMetaModel application) { RouterMetaModel router = getRoutes(application, false); if (router != null) { ArrayList<RouteMetaModel> list = new ArrayList<RouteMetaModel>(router.routes); Collections.sort(list, new Comparator<RouteMetaModel>() { @Override public int compare(RouteMetaModel o1, RouteMetaModel o2) { return ((Integer)o1.priority).compareTo(o2.priority); } }); return new JSON().map("routes", list); } return null; } }
@Override public JSON toJSON() { JSON json = new JSON(); json.map("values", getChildren(ControllerMetaModel.class)); return json; }
@Override public JSON toJSON() { JSON json = new JSON(); json.map("values", getChildren(TemplateMetaModel.class)); json.set("qn", qn); return json; }
@Override public JSON toJSON() { JSON json = new JSON(); json.map("values", getChildren(TemplateMetaModel.class)); json.set("qn", qn); return json; }
public JSON toJSON() { JSON json = new JSON(); json.set("handle", handle); json.map("methods", getHandlers()); return json; }
public JSON toJSON() { JSON json = new JSON(); json.set("handle", handle); json.map("methods", getHandlers()); return json; }
public JSON toJSON() { JSON json = new JSON(); json.set("method", method); json.set("id", declaredId); json.set("phase", phase); json.set("name", name); json.map("parameters", new ArrayList<ParameterMetaModel>(parameters)); return json; }
public JSON toJSON() { JSON json = new JSON(); json.set("method", method); json.set("id", declaredId); json.set("phase", phase); json.set("name", name); json.map("parameters", new ArrayList<ParameterMetaModel>(parameters)); return json; }
@Override public JSON getDescriptor(ApplicationMetaModel application) { JSON config = new JSON(); AbstractContainerMetaModel metaModel = application.getChild(TemplateContainerMetaModel.KEY); LinkedHashSet<String> templates = new LinkedHashSet<String>(); for (TemplateRefMetaModel ref : metaModel.getChildren(TemplateRefMetaModel.class)) { if (ref instanceof ElementMetaModel) { templates.add(((ElementMetaModel)ref).getPath().getName().toString()); } } config.map("templates", templates); config.set("package", metaModel.getQN().toString()); return config; } }
@Override public JSON getDescriptor(ApplicationMetaModel application) { JSON config = new JSON(); AbstractContainerMetaModel metaModel = application.getChild(TemplateContainerMetaModel.KEY); LinkedHashSet<String> templates = new LinkedHashSet<String>(); for (TemplateRefMetaModel ref : metaModel.getChildren(TemplateRefMetaModel.class)) { if (ref instanceof ElementMetaModel) { templates.add(((ElementMetaModel)ref).getPath().getName().toString()); } } config.map("templates", templates); config.set("package", metaModel.getQN().toString()); return config; } }
@Override public JSON getDescriptor(ApplicationMetaModel application) { ControllersMetaModel ac = application.getChild(ControllersMetaModel.KEY); // Build routes configuration ArrayList<String> controllers = new ArrayList<String>(); for (ControllerMetaModel controller : ac) { controllers.add(controller.getHandle().getName() + "_"); } // JSON config = new JSON(); config.set("default", ac.defaultController != null ? ac.defaultController.toString() : null); config.set("error", ac.errorController != null ? ac.errorController.toString() : null); config.set("escapeXML", ac.escapeXML); config.map("controllers", controllers); // return config; }
@Override public JSON getDescriptor(ApplicationMetaModel application) { ControllersMetaModel ac = application.getChild(ControllersMetaModel.KEY); // Build routes configuration ArrayList<String> controllers = new ArrayList<String>(); for (ControllerMetaModel controller : ac) { controllers.add(controller.getHandle().getName() + "_"); } // JSON config = new JSON(); config.set("default", ac.defaultController != null ? ac.defaultController.toString() : null); config.set("error", ac.errorController != null ? ac.errorController.toString() : null); config.set("escapeXML", ac.escapeXML); config.map("controllers", controllers); // return config; }
@Test public void testCastToList() throws Exception { assertEquals(Arrays.asList("bar"), new JSON().map("foo", Arrays.asList("bar")).getList("foo")); assertEquals(Arrays.asList("bar"), new JSON().map("foo", Arrays.asList("bar")).getList("foo", String.class)); assertNull(new JSON().getList("foo")); assertNull(new JSON().getList("foo", Boolean.class)); try { new JSON().set("foo", true).getList("foo"); fail(); } catch (ClassCastException ignore) { } try { new JSON().set("foo", true).getList("foo", String.class); fail(); } catch (ClassCastException ignore) { } try { new JSON().map("foo", Arrays.asList("String")).getList("foo", Boolean.class); fail(); } catch (ClassCastException ignore) { } }
url.map("parameters", foo); url.set("properties", props);
@Test public void testCastToList() throws Exception { assertEquals(Arrays.asList("bar"), new JSON().map("foo", Arrays.asList("bar")).getList("foo")); assertEquals(Arrays.asList("bar"), new JSON().map("foo", Arrays.asList("bar")).getList("foo", String.class)); assertNull(new JSON().getList("foo")); assertNull(new JSON().getList("foo", Boolean.class)); try { new JSON().set("foo", true).getList("foo"); fail(); } catch (ClassCastException ignore) { } try { new JSON().set("foo", true).getList("foo", String.class); fail(); } catch (ClassCastException ignore) { } try { new JSON().map("foo", Arrays.asList("String")).getList("foo", Boolean.class); fail(); } catch (ClassCastException ignore) { } }
url.map("parameters", foo); url.set("properties", props);