Skip to content

Commit

Permalink
[Issue adobe#52] Add schema content + presetNodes ModelObject constru…
Browse files Browse the repository at this point in the history
…ctor
  • Loading branch information
gahag committed Oct 12, 2019
1 parent b697dd2 commit f4009c3
Showing 1 changed file with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,43 @@ private void initializeModelObject(String resourceLocation, JSONObject presetNod
loadModel(resourceLocation);
}

/**
* Create a model object from a json schema string and use a predefined set of nodes to start
* with. Also only build a targeted set of nodes. The specified resource location is only used as
* metadata, so the content will not be fetched from it.
*
* @param resourceLocation location of the schema within the project resources.
* @param modelString string which conforms to JSON schema standards
* @param presetNodes set of JSON nodes and values to be used in the object, not generated
* dynamically
* @param nodesToBuild set of JSONnodes which are to be dynamically generated. Remaining schema
* defined nodes will not be generated.
* @param useRequiredOnly boolean to determine whether to build only the required json nodes as
* defined in the spec
*/
public ModelObject(String resourceLocation, String modelString, JSONObject presetNodes,
Set<String> nodesToBuild, boolean useRequiredOnly) {
initializeModelObject(resourceLocation, modelString, presetNodes, nodesToBuild,
useRequiredOnly);
}

private void initializeModelObject(String resourceLocation, String modelString,
JSONObject presetNodes, Set<String> nodesToBuild, boolean useRequiredOnly) {
if (presetNodes != null) {
this.presetNodes = presetNodes;
}

if (nodesToBuild != null) {
this.nodesToBuild = nodesToBuild;
}

this.requiredOnly = useRequiredOnly;

this.resourceLocation = resourceLocation;
this.modelString = modelString;
loadModelString(modelString);
}

/**
* Constructor to initialize with a JSON schema string
*
Expand Down

0 comments on commit f4009c3

Please sign in to comment.