@SuppressWarnings("unused") private static void validatePropertyRefList(Bean bean) { Schema schema = bean.getSchema(); for (SchemaPropertyRefList prop : schema.get(SchemaPropertyRefList.class)) { } }
public XmlSchema(Schema bean) { this.id = new XmlSchemaId(bean.getId()); this.name = bean.getName(); this.type = bean.getType(); this.desc = bean.getDesc(); for (SchemaProperty p : bean.get(SchemaProperty.class)) { properties.add(new XmlSchemaProperty(p)); } for (SchemaPropertyList p : bean.get(SchemaPropertyList.class)) { collection.add(new XmlSchemaCollection(p)); } for (SchemaPropertyRef p : bean.get(SchemaPropertyRef.class)) { ref.add(new XmlSchemaRef(p)); } for (SchemaPropertyRefList p : bean.get(SchemaPropertyRefList.class)) { refCollection.add(new XmlSchemaRefCollection(p)); } for (SchemaPropertyRefMap p : bean.get(SchemaPropertyRefMap.class)) { refMap.add(new XmlSchemaRefMap(p)); } } }
private static void validatePropertyRefMap(Bean bean) { Schema schema = bean.getSchema(); for (SchemaPropertyRefMap prop : schema.get(SchemaPropertyRefMap.class)) { } }
private static void validatePropertyRefList(Bean bean) { Schema schema = bean.getSchema(); for (SchemaPropertyRefList prop : schema.get(SchemaPropertyRefList.class)) { } }
/** * Returns all property names that exist for this schema. */ public Set<String> getPropertyNames() { Set<String> names = new HashSet<>(); for (AbstractSchemaProperty prop : get(SchemaProperty.class)) { names.add(prop.getName()); } for (AbstractSchemaProperty prop : get(SchemaPropertyList.class)) { names.add(prop.getName()); } return names; }
@SuppressWarnings("unused") private static void validatePropertyRefMap(Bean bean) { Schema schema = bean.getSchema(); for (SchemaPropertyRefMap prop : schema.get(SchemaPropertyRefMap.class)) { } }
public Set<Class<?>> getReferenceSchemaTypes() { Set<Class<?>> names = new HashSet<>(); for (AbstractSchemaProperty prop : get(SchemaPropertyRef.class)) { names.add(prop.getClassType()); } for (AbstractSchemaProperty prop : get(SchemaPropertyRefList.class)) { names.add(prop.getClassType()); } for (AbstractSchemaProperty prop : get(SchemaPropertyRefMap.class)) { names.add(prop.getClassType()); } return names; }
/** * Returns a specific properties of a particular type identified with a name. * * @param clazz specific type of property to get. * @param name The AbstractSchemaProperty name of the property. * @return Matching property. */ public <T extends AbstractSchemaProperty> T get(final Class<T> clazz, final String name) { Set<T> propertyCollection = get(clazz); for (T property : propertyCollection) { if (property.getName().equals(name)) { return property; } } return null; }
/** * Returns all reference names that exist for this schema. */ public Set<String> getReferenceNames() { Set<String> names = new HashSet<>(); for (AbstractSchemaProperty prop : get(SchemaPropertyRef.class)) { names.add(prop.getName()); } for (AbstractSchemaProperty prop : get(SchemaPropertyRefList.class)) { names.add(prop.getName()); } for (AbstractSchemaProperty prop : get(SchemaPropertyRefMap.class)) { names.add(prop.getName()); } return names; }
private static void validatePropertyReferences(Bean bean) { Schema schema = bean.getSchema(); for (SchemaPropertyRef prop : schema.get(SchemaPropertyRef.class)) { validateSingle(bean, prop); } }
private static void validatePropertyReferences(Bean bean) { Schema schema = bean.getSchema(); for (SchemaPropertyRef prop : schema.get(SchemaPropertyRef.class)) { validateSingle(bean, prop); } }
private void convertProperty(Bean source, Map<String, Object> values) { for (SchemaProperty prop : source.getSchema().get(SchemaProperty.class)) { String value = source.getSingleValue(prop.getName()); String field = prop.getFieldName(); Object converted = conversion.convert(value, loadClass(prop.getType())); values.put(field, converted); } }
private void convertProperty(Bean source, Map<String, Object> values) { for (SchemaProperty prop : source.getSchema().get(SchemaProperty.class)) { String value = source.getSingleValue(prop.getName()); String field = prop.getFieldName(); Object converted = conversion.convert(value, forName(prop.getType())); values.put(field, converted); } }
private void convertPropertyList(Bean source, Map<String, Object> values) { for (SchemaPropertyList prop : source.getSchema().get(SchemaPropertyList.class)) { List<String> vals = source.getValues(prop.getName()); String field = prop.getFieldName(); if (vals == null) { continue; } Collection<Object> c = newCollection(loadClass(prop.getCollectionType())); for (String val : vals) { Object converted = conversion.convert(val, loadClass(prop.getType())); c.add(converted); } values.put(field, c); } }
private void convertPropertyList(Bean source, Map<String, Object> values) { for (SchemaPropertyList prop : source.getSchema().get(SchemaPropertyList.class)) { List<String> vals = source.getValues(prop.getName()); String field = prop.getFieldName(); if (vals == null) { continue; } Collection<Object> c = newCollection(forName(prop.getCollectionType())); for (String val : vals) { Object converted = conversion.convert(val, forName(prop.getType())); c.add(converted); } values.put(field, c); } }
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); } } }
private static void validateProperties(Bean bean) { Schema schema = bean.getSchema(); for (SchemaProperty prop : schema.get(SchemaProperty.class)) { String value = validateSingle(bean, prop); if (value == null) { continue; } try { conversion.convert(value, forName(prop.getType())); } catch (Exception e) { throw Events.CFG105_WRONG_PROPERTY_TYPE(bean.getId(), prop.getName(), prop.getType(), value); } } }
private static void validateProperties(Bean bean) { Schema schema = bean.getSchema(); ClassRepository repos = new ClassRepository(); for (SchemaProperty prop : schema.get(SchemaProperty.class)) { String value = validateSingle(bean, prop); if (value == null) { continue; } try { conversion.convert(value, repos.loadClass(prop.getType())); } catch (Exception e) { throw Events.CFG105_WRONG_PROPERTY_TYPE(bean.getId(), prop.getName(), prop.getType(), value); } } }
private static void validatePropertyList(Bean bean) { Schema schema = bean.getSchema(); ClassRepository repos = new ClassRepository(); for (SchemaPropertyList prop : schema.get(SchemaPropertyList.class)) { List<String> values = bean.getValues(prop.getName()); if (values == null) { continue; } for (String value : values) { try { conversion.convert(value, repos.loadClass(prop.getType())); } catch (Exception e) { throw Events.CFG105_WRONG_PROPERTY_TYPE(bean.getId(), prop.getName(), prop.getType(), value); } } } }