/** * This is used to create the <code>Instantiator</code> object that will be used to instantiate * objects. Validation is performed on all of the parameters as well as the <code>Creator</code> * objects associated with the type. This validation ensures that the labels and constructor * parameters match based on annotations. * * @param detail contains the details instantiators are built with * @return this returns the instance that has been created */ private Instantiator create(Detail detail) throws Exception { Signature primary = scanner.getSignature(); ParameterMap registry = scanner.getParameters(); Creator creator = null; if (primary != null) { creator = new SignatureCreator(primary); } return new ClassInstantiator(options, creator, registry, detail); }
/** * This is used to ensure that for each parameter in the builder there is a matching method or * field. This ensures that the class schema is fully readable and writable. If not method or * field annotation exists for the parameter validation fails. * * @param detail contains the details instantiators are built with */ private void validate(Detail detail) throws Exception { ParameterMap registry = scanner.getParameters(); List<Parameter> list = registry.getAll(); for (Parameter parameter : list) { Label label = resolve(parameter); String path = parameter.getPath(); if (label == null) { throw new ConstructorException("Parameter '%s' does not have a match in %s", path, detail); } validateParameter(label, parameter); } validateConstructors(); }