mirror of https://github.com/apache/openjpa.git
OPENJPA-1700 FindBugs - Method invokes inefficient Number constructor; use static valueOf instead
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@955046 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5e2f6c2288
commit
8a2b1c1f08
|
@ -89,7 +89,7 @@ public abstract class AbstractQueryCache
|
|||
// Pre-load all the entity types into the HashMap to handle
|
||||
// synchronization on the map efficiently
|
||||
for (Object o : perTypes)
|
||||
entityTimestampMap.put((String)o, new Long(0));
|
||||
entityTimestampMap.put((String)o, Long.valueOf(0));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ public abstract class AbstractQueryCache
|
|||
Collection changedTypes = ev.getTypes();
|
||||
HashMap<String,Long> changedClasses =
|
||||
new HashMap<String,Long>();
|
||||
Long tstamp = new Long(System.currentTimeMillis());
|
||||
Long tstamp = Long.valueOf(System.currentTimeMillis());
|
||||
for (Object o: changedTypes) {
|
||||
String name = ((Class) o).getName();
|
||||
if(!changedClasses.containsKey(name)) {
|
||||
|
|
|
@ -144,10 +144,10 @@ public class ReflectingPersistenceCapable
|
|||
sm.replaceBooleanField(this, i)));
|
||||
break;
|
||||
case JavaTypes.BYTE:
|
||||
setValue(i, o, new Byte(sm.replaceByteField(this, i)));
|
||||
setValue(i, o, Byte.valueOf(sm.replaceByteField(this, i)));
|
||||
break;
|
||||
case JavaTypes.CHAR:
|
||||
setValue(i, o, new Character(sm.replaceCharField(this, i)));
|
||||
setValue(i, o, Character.valueOf(sm.replaceCharField(this, i)));
|
||||
break;
|
||||
case JavaTypes.DOUBLE:
|
||||
setValue(i, o, new Double(sm.replaceDoubleField(this, i)));
|
||||
|
@ -156,13 +156,13 @@ public class ReflectingPersistenceCapable
|
|||
setValue(i, o, new Float(sm.replaceFloatField(this, i)));
|
||||
break;
|
||||
case JavaTypes.INT:
|
||||
setValue(i, o, new Integer(sm.replaceIntField(this, i)));
|
||||
setValue(i, o, Integer.valueOf(sm.replaceIntField(this, i)));
|
||||
break;
|
||||
case JavaTypes.LONG:
|
||||
setValue(i, o, new Long(sm.replaceLongField(this, i)));
|
||||
setValue(i, o, Long.valueOf(sm.replaceLongField(this, i)));
|
||||
break;
|
||||
case JavaTypes.SHORT:
|
||||
setValue(i, o, new Short(sm.replaceShortField(this, i)));
|
||||
setValue(i, o, Short.valueOf(sm.replaceShortField(this, i)));
|
||||
break;
|
||||
case JavaTypes.STRING:
|
||||
setValue(i, o, sm.replaceStringField(this, i));
|
||||
|
|
|
@ -779,14 +779,14 @@ public class Reflection {
|
|||
* Invoke the given setter on the given object.
|
||||
*/
|
||||
public static void set(Object target, Method setter, byte value) {
|
||||
set(target, setter, new Byte(value));
|
||||
set(target, setter, Byte.valueOf(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke the given setter on the given object.
|
||||
*/
|
||||
public static void set(Object target, Method setter, char value) {
|
||||
set(target, setter, new Character(value));
|
||||
set(target, setter, Character.valueOf(value));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -807,21 +807,21 @@ public class Reflection {
|
|||
* Invoke the given setter on the given object.
|
||||
*/
|
||||
public static void set(Object target, Method setter, int value) {
|
||||
set(target, setter, new Integer(value));
|
||||
set(target, setter, Integer.valueOf(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke the given setter on the given object.
|
||||
*/
|
||||
public static void set(Object target, Method setter, long value) {
|
||||
set(target, setter, new Long(value));
|
||||
set(target, setter, Long.valueOf(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke the given setter on the given object.
|
||||
*/
|
||||
public static void set(Object target, Method setter, short value) {
|
||||
set(target, setter, new Short(value));
|
||||
set(target, setter, Short.valueOf(value));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1624,7 +1624,7 @@ public class BrokerImpl
|
|||
&& (tranStatus != Status.STATUS_COMMITTED))
|
||||
_runtime.setRollbackOnly(cause);
|
||||
else if (_log.isTraceEnabled())
|
||||
_log.trace(_loc.get("invalid-tran-status", new Integer(
|
||||
_log.trace(_loc.get("invalid-tran-status", Integer.valueOf(
|
||||
tranStatus), "setRollbackOnly"));
|
||||
} catch (OpenJPAException ke) {
|
||||
throw ke;
|
||||
|
|
|
@ -309,9 +309,9 @@ public class DetachedValueStateManager
|
|||
return (fm.fetchBooleanField(field)) ? Boolean.TRUE
|
||||
: Boolean.FALSE;
|
||||
case JavaTypes.BYTE:
|
||||
return new Byte(fm.fetchByteField(field));
|
||||
return Byte.valueOf(fm.fetchByteField(field));
|
||||
case JavaTypes.CHAR:
|
||||
return new Character(fm.fetchCharField(field));
|
||||
return Character.valueOf(fm.fetchCharField(field));
|
||||
case JavaTypes.DOUBLE:
|
||||
return new Double(fm.fetchDoubleField(field));
|
||||
case JavaTypes.FLOAT:
|
||||
|
@ -321,7 +321,7 @@ public class DetachedValueStateManager
|
|||
case JavaTypes.LONG:
|
||||
return fm.fetchLongField(field);
|
||||
case JavaTypes.SHORT:
|
||||
return new Short(fm.fetchShortField(field));
|
||||
return Short.valueOf(fm.fetchShortField(field));
|
||||
default:
|
||||
return fm.fetchObjectField(field);
|
||||
}
|
||||
|
|
|
@ -307,7 +307,7 @@ public class FetchConfigurationImpl
|
|||
&& flush != QueryFlushModes.FLUSH_FALSE
|
||||
&& flush != QueryFlushModes.FLUSH_WITH_CONNECTION)
|
||||
throw new IllegalArgumentException(_loc.get(
|
||||
"bad-flush-before-queries", new Integer(flush)).getMessage());
|
||||
"bad-flush-before-queries", Integer.valueOf(flush)).getMessage());
|
||||
|
||||
if (flush == DEFAULT && _state.ctx != null)
|
||||
_state.flushQuery = _state.ctx.getConfiguration().
|
||||
|
@ -549,7 +549,7 @@ public class FetchConfigurationImpl
|
|||
&& scope != LockScopes.LOCKSCOPE_NORMAL
|
||||
&& scope != LockScopes.LOCKSCOPE_EXTENDED)
|
||||
throw new IllegalArgumentException(_loc.get(
|
||||
"bad-lock-scope", new Integer(scope)).getMessage());
|
||||
"bad-lock-scope", Integer.valueOf(scope)).getMessage());
|
||||
if (scope == DEFAULT )
|
||||
_state.lockScope = LOCKSCOPE_NORMAL;
|
||||
else
|
||||
|
@ -575,7 +575,7 @@ public class FetchConfigurationImpl
|
|||
&& level != MixedLockLevels.LOCK_PESSIMISTIC_WRITE
|
||||
&& level != MixedLockLevels.LOCK_PESSIMISTIC_FORCE_INCREMENT)
|
||||
throw new IllegalArgumentException(_loc.get(
|
||||
"bad-lock-level", new Integer(level)).getMessage());
|
||||
"bad-lock-level", Integer.valueOf(level)).getMessage());
|
||||
|
||||
lock();
|
||||
try {
|
||||
|
@ -610,7 +610,7 @@ public class FetchConfigurationImpl
|
|||
&& level != MixedLockLevels.LOCK_PESSIMISTIC_WRITE
|
||||
&& level != MixedLockLevels.LOCK_PESSIMISTIC_FORCE_INCREMENT)
|
||||
throw new IllegalArgumentException(_loc.get(
|
||||
"bad-lock-level", new Integer(level)).getMessage());
|
||||
"bad-lock-level", Integer.valueOf(level)).getMessage());
|
||||
|
||||
lock();
|
||||
try {
|
||||
|
|
|
@ -298,7 +298,7 @@ public class Filters {
|
|||
else if (type == Character.class) {
|
||||
String str = o.toString();
|
||||
if (str != null && str.length() == 1)
|
||||
return new Character(str.charAt(0));
|
||||
return Character.valueOf(str.charAt(0));
|
||||
} else if (Calendar.class.isAssignableFrom(type) &&
|
||||
o instanceof Date) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
|
@ -359,9 +359,9 @@ public class Filters {
|
|||
} else if (type == BigInteger.class) {
|
||||
return new BigInteger(o.toString());
|
||||
} else if (type == Short.class && allowNumericConversion(o.getClass(), type, strictNumericConversion)) {
|
||||
return new Short(((Number) o).shortValue());
|
||||
return Short.valueOf(((Number) o).shortValue());
|
||||
} else if (type == Byte.class && allowNumericConversion(o.getClass(), type, strictNumericConversion)) {
|
||||
return new Byte(((Number) o).byteValue());
|
||||
return Byte.valueOf(((Number) o).byteValue());
|
||||
} else if (!strictNumericConversion) {
|
||||
return ((Number) o).intValue();
|
||||
} else {
|
||||
|
@ -1017,15 +1017,15 @@ public class Filters {
|
|||
|
||||
public static Object getDefaultForNull(Class<?> nType) {
|
||||
if (nType == Long.class)
|
||||
return new Long(0);
|
||||
return Long.valueOf(0);
|
||||
if (nType == Integer.class)
|
||||
return new Integer(0);
|
||||
return Integer.valueOf(0);
|
||||
if (nType == Double.class)
|
||||
return new Double(0.0);
|
||||
if (nType == Float.class)
|
||||
return new Float(0.0);
|
||||
if (nType == Short.class)
|
||||
return new Short((short)0);
|
||||
return Short.valueOf((short)0);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -47,11 +47,11 @@ import org.apache.openjpa.util.ImplHelper;
|
|||
public class ObjectIdStateManager
|
||||
implements OpenJPAStateManager {
|
||||
|
||||
private static final Byte ZERO_BYTE = new Byte((byte) 0);
|
||||
private static final Character ZERO_CHAR = new Character((char) 0);
|
||||
private static final Byte ZERO_BYTE = Byte.valueOf((byte)0);
|
||||
private static final Character ZERO_CHAR = Character.valueOf((char)0);
|
||||
private static final Double ZERO_DOUBLE = new Double(0);
|
||||
private static final Float ZERO_FLOAT = new Float(0);
|
||||
private static final Short ZERO_SHORT = new Short((short) 0);
|
||||
private static final Short ZERO_SHORT = Short.valueOf((short)0);
|
||||
|
||||
private Object _oid;
|
||||
private final OpenJPAStateManager _owner;
|
||||
|
@ -463,11 +463,11 @@ public class ObjectIdStateManager
|
|||
}
|
||||
|
||||
public void storeByte(int field, byte extVal) {
|
||||
setValue(field, new Byte(extVal), true);
|
||||
setValue(field, Byte.valueOf(extVal), true);
|
||||
}
|
||||
|
||||
public void storeChar(int field, char extVal) {
|
||||
setValue(field, new Character(extVal), true);
|
||||
setValue(field, Character.valueOf(extVal), true);
|
||||
}
|
||||
|
||||
public void storeInt(int field, int extVal) {
|
||||
|
@ -475,7 +475,7 @@ public class ObjectIdStateManager
|
|||
}
|
||||
|
||||
public void storeShort(int field, short extVal) {
|
||||
setValue(field, new Short(extVal), true);
|
||||
setValue(field, Short.valueOf(extVal), true);
|
||||
}
|
||||
|
||||
public void storeLong(int field, long extVal) {
|
||||
|
|
|
@ -848,9 +848,9 @@ public class StateManagerImpl
|
|||
return (fetchBooleanField(field)) ? Boolean.TRUE
|
||||
: Boolean.FALSE;
|
||||
case JavaTypes.BYTE:
|
||||
return new Byte(fetchByteField(field));
|
||||
return Byte.valueOf(fetchByteField(field));
|
||||
case JavaTypes.CHAR:
|
||||
return new Character(fetchCharField(field));
|
||||
return Character.valueOf(fetchCharField(field));
|
||||
case JavaTypes.DOUBLE:
|
||||
return new Double(fetchDoubleField(field));
|
||||
case JavaTypes.FLOAT:
|
||||
|
@ -860,7 +860,7 @@ public class StateManagerImpl
|
|||
case JavaTypes.LONG:
|
||||
return fetchLongField(field);
|
||||
case JavaTypes.SHORT:
|
||||
return new Short(fetchShortField(field));
|
||||
return Short.valueOf(fetchShortField(field));
|
||||
default:
|
||||
return fetchObjectField(field);
|
||||
}
|
||||
|
@ -979,9 +979,9 @@ public class StateManagerImpl
|
|||
return (fm.fetchBooleanField(field)) ? Boolean.TRUE
|
||||
: Boolean.FALSE;
|
||||
case JavaTypes.BYTE:
|
||||
return new Byte(fm.fetchByteField(field));
|
||||
return Byte.valueOf(fm.fetchByteField(field));
|
||||
case JavaTypes.CHAR:
|
||||
return new Character(fm.fetchCharField(field));
|
||||
return Character.valueOf(fm.fetchCharField(field));
|
||||
case JavaTypes.DOUBLE:
|
||||
return new Double(fm.fetchDoubleField(field));
|
||||
case JavaTypes.FLOAT:
|
||||
|
@ -991,7 +991,7 @@ public class StateManagerImpl
|
|||
case JavaTypes.LONG:
|
||||
return fm.fetchLongField(field);
|
||||
case JavaTypes.SHORT:
|
||||
return new Short(fm.fetchShortField(field));
|
||||
return Short.valueOf(fm.fetchShortField(field));
|
||||
case JavaTypes.STRING:
|
||||
return fm.fetchStringField(field);
|
||||
default:
|
||||
|
@ -2444,7 +2444,7 @@ public class StateManagerImpl
|
|||
if (!fmd.isExternalized())
|
||||
storeByteField(field, externalVal);
|
||||
else
|
||||
storeField(field, fmd.getFieldValue(new Byte(externalVal),
|
||||
storeField(field, fmd.getFieldValue(Byte.valueOf(externalVal),
|
||||
_broker));
|
||||
}
|
||||
|
||||
|
@ -2465,7 +2465,7 @@ public class StateManagerImpl
|
|||
if (!fmd.isExternalized())
|
||||
storeCharField(field, externalVal);
|
||||
else
|
||||
storeField(field, fmd.getFieldValue(new Character(externalVal),
|
||||
storeField(field, fmd.getFieldValue(Character.valueOf(externalVal),
|
||||
_broker));
|
||||
}
|
||||
|
||||
|
@ -2592,7 +2592,7 @@ public class StateManagerImpl
|
|||
if (!fmd.isExternalized())
|
||||
storeShortField(field, externalVal);
|
||||
else
|
||||
storeField(field, fmd.getFieldValue(new Short(externalVal),
|
||||
storeField(field, fmd.getFieldValue(Short.valueOf(externalVal),
|
||||
_broker));
|
||||
}
|
||||
|
||||
|
|
|
@ -1008,7 +1008,7 @@ public class JPQLExpressionBuilder
|
|||
? node.text.substring(0, node.text.length() - 1)
|
||||
: node.text).
|
||||
multiply(new BigDecimal(negative(node)));
|
||||
return factory.newLiteral(new Long(intlit.longValue()),
|
||||
return factory.newLiteral(Long.valueOf(intlit.longValue()),
|
||||
Literal.TYPE_NUMBER);
|
||||
|
||||
case JJTDECIMALLITERAL:
|
||||
|
@ -1431,13 +1431,13 @@ public class JPQLExpressionBuilder
|
|||
// optimize SQL for the common case of two literals
|
||||
long jpqlStart = ((Number) ((Literal) val2).getValue())
|
||||
.longValue();
|
||||
start = factory.newLiteral(new Long(jpqlStart - 1),
|
||||
start = factory.newLiteral(Long.valueOf(jpqlStart - 1),
|
||||
Literal.TYPE_NUMBER);
|
||||
if (val3 != null) {
|
||||
long length = ((Number) ((Literal) val3).getValue())
|
||||
.longValue();
|
||||
long endIndex = length + (jpqlStart - 1);
|
||||
end = factory.newLiteral(new Long(endIndex),
|
||||
end = factory.newLiteral(Long.valueOf(endIndex),
|
||||
Literal.TYPE_NUMBER);
|
||||
}
|
||||
} else {
|
||||
|
@ -2140,7 +2140,7 @@ public class JPQLExpressionBuilder
|
|||
private JPQLNode child(JPQLNode node, int childNum, int assertCount) {
|
||||
if (node.children.length != assertCount)
|
||||
throw parseException(EX_USER, "wrong-child-count",
|
||||
new Object[]{ new Integer(assertCount), node,
|
||||
new Object[]{ Integer.valueOf(assertCount), node,
|
||||
Arrays.asList(node.children) }, null);
|
||||
|
||||
return node.children[childNum];
|
||||
|
|
|
@ -1529,7 +1529,7 @@ public class FieldMetaData
|
|||
return Float.valueOf(val);
|
||||
case JavaTypes.CHAR:
|
||||
case JavaTypes.CHAR_OBJ:
|
||||
return new Character(val.charAt(0));
|
||||
return Character.valueOf(val.charAt(0));
|
||||
case JavaTypes.STRING:
|
||||
return val;
|
||||
case JavaTypes.ENUM:
|
||||
|
|
|
@ -272,20 +272,20 @@ public class JavaTypes {
|
|||
if (val instanceof Byte)
|
||||
return val;
|
||||
if (val instanceof Number)
|
||||
return new Byte(((Number) val).byteValue());
|
||||
return Byte.valueOf(((Number) val).byteValue());
|
||||
// no break
|
||||
case BYTE:
|
||||
if (val instanceof String)
|
||||
return new Byte(val.toString());
|
||||
return Byte.valueOf((String)val);
|
||||
return val;
|
||||
case CHAR:
|
||||
case CHAR_OBJ:
|
||||
if (val instanceof Character)
|
||||
return val;
|
||||
if (val instanceof String)
|
||||
return new Character(val.toString().charAt(0));
|
||||
return Character.valueOf(val.toString().charAt(0));
|
||||
if (val instanceof Number)
|
||||
return new Character((char) ((Number) val).intValue());
|
||||
return Character.valueOf((char) ((Number) val).intValue());
|
||||
return val;
|
||||
case DATE:
|
||||
if (val instanceof String)
|
||||
|
@ -319,7 +319,7 @@ public class JavaTypes {
|
|||
// no break
|
||||
case INT:
|
||||
if (val instanceof String)
|
||||
return new Integer(val.toString());
|
||||
return Integer.valueOf(val.toString());
|
||||
return val;
|
||||
case LONG_OBJ:
|
||||
if (val instanceof Long)
|
||||
|
@ -329,7 +329,7 @@ public class JavaTypes {
|
|||
// no break
|
||||
case LONG:
|
||||
if (val instanceof String)
|
||||
return new Long(val.toString());
|
||||
return Long.valueOf(val.toString());
|
||||
return val;
|
||||
case NUMBER:
|
||||
if (val instanceof Number)
|
||||
|
@ -341,11 +341,11 @@ public class JavaTypes {
|
|||
if (val instanceof Short)
|
||||
return val;
|
||||
if (val instanceof Number)
|
||||
return new Short(((Number) val).shortValue());
|
||||
return Short.valueOf(((Number) val).shortValue());
|
||||
// no break
|
||||
case SHORT:
|
||||
if (val instanceof String)
|
||||
return new Short(val.toString());
|
||||
return Short.valueOf(val.toString());
|
||||
return val;
|
||||
case STRING:
|
||||
return val.toString();
|
||||
|
|
|
@ -596,15 +596,15 @@ public class ApplicationIds {
|
|||
}
|
||||
|
||||
public void storeByteField(int field, byte val) {
|
||||
store(new Byte(val));
|
||||
store(Byte.valueOf(val));
|
||||
}
|
||||
|
||||
public void storeCharField(int field, char val) {
|
||||
store(new Character(val));
|
||||
store(Character.valueOf(val));
|
||||
}
|
||||
|
||||
public void storeShortField(int field, short val) {
|
||||
store(new Short(val));
|
||||
store(Short.valueOf(val));
|
||||
}
|
||||
|
||||
public void storeIntField(int field, int val) {
|
||||
|
|
|
@ -50,7 +50,7 @@ public final class ByteId extends OpenJPAId {
|
|||
}
|
||||
|
||||
public Object getIdObject() {
|
||||
return new Byte(key);
|
||||
return Byte.valueOf(key);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
|
|
|
@ -50,7 +50,7 @@ public final class CharId extends OpenJPAId {
|
|||
}
|
||||
|
||||
public Object getIdObject() {
|
||||
return new Character(key);
|
||||
return Character.valueOf(key);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
|
|
|
@ -116,7 +116,7 @@ public abstract class OpenJPAId
|
|||
superclass = base.getSuperclass();
|
||||
}
|
||||
_typeHash = base.hashCode();
|
||||
_typeCache.put(type, new Integer(_typeHash));
|
||||
_typeCache.put(type, Integer.valueOf(_typeHash));
|
||||
} else {
|
||||
_typeHash = typeHashInt.intValue();
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ public final class ShortId extends OpenJPAId {
|
|||
}
|
||||
|
||||
public Object getIdObject() {
|
||||
return new Short(key);
|
||||
return Short.valueOf(key);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
|
|
|
@ -121,7 +121,7 @@ public class ParseException
|
|||
String curtok = curtokBuf.toString();
|
||||
|
||||
return _loc.get("bad-parse", new Object[]{ curtok,
|
||||
new Integer(currentToken.next.beginColumn), expected });
|
||||
Integer.valueOf(currentToken.next.beginColumn), expected });
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue