/** * Create a Model for a registered Blueprint * * @param <T> model Class * @param clazz Model class * @param withPolicies boolean if Policies should be applied to the create * @return Model * @throws CreateModelException model failed to create */ public <T> T createModel(Class<T> clazz, boolean withPolicies) throws CreateModelException { Erector erector = erectors.get(clazz); if (erector == null) { throw new CreateModelException("Unregistered class: " + clazz); } return createModel(erector, null, withPolicies); }
/** * Create a Model for a registered Blueprint. Values set in the * model will not be overridden by defaults in the Blueprint. * * @param <T> model Class * @param referenceModel Object * @param withPolicies boolean if Policies should be applied to the create * @return Model * @throws CreateModelException model failed to create */ @SuppressWarnings({"rawtypes", "unchecked"}) public <T> T createModel(T referenceModel, boolean withPolicies) throws CreateModelException { Erector erector = erectors.get(referenceModel.getClass()); if (erector == null) { throw new CreateModelException("Unregistered class: " + referenceModel.getClass()); } return createModel(erector, referenceModel, withPolicies); }
createdModel = (T) createNewInstance(erector); } catch (BlueprintTemplateException e) { throw new CreateModelException(e); throw new CreateModelException(e); new CreateModelException(e); value = erector.getTemplate().get(nonNullReferenceModel, defaultField.getName()); } catch (BlueprintTemplateException e) { throw new CreateModelException(e); createdModel = erector.getTemplate().set(createdModel, defaultField.getName(), value); } catch (BlueprintTemplateException e) { throw new CreateModelException(e); value = erector.getTemplate().get(nonNullReferenceModel, mappedField.getName()); } catch (BlueprintTemplateException e) { throw new CreateModelException(e); createdModel = erector.getTemplate().set(createdModel, mappedField.getName(), value); } catch (BlueprintTemplateException e) { throw new CreateModelException(e); value = (List) erector.getTemplate().construct(listField.getTargetList()); } catch (BlueprintTemplateException e) { throw new CreateModelException(e); modelList = (List) erector.getTemplate().get(nonNullReferenceModel, listField.getName());