private DatasetSpecification namespace(String namespace, DatasetSpecification spec) { // Name of the DataSetSpecification is prefixed with namespace if namespace is present. String name; if (namespace == null) { name = spec.getName(); } else { name = namespace; if (!spec.getName().isEmpty()) { name += '.' + spec.getName(); } } // If no namespace is given, starts with using the DataSet name. namespace = (namespace == null) ? spec.getName() : namespace; TreeMap<String, DatasetSpecification> specifications = new TreeMap<>(); for (Map.Entry<String, DatasetSpecification> entry : spec.datasetSpecs.entrySet()) { specifications.put(entry.getKey(), namespace(namespace, entry.getValue())); } return new DatasetSpecification(name, spec.type, spec.description, spec.properties, specifications); } }
/** * Prefixes all DataSets embedded inside the given {@link DatasetSpecification} with the name of the enclosing * Dataset. */ private DatasetSpecification namespace(DatasetSpecification spec) { return namespace(null, spec); }
/** * Create a DataSetSpecification from this builder, using the private DataSetSpecification * constructor. * @return a complete DataSetSpecification */ public DatasetSpecification build() { return namespace(new DatasetSpecification(name, type, description, properties, dataSetSpecs)); }