Author: alessio.soldano(a)jboss.com
Date: 2013-07-03 18:01:47 -0400 (Wed, 03 Jul 2013)
New Revision: 578
Modified:
core/trunk/core/src/main/java/org/jboss/wise/core/utils/JavaUtils.java
core/trunk/core/src/main/java/org/jboss/wise/core/utils/ReflectionUtils.java
Log:
Few minor optimizations/cleanup
Modified: core/trunk/core/src/main/java/org/jboss/wise/core/utils/JavaUtils.java
===================================================================
--- core/trunk/core/src/main/java/org/jboss/wise/core/utils/JavaUtils.java 2013-07-03
21:45:50 UTC (rev 577)
+++ core/trunk/core/src/main/java/org/jboss/wise/core/utils/JavaUtils.java 2013-07-03
22:01:47 UTC (rev 578)
@@ -31,7 +31,7 @@
*/
public class JavaUtils {
- private static HashMap<String, Class<?>> primitiveNames = new
HashMap<String, Class<?>>(8);
+ private static HashMap<String, Class<?>> primitiveNames = new
HashMap<String, Class<?>>(12);
static {
primitiveNames.put("int", int.class);
Modified: core/trunk/core/src/main/java/org/jboss/wise/core/utils/ReflectionUtils.java
===================================================================
---
core/trunk/core/src/main/java/org/jboss/wise/core/utils/ReflectionUtils.java 2013-07-03
21:45:50 UTC (rev 577)
+++
core/trunk/core/src/main/java/org/jboss/wise/core/utils/ReflectionUtils.java 2013-07-03
22:01:47 UTC (rev 578)
@@ -24,7 +24,6 @@
import java.lang.reflect.Field;
import java.util.LinkedList;
import java.util.List;
-import javax.xml.bind.annotation.XmlElement;
/**
* Provides some utility methods useful to deal with classes through reflection.
@@ -63,15 +62,11 @@
*/
public static String setterMethodName( String fieldName,
boolean isBoolean ) {
- String setter = "set" + JavaUtils.capitalize(fieldName);
- if (isBoolean) {
- if (fieldName.startsWith("is")) {
- setter = "set" + fieldName.substring(2);
- } else {
- setter = "set" + JavaUtils.capitalize(fieldName);
- }
+ if (!isBoolean) {
+ return "set" + JavaUtils.capitalize(fieldName);
+ } else {
+ return "set" + (fieldName.startsWith("is") ?
fieldName.substring(2) : JavaUtils.capitalize(fieldName));
}
- return setter;
}
/**
@@ -83,15 +78,11 @@
*/
public static String getterMethodName( String fieldName,
boolean isBoolean ) {
- String getter = "get" + JavaUtils.capitalize(fieldName);
- if (isBoolean) {
- if (fieldName.startsWith("is")) {
- getter = fieldName;
- } else {
- getter = "is" + JavaUtils.capitalize(fieldName);
- }
- }
- return getter;
+ if (!isBoolean) {
+ return "get" + JavaUtils.capitalize(fieldName);
+ } else {
+ return fieldName.startsWith("is") ? fieldName : "is" +
JavaUtils.capitalize(fieldName);
+ }
}
/**
@@ -104,13 +95,8 @@
Class cl = field.getType();
if (cl.isPrimitive()) {
cl = JavaUtils.getWrapperType(cl);
-
}
String cap = JavaUtils.capitalize(field.getName());
- if (cl.getName().equalsIgnoreCase("java.lang.Boolean")) {
- return "is" + cap;
- } else {
- return "get" + cap;
- }
+ return cl.getName().equalsIgnoreCase("java.lang.Boolean") ?
"is" + cap : "get" + cap;
}
}
Show replies by date