This is an automated email from the ASF dual-hosted git repository.
prhomberg pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/develop by this push:
new 4ad6337 GEODE-4733: Remove unused and inline trivial ObjectUtils
methods.
4ad6337 is described below
commit 4ad633773b1fffe9ce5a71ea95fc5410d54d90fc
Author: Patrick Rhomberg <[email protected]>
AuthorDate: Wed Feb 28 11:12:36 2018 -0800
GEODE-4733: Remove unused and inline trivial ObjectUtils methods.
---
.../internal/locator/LocatorStatusResponse.java | 30 +++--
.../apache/geode/distributed/AbstractLauncher.java | 9 +-
.../apache/geode/distributed/LocatorLauncher.java | 10 +-
.../apache/geode/distributed/ServerLauncher.java | 10 +-
.../apache/geode/internal/lang/ObjectUtils.java | 124 ---------------------
.../org/apache/geode/internal/util/IOUtils.java | 4 +-
.../web/controllers/ShellCommandsController.java | 3 +-
.../SerializableObjectHttpMessageConverter.java | 4 +-
.../geode/internal/lang/ObjectUtilsJUnitTest.java | 88 ---------------
9 files changed, 36 insertions(+), 246 deletions(-)
diff --git
a/geode-core/src/main/java/org/apache/geode/cache/client/internal/locator/LocatorStatusResponse.java
b/geode-core/src/main/java/org/apache/geode/cache/client/internal/locator/LocatorStatusResponse.java
index 3a1be1a..04a82f0 100644
---
a/geode-core/src/main/java/org/apache/geode/cache/client/internal/locator/LocatorStatusResponse.java
+++
b/geode-core/src/main/java/org/apache/geode/cache/client/internal/locator/LocatorStatusResponse.java
@@ -101,8 +101,7 @@ public class LocatorStatusResponse extends
ServerLocationResponse {
@SuppressWarnings("unchecked")
public List<String> getJvmArgs() {
- return Collections
- .unmodifiableList(ObjectUtils.defaultIfNull(jvmArgs,
Collections.emptyList()));
+ return Collections.unmodifiableList(jvmArgs != null ? jvmArgs :
Collections.emptyList());
}
public Integer getPid() {
@@ -220,7 +219,8 @@ public class LocatorStatusResponse extends
ServerLocationResponse {
}
protected void writePid(final DataOutput out) throws IOException {
- out.writeInt(ObjectUtils.defaultIfNull(getPid(), 0));
+ Integer pid = getPid();
+ out.writeInt(pid != null ? pid : (Integer) 0);
}
protected void writeUptime(final DataOutput out) throws IOException {
@@ -228,7 +228,8 @@ public class LocatorStatusResponse extends
ServerLocationResponse {
}
protected void writeWorkingDirectory(final DataOutput out) throws
IOException {
- out.writeUTF(ObjectUtils.defaultIfNull(getWorkingDirectory(), ""));
+ String workingDir = getWorkingDirectory();
+ out.writeUTF(workingDir != null ? workingDir : "");
}
protected void writeJvmArguments(final DataOutput out) throws IOException {
@@ -240,31 +241,38 @@ public class LocatorStatusResponse extends
ServerLocationResponse {
}
protected void writeClasspath(final DataOutput out) throws IOException {
- out.writeUTF(ObjectUtils.defaultIfNull(getClasspath(), ""));
+ String classpath = getClasspath();
+ out.writeUTF(classpath != null ? classpath : "");
}
protected void writeGemFireVersion(final DataOutput out) throws IOException {
- out.writeUTF(ObjectUtils.defaultIfNull(getGemFireVersion(), ""));
+ String version = getGemFireVersion();
+ out.writeUTF(version != null ? version : "");
}
protected void writeJavaVersion(final DataOutput out) throws IOException {
- out.writeUTF(ObjectUtils.defaultIfNull(getJavaVersion(), ""));
+ String version = getJavaVersion();
+ out.writeUTF(version != null ? version : "");
}
protected void writeLogFile(final DataOutput out) throws IOException {
- out.writeUTF(ObjectUtils.defaultIfNull(getLogFile(), ""));
+ String log = getLogFile();
+ out.writeUTF(log != null ? log : "");
}
protected void writeHost(final DataOutput out) throws IOException {
- out.writeUTF(ObjectUtils.defaultIfNull(getHost(), ""));
+ String host = getHost();
+ out.writeUTF(host != null ? host : "");
}
protected void writePort(final DataOutput out) throws IOException {
- out.writeInt(ObjectUtils.defaultIfNull(getPort(), 0));
+ Integer port = getPort();
+ out.writeInt(port != null ? port : (Integer) 0);
}
protected void writeName(final DataOutput out) throws IOException {
- out.writeUTF(ObjectUtils.defaultIfNull(getName(), ""));
+ String name = getName();
+ out.writeUTF(name != null ? name : "");
}
@Override
diff --git
a/geode-core/src/main/java/org/apache/geode/distributed/AbstractLauncher.java
b/geode-core/src/main/java/org/apache/geode/distributed/AbstractLauncher.java
index ee1656c..8f56299 100644
---
a/geode-core/src/main/java/org/apache/geode/distributed/AbstractLauncher.java
+++
b/geode-core/src/main/java/org/apache/geode/distributed/AbstractLauncher.java
@@ -19,14 +19,12 @@ import static org.apache.commons.lang.StringUtils.join;
import static org.apache.commons.lang.StringUtils.lowerCase;
import static org.apache.geode.distributed.ConfigurationProperties.NAME;
import static org.apache.geode.internal.lang.ClassUtils.forName;
-import static org.apache.geode.internal.lang.ObjectUtils.defaultIfNull;
import static org.apache.geode.internal.lang.StringUtils.defaultString;
import static org.apache.geode.internal.lang.SystemUtils.CURRENT_DIRECTORY;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
-import java.io.UncheckedIOException;
import java.net.BindException;
import java.net.InetAddress;
import java.net.URISyntaxException;
@@ -551,8 +549,7 @@ public abstract class AbstractLauncher<T extends
Comparable<T>> implements Runna
this.pid = pid;
this.uptime = uptime;
this.workingDirectory = workingDirectory;
- this.jvmArguments =
defaultIfNull(Collections.unmodifiableList(jvmArguments),
- Collections.<String>emptyList());
+ this.jvmArguments = Collections.unmodifiableList(jvmArguments);
this.classpath = classpath;
this.gemfireVersion = gemfireVersion;
this.javaVersion = javaVersion;
@@ -724,7 +721,7 @@ public abstract class AbstractLauncher<T extends
Comparable<T>> implements Runna
* @return a String value indicating the GemFire service's working
(running) directory.
*/
public String getWorkingDirectory() {
- return defaultIfNull(workingDirectory, DEFAULT_WORKING_DIRECTORY);
+ return workingDirectory != null ? workingDirectory :
DEFAULT_WORKING_DIRECTORY;
}
/**
@@ -800,7 +797,7 @@ public abstract class AbstractLauncher<T extends
Comparable<T>> implements Runna
// the value of the String, or "" if value is null
protected String toString(final String value) {
- return defaultIfNull(value, "");
+ return value != null ? value : "";
}
}
diff --git
a/geode-core/src/main/java/org/apache/geode/distributed/LocatorLauncher.java
b/geode-core/src/main/java/org/apache/geode/distributed/LocatorLauncher.java
index 5c2b75d..1dbf0af 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/LocatorLauncher.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/LocatorLauncher.java
@@ -20,7 +20,6 @@ import static org.apache.commons.lang.StringUtils.isNotBlank;
import static org.apache.commons.lang.StringUtils.lowerCase;
import static org.apache.geode.distributed.ConfigurationProperties.LOG_FILE;
import static org.apache.geode.distributed.ConfigurationProperties.NAME;
-import static org.apache.geode.internal.lang.ObjectUtils.defaultIfNull;
import static org.apache.geode.internal.lang.StringUtils.wrap;
import static org.apache.geode.internal.lang.SystemUtils.CURRENT_DIRECTORY;
import static
org.apache.geode.internal.util.IOUtils.tryGetCanonicalPathElseGetAbsolutePath;
@@ -452,7 +451,8 @@ public class LocatorLauncher extends
AbstractLauncher<String> {
* @see #getPort()
*/
public String getPortAsString() {
- return defaultIfNull(getPort(), getDefaultLocatorPort()).toString();
+ Integer port = getPort();
+ return (port != null ? port : getDefaultLocatorPort()).toString();
}
/**
@@ -1341,7 +1341,7 @@ public class LocatorLauncher extends
AbstractLauncher<String> {
* @see LocatorLauncher.Command
*/
public Command getCommand() {
- return defaultIfNull(this.command, DEFAULT_COMMAND);
+ return this.command != null ? this.command : DEFAULT_COMMAND;
}
/**
@@ -1426,7 +1426,7 @@ public class LocatorLauncher extends
AbstractLauncher<String> {
* @see #setForce(Boolean)
*/
public Boolean getForce() {
- return defaultIfNull(this.force, DEFAULT_FORCE);
+ return this.force != null ? this.force : DEFAULT_FORCE;
}
/**
@@ -1634,7 +1634,7 @@ public class LocatorLauncher extends
AbstractLauncher<String> {
* @see #setPort(Integer)
*/
public Integer getPort() {
- return defaultIfNull(port, getDefaultLocatorPort());
+ return port != null ? port : getDefaultLocatorPort();
}
/**
diff --git
a/geode-core/src/main/java/org/apache/geode/distributed/ServerLauncher.java
b/geode-core/src/main/java/org/apache/geode/distributed/ServerLauncher.java
index 32e45e8..f456a99 100755
--- a/geode-core/src/main/java/org/apache/geode/distributed/ServerLauncher.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/ServerLauncher.java
@@ -22,7 +22,6 @@ import static org.apache.commons.lang.StringUtils.lowerCase;
import static org.apache.geode.distributed.ConfigurationProperties.LOG_FILE;
import static org.apache.geode.distributed.ConfigurationProperties.NAME;
import static
org.apache.geode.distributed.ConfigurationProperties.SERVER_BIND_ADDRESS;
-import static org.apache.geode.internal.lang.ObjectUtils.defaultIfNull;
import static org.apache.geode.internal.lang.StringUtils.wrap;
import static org.apache.geode.internal.lang.SystemUtils.CURRENT_DIRECTORY;
import static
org.apache.geode.internal.util.IOUtils.tryGetCanonicalPathElseGetAbsolutePath;
@@ -550,7 +549,8 @@ public class ServerLauncher extends
AbstractLauncher<String> {
* @see #getServerPort()
*/
public String getServerPortAsString() {
- return defaultIfNull(getServerPort(), getDefaultServerPort()).toString();
+ Integer v1 = getServerPort();
+ return (v1 != null ? v1 : getDefaultServerPort()).toString();
}
/**
@@ -1660,7 +1660,7 @@ public class ServerLauncher extends
AbstractLauncher<String> {
* @see org.apache.geode.distributed.ServerLauncher.Command
*/
public Command getCommand() {
- return defaultIfNull(this.command, DEFAULT_COMMAND);
+ return this.command != null ? this.command : DEFAULT_COMMAND;
}
/**
@@ -1803,7 +1803,7 @@ public class ServerLauncher extends
AbstractLauncher<String> {
* @see #setForce(Boolean)
*/
public Boolean getForce() {
- return defaultIfNull(this.force, DEFAULT_FORCE);
+ return this.force != null ? this.force : DEFAULT_FORCE;
}
/**
@@ -2038,7 +2038,7 @@ public class ServerLauncher extends
AbstractLauncher<String> {
* @see #setServerPort(Integer)
*/
public Integer getServerPort() {
- return defaultIfNull(this.serverPort, getDefaultServerPort());
+ return this.serverPort != null ? this.serverPort :
getDefaultServerPort();
}
boolean isServerPortSetByUser() {
diff --git
a/geode-core/src/main/java/org/apache/geode/internal/lang/ObjectUtils.java
b/geode-core/src/main/java/org/apache/geode/internal/lang/ObjectUtils.java
index 888f672..eff0f5c 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/lang/ObjectUtils.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/lang/ObjectUtils.java
@@ -15,9 +15,6 @@
package org.apache.geode.internal.lang;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
/**
* The ObjectUtils class is an abstract utility class for working with and
invoking methods on
* Objects.
@@ -29,31 +26,6 @@ import java.lang.reflect.Method;
@SuppressWarnings("unused")
public abstract class ObjectUtils {
- public static final Object[] EMPTY_OBJECT_ARRAY = new Object[0];
-
- /**
- * Gets the first non-null value in an array of values. If the array is
null, then null is
- * returned, otherwise the first non-null array element is returned. If the
array is not null and
- * all the array elements are null, then null is still returned.
- * <p/>
- *
- * @param <T> a type parameter specifying the array element type.
- * @param values the array of values being iterated for the first non-null
value.
- * @return the first non-null value from the array of values, otherwise
return null if either the
- * array is null or all the elements of the array are null.
- */
- public static <T> T defaultIfNull(T... values) {
- if (values != null) {
- for (T value : values) {
- if (value != null) {
- return value;
- }
- }
- }
-
- return null;
- }
-
/**
* Determines whether 2 Objects are equal in value. The Objects are equal if
and only if neither
* are null and are equal according to the equals method of the Object's
class type.
@@ -112,100 +84,4 @@ public abstract class ObjectUtils {
return (obj == null ? null : obj.toString());
}
- /**
- * Gets the Class types of all arguments in the Object array.
- * <p/>
- *
- * @param args the Object array of arguments to determine the Class types
for.
- * @return a Class array containing the Class types of each argument in the
arguments Object
- * array.
- * @see #invoke(Object, String, Object...)
- */
- static Class[] getArgumentTypes(final Object... args) {
- Class[] argTypes = null;
-
- if (args != null) {
- int index = 0;
- argTypes = new Class[args.length];
- for (Object arg : args) {
- argTypes[index++] = ClassUtils.getClass(arg);
- }
- }
-
- return argTypes;
- }
-
- /**
- * Invokes a method by name on the specified Object using Java Reflection.
- * <p/>
- *
- * @param obj the Object in which to invoke the method on.
- * @param methodName a String value indication the name of the method to
invoke.
- * @param <T> a generic type parameter for the method return value.
- * @return a value of the method invocation on Object cast to the generized
type.
- * @see #invoke(Object, String, Class[], Object...)
- */
- public static <T> T invoke(final Object obj, final String methodName) {
- return invoke(obj, methodName, (Class<?>[]) null, (Object[]) null);
- }
-
- /**
- * Invokes a method by name on the specified Object using Java Reflection.
- * <p/>
- *
- * @param obj the Object in which to invoke the method on.
- * @param methodName a String value indication the name of the method to
invoke.
- * @param arguments the Object arguments to the method based on its
parameters.
- * @param <T> a generic type parameter for the method return value.
- * @return a value of the method invocation on Object cast to the generized
type.
- * @see #getArgumentTypes(Object...)
- * @see #invoke(Object, String, Class[], Object...)
- */
- public static <T> T invoke(final Object obj, final String methodName, final
Object... arguments) {
- return invoke(obj, methodName, getArgumentTypes(arguments), arguments);
- }
-
- /**
- * Invokes a method by name on the specified Object using Java Reflection.
- * <p/>
- *
- * @param obj the Object in which to invoke the method on.
- * @param methodName a String value indication the name of the method to
invoke.
- * @param parameterTypes the Class types of parameters indicating the exact
method to invoke
- * (parameters in number, order and type) if the method is overloaded.
- * @param arguments the Object arguments to the method based on its
parameters.
- * @param <T> a generic type parameter for the method return value.
- * @return a value of the method invocation on Object cast to the generized
type.
- */
- @SuppressWarnings("unchecked")
- public static <T> T invoke(final Object obj, final String methodName,
- final Class<?>[] parameterTypes, final Object... arguments) {
- assert obj != null : String.format("The Object to invoke method (%1$s) on
cannot be null!",
- methodName);
- assert methodName != null : String.format(
- "The name of the method to invoke on Object of type (%1$s) cannot be
null",
- obj.getClass().getName());
-
- try {
- final Method method = obj.getClass().getMethod(methodName,
parameterTypes);
- method.setAccessible(true);
- return (T) method.invoke(obj, arguments);
- } catch (NoSuchMethodException e) {
- throw new RuntimeException(
- String.format("Method (%1$s) does not exist on Object of type
(%2$s)!", methodName,
- obj.getClass().getName()),
- e);
- } catch (InvocationTargetException e) {
- throw new RuntimeException(
- String.format("The invocation of method (%1$s) on an Object of type
(%2$s) failed!",
- methodName, obj.getClass().getName()),
- e);
- } catch (IllegalAccessException e) {
- throw new RuntimeException(
- String.format("The method (%1$s) on an Object of type (%2$s) is not
accessible!",
- methodName, obj.getClass().getName()),
- e);
- }
- }
-
}
diff --git
a/geode-core/src/main/java/org/apache/geode/internal/util/IOUtils.java
b/geode-core/src/main/java/org/apache/geode/internal/util/IOUtils.java
index 9ae2a1f..a2432e2 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/util/IOUtils.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/util/IOUtils.java
@@ -27,8 +27,6 @@ import java.io.ObjectStreamClass;
import org.apache.commons.lang.StringUtils;
-import org.apache.geode.internal.lang.ObjectUtils;
-
/**
* Reusable Input/Output operation utility methods.
*
@@ -106,7 +104,7 @@ public abstract class IOUtils {
* @see java.io.File#separator
*/
public static String createPath(final String[] pathElements, String
separator) {
- separator = ObjectUtils.defaultIfNull(separator, File.separator);
+ separator = separator != null ? separator : File.separator;
final StringBuilder buffer = new StringBuilder();
diff --git
a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/ShellCommandsController.java
b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/ShellCommandsController.java
index 6b2d5f9..e25ea7d 100644
---
a/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/ShellCommandsController.java
+++
b/geode-core/src/main/java/org/apache/geode/management/internal/web/controllers/ShellCommandsController.java
@@ -46,7 +46,6 @@ import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.apache.geode.internal.GemFireVersion;
-import org.apache.geode.internal.lang.ObjectUtils;
import org.apache.geode.internal.util.IOUtils;
import org.apache.geode.management.cli.Result;
import org.apache.geode.management.internal.cli.result.CommandResult;
@@ -98,7 +97,7 @@ public class ShellCommandsController extends
AbstractCommandsController {
ReflectionException, IOException {
// Exceptions are caught by the @ExceptionHandler
AbstractCommandsController.handleAppException
signature = (signature != null ? signature :
ArrayUtils.EMPTY_STRING_ARRAY);
- parameters = (parameters != null ? parameters :
ObjectUtils.EMPTY_OBJECT_ARRAY);
+ parameters = (parameters != null ? parameters :
ArrayUtils.EMPTY_OBJECT_ARRAY);
MBeanServer mBeanServer = getMBeanServer();
ObjectName objectName = ObjectName.getInstance(decode(resourceName));
final Object result =
diff --git
a/geode-core/src/main/java/org/apache/geode/management/internal/web/http/converter/SerializableObjectHttpMessageConverter.java
b/geode-core/src/main/java/org/apache/geode/management/internal/web/http/converter/SerializableObjectHttpMessageConverter.java
index 13ae90e..ce3ba15 100644
---
a/geode-core/src/main/java/org/apache/geode/management/internal/web/http/converter/SerializableObjectHttpMessageConverter.java
+++
b/geode-core/src/main/java/org/apache/geode/management/internal/web/http/converter/SerializableObjectHttpMessageConverter.java
@@ -26,7 +26,6 @@ import
org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.http.converter.HttpMessageNotWritableException;
import org.springframework.util.StreamUtils;
-import org.apache.geode.internal.lang.ObjectUtils;
import org.apache.geode.internal.util.IOUtils;
/**
@@ -73,8 +72,9 @@ public class SerializableObjectHttpMessageConverter
protected Serializable readInternal(final Class<? extends Serializable> type,
final HttpInputMessage inputMessage) throws IOException,
HttpMessageNotReadableException {
try {
+ ClassLoader classLoader = type.getClassLoader();
return
type.cast(IOUtils.deserializeObject(IOUtils.toByteArray(inputMessage.getBody()),
- ObjectUtils.defaultIfNull(type.getClassLoader(),
getClass().getClassLoader())));
+ classLoader != null ? classLoader : getClass().getClassLoader()));
} catch (ClassNotFoundException e) {
throw new HttpMessageNotReadableException(
String.format("Unable to convert the HTTP message body into an
Object of type (%1$s)",
diff --git
a/geode-core/src/test/java/org/apache/geode/internal/lang/ObjectUtilsJUnitTest.java
b/geode-core/src/test/java/org/apache/geode/internal/lang/ObjectUtilsJUnitTest.java
index 4ea9ec8..e5d685f 100644
---
a/geode-core/src/test/java/org/apache/geode/internal/lang/ObjectUtilsJUnitTest.java
+++
b/geode-core/src/test/java/org/apache/geode/internal/lang/ObjectUtilsJUnitTest.java
@@ -29,26 +29,11 @@ import org.apache.geode.test.junit.categories.UnitTest;
* @see org.apache.geode.internal.lang.ObjectUtils
* @see org.junit.Assert
* @see org.junit.Test
- * @since GemFire 6.8
*/
@Category(UnitTest.class)
public class ObjectUtilsJUnitTest {
@Test
- public void testDefaultIfNull() {
- assertNull(ObjectUtils.defaultIfNull());
- assertNull(ObjectUtils.defaultIfNull((Object[]) null));
- assertNull(ObjectUtils.defaultIfNull(null, null));
- assertNull(ObjectUtils.defaultIfNull(null, null, null));
- assertEquals("test", ObjectUtils.defaultIfNull(null, null, "test"));
- assertEquals("test", ObjectUtils.defaultIfNull("test", null));
- assertEquals("test", ObjectUtils.defaultIfNull("test"));
- assertEquals("test", ObjectUtils.defaultIfNull("test", "mock", "assert"));
- assertEquals("null", ObjectUtils.defaultIfNull(null, "null", null));
- assertEquals("null", ObjectUtils.defaultIfNull("null", "test", null));
- }
-
- @Test
public void testEqualsWithUnequalObjects() {
assertFalse(ObjectUtils.equals(null, null));
assertFalse(ObjectUtils.equals(null, "null"));
@@ -111,77 +96,4 @@ public class ObjectUtilsJUnitTest {
assertEquals(String.valueOf(Math.PI), ObjectUtils.toString(Math.PI));
assertEquals("true", ObjectUtils.toString(Boolean.TRUE));
}
-
- @Test
- public void testGetArgumentsTypesForNullArgumentsObjectArray() {
- assertNull(ObjectUtils.getArgumentTypes((Object[]) null));
- }
-
- @Test
- public void testGetArgumentsTypesForEmptyArgumentsObjectArray() {
- final Class[] argumentTypes = ObjectUtils.getArgumentTypes(new Object[0]);
-
- assertNotNull(argumentTypes);
- assertEquals(0, argumentTypes.length);
- }
-
- @Test
- public void testGetArgumentsTypes() {
- final Object[] arguments = {true, 'A', 0, Math.PI, "test"};
- final Class[] argumentTypes = ObjectUtils.getArgumentTypes(arguments);
-
- assertNotNull(argumentTypes);
- assertEquals(arguments.length, argumentTypes.length);
-
- int index = 0;
-
- for (Object argument : arguments) {
- assertEquals(argument.getClass(), argumentTypes[index++]);
- }
- }
-
- @Test
- public void testInvoke() {
- final ValueHolder<String> value = new ValueHolder<String>("test");
-
- assertEquals("test", ObjectUtils.invoke(value, "getValue"));
- }
-
- @Test
- public void testInvokeWithArguments() {
- final ValueHolder<String> value = new ValueHolder<String>("test");
-
- assertEquals("TEST", ObjectUtils.invoke(value, "transform", true));
- }
-
- @Test
- public void testInvokeWithParametersAndArguments() {
- final ValueHolder<Integer> value = new ValueHolder<Integer>(1);
-
- assertEquals("1 is the loneliest number!", ObjectUtils.invoke(value,
"transform",
- new Class[] {String.class}, " is the loneliest number!"));
- }
-
- private static class ValueHolder<T> {
-
- private final T value;
-
- public ValueHolder(final T value) {
- assert value != null : "The value for this holder cannot be null!";
- this.value = value;
- }
-
- public T getValue() {
- return value;
- }
-
- public Object transform(final Boolean upperCase) {
- return String.valueOf(getValue()).toUpperCase();
- }
-
- public Object transform(final String concatenationValue) {
- return (String.valueOf(getValue()) + concatenationValue);
- }
- }
-
}
--
To stop receiving notification emails like this one, please contact
[email protected].