public Bean traverse(Set<Bean> beans, Bean parent) { Bean current = Bean.create(BeanId.create(value + "", "binarytree")); current.setProperty("value", value + ""); if (parent != null) { current.setReference("parent", parent.getId()); } if (left != null) { Bean leftBean = left.traverse(beans, current); current.setReference("left", leftBean.getId()); } if (right != null) { Bean rightBean = right.traverse(beans, current); current.setReference("right", rightBean.getId()); } beans.add(current); return current; }
private void setSingletonReferences(Bean bean, Map<String, Schema> schemas) { Schema s = bean.getSchema(); for (SchemaPropertyRef ref : s.get(SchemaPropertyRef.class)) { if (ref.isSingleton()) { Schema singletonSchema = schemas.get(ref.getSchemaName()); Optional<Bean> singleton = beanManager.getSingleton(ref.getSchemaName()); if (singleton.isPresent()) { singleton.get().set(singletonSchema); BeanId singletonId = singleton.get().getId(); singletonId.setBean(singleton.get()); // recursive call. setSingletonReferences(singleton.get(), schemas); bean.setReference(ref.getName(), singletonId); } } } }
private void setSingletonReferences(Bean bean, Map<String, Schema> schemas) { Schema s = bean.getSchema(); for (SchemaPropertyRef ref : s.get(SchemaPropertyRef.class)) { if (ref.isSingleton()) { Schema singletonSchema = schemas.get(ref.getSchemaName()); Optional<Bean> singleton = beanManager.getSingleton(ref.getSchemaName()); if (!singleton.isPresent()) { initFile(null); Bean fileBean = FILE_CONFIG.get(BeanId.createSingleton(ref.getSchemaName())); if (fileBean != null) { singleton = Optional.of(fileBean); } } if (!singleton.isPresent()) { singleton = Optional.of(Bean.create(BeanId.createSingleton(ref.getSchemaName()))); } singleton.get().set(singletonSchema); BeanId singletonId = singleton.get().getId(); singletonId.setBean(singleton.get()); // recursive call. setSingletonReferences(singleton.get(), schemas); bean.setReference(ref.getName(), singletonId); } } }
a.setReference("bestFriend", bId); b.setReference("bestFriend", aId); c.setReference("bestFriend", dId); d.setReference("bestFriend", cId);
a.setReference("bestFriend", bId); b.setReference("bestFriend", aId); c.setReference("bestFriend", dId); d.setReference("bestFriend", cId);
private void setSingletonReferences(Bean bean, Map<String, Schema> schemas) { Schema s = bean.getSchema(); for (SchemaPropertyRef ref : s.get(SchemaPropertyRef.class)) { if (ref.isSingleton()) { Schema singletonSchema = schemas.get(ref.getSchemaName()); Bean singleton = beanManager.getSingleton(ref.getSchemaName()); singleton.set(singletonSchema); BeanId singletonId = singleton.getId(); singletonId.setBean(singleton); // recursive call. setSingletonReferences(singleton, schemas); bean.setReference(ref.getName(), singletonId); } } }
private void setSingletonReferences(Bean bean, Map<String, Schema> schemas) { Schema s = bean.getSchema(); for (SchemaPropertyRef ref : s.get(SchemaPropertyRef.class)) { if (ref.isSingleton()) { Schema singletonSchema = schemas.get(ref.getSchemaName()); Bean singleton = beanManager.getSingleton(ref.getSchemaName()); singleton.set(singletonSchema); BeanId singletonId = singleton.getId(); singletonId.setBean(singleton); // recursive call. setSingletonReferences(singleton, schemas); bean.setReference(ref.getName(), singletonId); } } }
bean.setReference("non_existing", c1.getId()); admin.create(bean); fail("Not possible to set property names that does not exist in schema");
bean.setReference("non_existing", c1.getId()); admin.create(bean); fail("Not possible to set property names that does not exist in schema");