/** * Maps a map of {@code Map<String,String>} to a {@code Map<String,PropertyValue>}. * * @param config the String based map, not {@code null}. * @param source the source name, not {@code null}. * @param metaData additional metadata, not {@code null}. * @return the corresponding value based map. */ public static Map<String,PropertyValue> map(Map<String, String> config, String source, Map<String,String> metaData) { Objects.requireNonNull(config, "Config must be given."); Objects.requireNonNull(source, "Source must be given."); Objects.requireNonNull(metaData, "Meta data must be given."); Map<String,PropertyValue> result = new HashMap<>(config.size()); for(Map.Entry<String,String> en:config.entrySet()){ PropertyValue value = new PropertyValueBuilder(en.getKey(), source).setValue(en.getValue()) .addMetaEntries(metaData).build(); result.put(en.getKey(), value); } return result; } }
/** * Creates a new builder instance based on this item. * @return a new builder, never null. */ public PropertyValueBuilder toBuilder() { return new PropertyValueBuilder(this.getKey(), this.getSource()) .setValue(this.getValue()) .setMetaEntries(this.metaEntries); }
@Override public Map<String, PropertyValue> getProperties() { Map<String,PropertyValue> result = new HashMap<>(); for(PropertyValue val : source.getProperties().values()) { String mappedValue = valueFilter.mapProperty(val.getKey(), val.getValue()); PropertyValue value = val.toBuilder().setValue(mappedValue).build(); result.put(val.getKey(), value); } return result; }
props.put(reqKey+".lockIndex", String.valueOf(value.getLockIndex())); props.put(reqKey+".flags", String.valueOf(value.getFlags())); return new PropertyValueBuilder(key, value.getValue().get(), getName()).setContextData(props).build();
/** * Creates a new builder instance. * @param key the key, not {@code null}. * @param source the source, typically the name of the {@link PropertySource} * providing the value, not {@code null}. * @return a new builder instance. */ public static PropertyValueBuilder builder(String key, String source){ Objects.requireNonNull(key, "Key must be given."); Objects.requireNonNull(source, "Source must be given"); return new PropertyValueBuilder(key, source); }
/** * Creates a new builder instance. * @param key the key, not {@code null}. * @param source the source, typically the name of the {@link PropertySource} * providing the value, not {@code null}. * @return a new builder instance. */ public static PropertyValueBuilder builder(String key, String value, String source) { Objects.requireNonNull(key, "Key must be given."); Objects.requireNonNull(value, "Value must be given"); Objects.requireNonNull(source, "Source must be given."); return new PropertyValueBuilder(key, value, source); }