Author: davsclaus
Date: Wed Dec 10 09:09:21 2008
New Revision: 725343
URL: http://svn.apache.org/viewvc?rev=725343&view=rev
Log:
CAMEL-1155: Refactored ObjectHelper to use isEmpty, isNotEmpty for null and
empty string tests.
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileComponent.java
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/RenameFileProcessStrategy.java
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileComponent.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileComponent.java?rev=725343&r1=725342&r2=725343&view=diff
==============================================================================
---
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileComponent.java
(original)
+++
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileComponent.java
Wed Dec 10 09:09:21 2008
@@ -94,7 +94,7 @@
boolean ignoreCase = reminder.startsWith("ignoreCase:");
reminder = ignoreCase ? ifStartsWithReturnRemainder("ignoreCase:",
reminder) : reminder;
- ObjectHelper.notNull(reminder, "sortBy expression");
+ ObjectHelper.notEmpty(reminder, "sortBy expression", this);
// recursive add nested sorters
return DefaultFileSorter.sortByFileLanguage(reminder, reverse,
ignoreCase, createSortByComparator(it));
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/RenameFileProcessStrategy.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/RenameFileProcessStrategy.java?rev=725343&r1=725342&r2=725343&view=diff
==============================================================================
---
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/RenameFileProcessStrategy.java
(original)
+++
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/RenameFileProcessStrategy.java
Wed Dec 10 09:09:21 2008
@@ -62,7 +62,6 @@
if (beginRenamer != null) {
File newName = beginRenamer.renameFile(exchange, file);
- // deleting any existing files before renaming
File to = renameFile(file, newName);
exchange.setFile(to);
}
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java?rev=725343&r1=725342&r2=725343&view=diff
==============================================================================
---
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
(original)
+++
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
Wed Dec 10 09:09:21 2008
@@ -157,33 +157,64 @@
}
/**
- * Asserts whether the value is <b>not</b> <tt>null</tt> or an empty
string.
+ * Asserts whether the value is <b>not</b> <tt>null</tt>
*
* @param value the value to test
* @param name the key that resolved the value
+ * @throws IllegalArgumentException is thrown if assertion fails
*/
public static void notNull(Object value, String name) {
- if (isEmpty(value)) {
+ if (value == null) {
throw new IllegalArgumentException(name + " must be specified");
}
}
/**
- * Asserts whether the value is <b>not</b> <tt>null</tt> or an empty
string.
+ * Asserts whether the value is <b>not</b> <tt>null</tt>
*
* @param value the value to test
* @param on additional description to indicate where this problem
occured (appended as toString())
* @param name the key that resolved the value
+ * @throws IllegalArgumentException is thrown if assertion fails
*/
public static void notNull(Object value, String name, Object on) {
if (on == null) {
notNull(value, name);
- } else if (isEmpty(value)) {
+ } else if (value == null) {
throw new IllegalArgumentException(name + " must be specified on:
" + on);
}
}
/**
+ * Asserts whether the string is <b>not</b> empty.
+ *
+ * @param value the string to test
+ * @param name the key that resolved the value
+ * @throws IllegalArgumentException is thrown if assertion fails
+ */
+ public static void notEmpty(String value, String name) {
+ if (isEmpty(value)) {
+ throw new IllegalArgumentException(name + " must be specified and
not empty");
+ }
+ }
+
+ /**
+ * Asserts whether the string is <b>not</b> empty.
+ *
+ * @param value the string to test
+ * @param on additional description to indicate where this problem
occured (appended as toString())
+ * @param name the key that resolved the value
+ * @throws IllegalArgumentException is thrown if assertion fails
+ */
+ public static void notEmpty(String value, String name, Object on) {
+ if (on == null) {
+ notNull(value, name);
+ } else if (isEmpty(value)) {
+ throw new IllegalArgumentException(name + " must be specified and
not empty on: " + on);
+ }
+ }
+
+ /**
* Tests whether the value is <tt>null</tt> or an empty string.
*
* @param value the value, if its a String it will be tested for text
length as well