/** * Constructs a {@link PropertiesBuilder} based on a standard * {@link Properties} representation. * <p> * Note: The provided properties are added as default values to the * {@link PropertiesBuilder}. * * @param properties the {@link Properties} to use as the basis for the * {@link PropertiesBuilder} */ public PropertiesBuilder(Properties properties) { this(); for (String key : properties.stringPropertyNames()) { this.properties.put(key, new Property(key, null, properties.getProperty(key))); } }
/** * Constructs a {@link PropertiesBuilder} with properties based on a * {@link Map} of name-value pairs. * <p> * Note: The provided properties are added as default values to the * {@link PropertiesBuilder}. * * @param properties the {@link Map} of properties to use as the basis for * the {@link PropertiesBuilder} */ public PropertiesBuilder(Map<String, String> properties) { this(); for (String name : properties.keySet()) { this.properties.put(name, new Property(name, null, properties.get(name))); } }
/** * Constructs a {@link PropertiesBuilder} based on the properties defined * in another {@link PropertiesBuilder}. * * @param propertiesBuilder the {@link PropertiesBuilder} on which to base * the new {@link PropertiesBuilder} */ public PropertiesBuilder(PropertiesBuilder propertiesBuilder) { this(); for (String name : propertiesBuilder.getPropertyNames()) { this.properties.put(name, new Property(propertiesBuilder.properties.get(name))); } }
/** * Sets the specified named default property to use an {@link Iterator} to * provide successive property values when the {@link PropertiesBuilder} is realized. * * @param name the name of the property * @param defaultIterator the default {@link Iterator} that will provide * successive property values for the property when * the {@link PropertiesBuilder} is realized * * @return the {@link PropertiesBuilder} to which the property was added so * that further chained method calls, like to other * <code>setProperty(...)</code> methods on this class may be used */ @Deprecated public PropertiesBuilder setDefaultProperty(String name, Iterator<?> defaultIterator) { if (containsProperty(name)) { properties.get(name).setDefaultValue(defaultIterator); } else { properties.put(name, new Property(name, null, defaultIterator)); } return this; }
/** * Sets the specified named property to use an {@link Iterator}. * (to provide successive requests for the property with values from the said * {@link Iterator} when the {@link PropertiesBuilder} is realized) * * @param name the name of the property * @param iterator an {@link Iterator} that will provide successive property * values for the property when the {@link PropertiesBuilder} * is realized * * @return the {@link PropertiesBuilder} to which the property was added so * that further chained method calls, like to other * <code>setProperty(...)</code> methods on this class may be used. */ public PropertiesBuilder setProperty(String name, Iterator<?> iterator) { if (containsProperty(name)) { properties.get(name).setValue(iterator); } else { properties.put(name, new Property(name, iterator, null)); } return this; }
/** * Sets the specified named default property to have the specified value. * * @param name the name of the property * @param defaultValue the default value of the property * * @return the {@link PropertiesBuilder} to which the property was added so * that further chained method calls, like to other * <code>setProperty(...)</code> methods on this class may be used */ @Deprecated public PropertiesBuilder setDefaultProperty(String name, Object defaultValue) { if (containsProperty(name)) { properties.get(name).setDefaultValue(defaultValue); } else { properties.put(name, new Property(name, null, defaultValue)); } return this; }
/** * Sets the specified named property to have the specified value. * * @param name the name of the property * @param value the value of the property * * @return the {@link PropertiesBuilder} to which the property was added so * that further chained method calls, like to other * <code>setProperty(...)</code> methods on this class may be used */ public PropertiesBuilder setProperty(String name, Object value) { if (containsProperty(name)) { properties.get(name).setValue(value); } else { properties.put(name, new Property(name, value, null)); } return this; }