/** * @return a new spec that is the same as this one, with the original properties set to the provided properties. */ public DatasetSpecification setOriginalProperties(Map<String, String> originalProps) { return new DatasetSpecification(name, type, description, originalProps, properties, datasetSpecs); }
public DatasetSpecification setDescription(String description) { return new DatasetSpecification(name, type, description, originalProperties, properties, datasetSpecs); }
/** * 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)); }
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); } }