Spring Data for VMware GemFire
Class PropertiesBuilder
java.lang.Object
org.springframework.data.gemfire.util.PropertiesBuilder
- All Implemented Interfaces:
org.springframework.beans.factory.FactoryBean<Properties>
public class PropertiesBuilder
extends Object
implements org.springframework.beans.factory.FactoryBean<Properties>
Builder for
Properties.- Since:
- 1.9.0
- See Also:
-
PropertiesFactoryBean
-
Field Summary
Fields inherited from interface org.springframework.beans.factory.FactoryBean
OBJECT_TYPE_ATTRIBUTE -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new instance ofPropertiesBuilder.PropertiesBuilder(Properties defaults) Constructs a new instance ofPropertiesBuilderinitialized with the defaultProperties.PropertiesBuilder(PropertiesBuilder builder) Constructs a new instance ofPropertiesBuilderinitialized with the givenPropertiesBuilderproviding the defaultPropertiesfor this builder. -
Method Summary
Modifier and TypeMethodDescriptionadd(Properties properties) Null-safe method to add all thePropertiesto this builder.add(PropertiesBuilder builder) Null-safe method to add all thePropertiesfrom the providedPropertiesBuilderto this builder.build()Builds thePropertiesobject from this builder.static PropertiesBuildercreate()Factory method used to create a defaultPropertiesBuilderinstance.static PropertiesBuilderfrom(InputStream in) Constructs a new instance ofPropertiesBuilderinitialized with all properties from the givenInputStream.static PropertiesBuilderConstructs a new isntance ofPropertiesBuilderinitialized with all properties from the givenReader.static PropertiesBuilderfrom(Properties properties) Factory method used to create an instance ofPropertiesBuilderinitialized with the givenProperties.static PropertiesBuilderfromXml(InputStream xml) Constructs a new instance ofPropertiesBuilderinitialized with all properties from the givenInputStreamin XML format.Class<?>booleanprotected booleanisValuable(String value) Determine whether the givenStringvalue is a validPropertiesvalue.setProperty(String name, Object value) Sets a property with given name to the specified value.setProperty(String name, Object[] values) Sets the named property to the given array of object values.setProperty(String name, String value) Sets a property with the given name to the specifiedStringvalue.setPropertyIfNotDefault(String name, Object value, T defaultValue) Sets the named property to the given value if the defaultValue is not null and value is not equal to defaultValue.unsetProperty(String name) Un-sets the named property.
-
Constructor Details
-
PropertiesBuilder
public PropertiesBuilder()Constructs a new instance ofPropertiesBuilder. -
PropertiesBuilder
Constructs a new instance ofPropertiesBuilderinitialized with the defaultProperties.- Parameters:
defaults-Propertiesused as the defaults.- Throws:
NullPointerException- if thePropertiesreference is null.- See Also:
-
PropertiesBuilder
Constructs a new instance ofPropertiesBuilderinitialized with the givenPropertiesBuilderproviding the defaultPropertiesfor this builder.- Parameters:
builder-PropertiesBuilderproviding the defaultPropertiesfor this builder.- Throws:
NullPointerException- if thePropertiesBuilderreference is null.- See Also:
-
-
Method Details
-
create
Factory method used to create a defaultPropertiesBuilderinstance.- Returns:
- an instance of the
PropertiesBuilderclass with notProperties. - See Also:
-
from
Factory method used to create an instance ofPropertiesBuilderinitialized with the givenProperties.- Parameters:
properties-Propertiesused as the default properties of the constructedPropertiesBuilder.- Returns:
- an instance of
PropertiesBuilderinitialized with the givenProperties. - See Also:
-
from
Constructs a new instance ofPropertiesBuilderinitialized with all properties from the givenInputStream.- Parameters:
in-InputStreamsource containing properties to use as the defaults for the constructed builder.- Returns:
- a
PropertiesBuilderinitialized with properties from the givenInputStream. - Throws:
IllegalArgumentException- if theInputStreamcannot be read.- See Also:
-
from
Constructs a new isntance ofPropertiesBuilderinitialized with all properties from the givenReader.- Parameters:
reader-Readersource containing properties to use as the defaults for the constructed builder.- Returns:
- a
PropertiesBuilderinitialized with properties from the givenReader. - Throws:
IllegalArgumentException- if theReadercannot be read.- See Also:
-
fromXml
Constructs a new instance ofPropertiesBuilderinitialized with all properties from the givenInputStreamin XML format.- Parameters:
xml-InputStreamsource containing properties in XML format to use as defaults for the constructed builder.- Returns:
- a
PropertiesBuilderinitialized with properties from the given XMLInputStream. - Throws:
IllegalArgumentException- if the XMLInputStreamcannot be read.- See Also:
-
getObject
- Specified by:
getObjectin interfaceorg.springframework.beans.factory.FactoryBean<Properties>- Throws:
Exception
-
getObjectType
- Specified by:
getObjectTypein interfaceorg.springframework.beans.factory.FactoryBean<Properties>
-
isSingleton
public boolean isSingleton()- Specified by:
isSingletonin interfaceorg.springframework.beans.factory.FactoryBean<Properties>
-
add
Null-safe method to add all thePropertiesto this builder. This operation effectively overwrites any properties already set with the same name from the source.- Parameters:
properties-Propertiesto add to this builder.- Returns:
- a reference to this
PropertiesBuilder. - See Also:
-
add
Null-safe method to add all thePropertiesfrom the providedPropertiesBuilderto this builder. This operation effectively overwrites any properties already set with the same name from the source.- Parameters:
builder- source of thePropertiesto add to this builder.- Returns:
- a reference to this
PropertiesBuilder. - See Also:
-
setProperty
Sets a property with given name to the specified value. The property is only set if the value is not null.- Parameters:
name- the name of the property to set.value- the value to set the property to.- Returns:
- a reference to this
PropertiesBuilder. - See Also:
-
setProperty
Sets the named property to the given array of object values. The property is only set if the array of object value is not null or empty.- Parameters:
name- name of the property to set.values- array of object values used as the property's value.- Returns:
- a reference to this
PropertiesBuilder - See Also:
-
StringUtils.arrayToCommaDelimitedString(Object[])setProperty(String, String)
-
setProperty
Sets a property with the given name to the specifiedStringvalue. The property is only set if the value is not null, an emptyStringor not equal to theStringliteral null, ignoring case.- Parameters:
name- the name of the property to set.value- the value to set the property to.- Returns:
- a reference to this
PropertiesBuilder. - Throws:
IllegalArgumentException- if the property name is not specified.- See Also:
-
setPropertyIfNotDefault
@NonNull public <T> PropertiesBuilder setPropertyIfNotDefault(@NonNull String name, Object value, T defaultValue) Sets the named property to the given value if the defaultValue is not null and value is not equal to defaultValue.- Type Parameters:
T- Class type of the property value.- Parameters:
name- name of the property to set.value- value to set for the property.defaultValue- default value of the property to compare with the given value when determining whether to set the property.- Returns:
- a reference to this
PropertiesBuilder. - See Also:
-
unsetProperty
Un-sets the named property. This method sets the given named property to an emptyString.- Parameters:
name- name of the property to unset.- Returns:
- a reference to this
PropertiesBuilder. - Throws:
IllegalArgumentException- if the property name is not specified.
-
isValuable
Determine whether the givenStringvalue is a validPropertiesvalue. A property value is considered valid if it is not null, not empty and not equal to (case-insensitive)Stringliteral null.- Parameters:
value-Stringvalue for the property being set.- Returns:
- a boolean value indicating whether the given
Stringvalue is a validPropertiesvalue.
-
build
Builds thePropertiesobject from this builder.- Returns:
- the
Propertiesobject built by this builder. - See Also:
-