/** * {@inheritDoc} */ @Override public Model assertModelValid() { validateModel().assertValid(); return this; }
/** * {@inheritDoc} */ @Override public boolean isModelValid() { return validateModel().isValid(); }
private final void primeModelChildren(Model model) { for (Model child : model.getModelChildren()) { primeModelChildren(child); } }
/** * Reads (constructs) a Model based on the specified Configuration. * @param config the Configuration * @return the new Model */ protected final synchronized Model readModel(Configuration config) { if (config != null) { Marshaller marsh = _desc.getMarshaller(config); if (marsh != null) { return marsh.read(config); } } return null; }
/** * Merges two models into a new model. * Note: The act of merging results in fromModel and toModel to have their configurations normalized and children ordered! * @param <M> the type of Model being merged * @param fromModel merge from this model, optionally overriding anything in toModel * @param toModel merge into a copy of this model * @param fromOverridesTo whether fromModel attributes/values should override those in toModel * @return the newly merged model */ public static <M extends Model> M merge(M fromModel, M toModel, boolean fromOverridesTo) { return merge(fromModel, toModel, fromOverridesTo, false); }
/** * Creates a new Validator based on the namespaces of the specified Configuration. * @param config the Configuration * @return the new Validator * @see #getValidator(Set) */ public Validator getValidator(Configuration config) { return getValidator(getSchema(config)); }
/** * By default, will delegate the writing to the specified Model. * @param model the Model to write * @param writer the Writer to write to * @throws IOException if a problem occurred */ @Override public void write(Model model, Writer writer) throws IOException { model.write(writer); }
/** * Gets the switchyard namespace for the scan. * @return the switchyard namespace */ public SwitchYardNamespace getSwitchyardNamespace() { return isSwitchyardNamespaceSet() ? _switchyardNamespace : SwitchYardNamespace.DEFAULT; }
/** * Gets the schema property, based on the specified namespace. * @param namespace the namespace * @return the {@link #SCHEMA} property value */ public String getSchemaProperty(String namespace) { return getProperty(SCHEMA, namespace); }
/** * {@inheritDoc} */ @Override public final Model getModelRoot() { Model root = this; while (root.getModelParent() != null) { root = root.getModelParent(); } return root; }
/** * Recursively iterates over the children, which will force instantiation of a Model for every child Configuration. * @return this model (useful for chaining) */ protected final Model primeModelChildren() { primeModelChildren(this); return this; }
/** * Constructs a new Descriptor based on discovered default properties. */ public Descriptor() { addDefaultProperties(); }
/** * Whether or not this model has a parent model. * @return true if a parent model exists */ protected final boolean hasParentModel() { return getModelParent() != null; }
/** * Constructs a new Descriptor based on the specified properties. * @param props the Properties */ public Descriptor(Properties props) { addProperties(props); }
/** * {@inheritDoc} */ @Override public Model assertModelValid() { validateModel().assertValid(); return this; }
/** * {@inheritDoc} */ @Override public boolean isModelValid() { return validateModel().isValid(); }
private final void primeModelChildren(Model model) { for (Model child : model.getModelChildren()) { primeModelChildren(child); } }
/** * Creates a new Validator based on the namespaces of the Configuration wrapped by the specified Model. * @param model the Model * @return the new Validator * @see #getValidator(Configuration) * @see #getValidator(Set) */ public Validator getValidator(Model model) { return getValidator(getSchema(model)); }
/** * Gets the marshaller property, based on the specified namespace. * @param namespace the namespace * @return the {@link #MARSHALLER} property value */ public String getMarshallerProperty(String namespace) { return getProperty(MARSHALLER, namespace); }
/** * Gets the section property, based on the specified namespace. * @param namespace the namespace * @return the {@link #SECTION} property value */ public String getSectionProperty(String namespace) { return getProperty(SECTION, namespace); }