Skip to content
Snippets Groups Projects
Commit da2ab0d2 authored by ribeaudc's avatar ribeaudc
Browse files

change: - Parameters in 'datamover' refactored.

SVN: 6055
parent f86221ba
No related branches found
No related tags found
No related merge requests found
...@@ -67,6 +67,30 @@ public final class PropertyUtils ...@@ -67,6 +67,30 @@ public final class PropertyUtils
assert propertyKey != null : "Given property key can not be null."; assert propertyKey != null : "Given property key can not be null.";
} }
/**
* Searches for the property with the specified key in this property list.
*
* @return <code>null</code> or the value trimmed if found.
*/
public final static String getProperty(final Properties properties, final String propertyKey)
{
assertParameters(properties, propertyKey);
final String property = properties.getProperty(propertyKey);
return property == null ? null : property.trim();
}
/**
* Searches for the property with the specified key in this property list.
*
* @return <code>null</code> or the value trimmed if found.
*/
public final static String getProperty(final Properties properties, final String propertyKey,
final String defaultValue)
{
final String property = getProperty(properties, propertyKey);
return property == null ? defaultValue : property;
}
/** /**
* Looks up given mandatory <var>propertyKey</var> in given <var>properties</var>. * Looks up given mandatory <var>propertyKey</var> in given <var>properties</var>.
* *
...@@ -77,14 +101,13 @@ public final class PropertyUtils ...@@ -77,14 +101,13 @@ public final class PropertyUtils
final String propertyKey) throws ConfigurationFailureException final String propertyKey) throws ConfigurationFailureException
{ {
assertParameters(properties, propertyKey); assertParameters(properties, propertyKey);
String property = properties.getProperty(propertyKey); String property = getProperty(properties, propertyKey);
if (property == null) if (property == null)
{ {
throw ConfigurationFailureException.fromTemplate(NOT_FOUND_PROPERTY_FORMAT, throw ConfigurationFailureException.fromTemplate(NOT_FOUND_PROPERTY_FORMAT,
propertyKey, CollectionUtils.abbreviate(Collections.list(properties propertyKey, CollectionUtils.abbreviate(Collections.list(properties
.propertyNames()), 10)); .propertyNames()), 10));
} }
property = property.trim();
if (property.length() == 0) if (property.length() == 0)
{ {
throw ConfigurationFailureException.fromTemplate(EMPTY_STRING_FORMAT, propertyKey); throw ConfigurationFailureException.fromTemplate(EMPTY_STRING_FORMAT, propertyKey);
...@@ -101,7 +124,7 @@ public final class PropertyUtils ...@@ -101,7 +124,7 @@ public final class PropertyUtils
final long defaultValue, final ISimpleLogger loggerOrNull) final long defaultValue, final ISimpleLogger loggerOrNull)
{ {
assertParameters(properties, propertyKey); assertParameters(properties, propertyKey);
final String longOrNull = properties.getProperty(propertyKey); final String longOrNull = getProperty(properties, propertyKey);
if (longOrNull == null) if (longOrNull == null)
{ {
return defaultValue; return defaultValue;
...@@ -139,7 +162,7 @@ public final class PropertyUtils ...@@ -139,7 +162,7 @@ public final class PropertyUtils
{ {
assertParameters(properties, propertyKey); assertParameters(properties, propertyKey);
assert defaultValue > -1 : "Negative default value (< 0)."; assert defaultValue > -1 : "Negative default value (< 0).";
final String longOrNull = properties.getProperty(propertyKey); final String longOrNull = getProperty(properties, propertyKey);
if (longOrNull == null) if (longOrNull == null)
{ {
return defaultValue; return defaultValue;
...@@ -176,7 +199,7 @@ public final class PropertyUtils ...@@ -176,7 +199,7 @@ public final class PropertyUtils
final int defaultValue, final ISimpleLogger loggerOrNull) final int defaultValue, final ISimpleLogger loggerOrNull)
{ {
assertParameters(properties, propertyKey); assertParameters(properties, propertyKey);
final String intOrNull = properties.getProperty(propertyKey); final String intOrNull = getProperty(properties, propertyKey);
if (intOrNull == null) if (intOrNull == null)
{ {
return defaultValue; return defaultValue;
...@@ -214,7 +237,7 @@ public final class PropertyUtils ...@@ -214,7 +237,7 @@ public final class PropertyUtils
{ {
assertParameters(properties, propertyKey); assertParameters(properties, propertyKey);
assert defaultValue > -1 : "Negative default value (< 0)."; assert defaultValue > -1 : "Negative default value (< 0).";
final String intOrNull = properties.getProperty(propertyKey); final String intOrNull = getProperty(properties, propertyKey);
if (intOrNull == null) if (intOrNull == null)
{ {
return defaultValue; return defaultValue;
...@@ -251,7 +274,7 @@ public final class PropertyUtils ...@@ -251,7 +274,7 @@ public final class PropertyUtils
final boolean defaultValue, final ISimpleLogger loggerOrNull) final boolean defaultValue, final ISimpleLogger loggerOrNull)
{ {
assertParameters(properties, propertyKey); assertParameters(properties, propertyKey);
final String booleanOrNull = properties.getProperty(propertyKey); final String booleanOrNull = getProperty(properties, propertyKey);
if (booleanOrNull == null) if (booleanOrNull == null)
{ {
return defaultValue; return defaultValue;
...@@ -289,7 +312,7 @@ public final class PropertyUtils ...@@ -289,7 +312,7 @@ public final class PropertyUtils
final char defaultValue, final ISimpleLogger loggerOrNull) final char defaultValue, final ISimpleLogger loggerOrNull)
{ {
assertParameters(properties, propertyKey); assertParameters(properties, propertyKey);
final String charOrNull = properties.getProperty(propertyKey); final String charOrNull = getProperty(properties, propertyKey);
if (charOrNull == null) if (charOrNull == null)
{ {
return defaultValue; return defaultValue;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment