Improved : Remove all unnecessary boxing and unboxing in Java classes
(OFBIZ-10504) Thanks Taher, Jacques, Mathieu and Rishi for the review git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1837577 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -2338,8 +2338,8 @@ public class GenericDelegator implements Delegator {
|
||||
}
|
||||
try {
|
||||
int seqVal = Integer.parseInt(currentSeqId);
|
||||
if (highestSeqVal == null || seqVal > highestSeqVal.intValue()) {
|
||||
highestSeqVal = Integer.valueOf(seqVal);
|
||||
if (highestSeqVal == null || seqVal > highestSeqVal) {
|
||||
highestSeqVal = seqVal;
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
Debug.logWarning("Error in make-next-seq-id converting SeqId [" + currentSeqId + "] in field: " + seqFieldName + " from entity: " + value.getEntityName() + " to a number: " + e.toString(), module);
|
||||
@@ -2347,7 +2347,7 @@ public class GenericDelegator implements Delegator {
|
||||
}
|
||||
}
|
||||
|
||||
int seqValToUse = (highestSeqVal == null ? 1 : highestSeqVal.intValue() + incrementBy);
|
||||
int seqValToUse = (highestSeqVal == null ? 1 : highestSeqVal + incrementBy);
|
||||
String newSeqId = sequencedIdPrefix + UtilFormatOut.formatPaddedNumber(seqValToUse, numericPadding);
|
||||
value.set(seqFieldName, newSeqId);
|
||||
|
||||
|
||||
@@ -478,7 +478,7 @@ public class GenericEntity implements Map<String, Object>, LocalizedMap<Object>,
|
||||
try {
|
||||
int fieldType = SqlJdbcUtil.getType(type.getJavaType());
|
||||
if (fieldType != 10) {
|
||||
value = ((Boolean) value).booleanValue() ? "Y" : "N";
|
||||
value = (Boolean) value ? "Y" : "N";
|
||||
}
|
||||
} catch (GenericNotImplementedException e) {
|
||||
throw new IllegalArgumentException(e.getMessage());
|
||||
@@ -738,7 +738,7 @@ public class GenericEntity implements Map<String, Object>, LocalizedMap<Object>,
|
||||
// this "hack" is needed for now until the Double/BigDecimal issues are all resolved
|
||||
Object value = get(name);
|
||||
if (value instanceof BigDecimal) {
|
||||
return Double.valueOf(((BigDecimal) value).doubleValue());
|
||||
return ((BigDecimal) value).doubleValue();
|
||||
}
|
||||
return (Double) value;
|
||||
}
|
||||
@@ -748,7 +748,7 @@ public class GenericEntity implements Map<String, Object>, LocalizedMap<Object>,
|
||||
// NOTE: for things to generally work properly BigDecimal should really be used as the java-type in the field type def XML files
|
||||
Object value = get(name);
|
||||
if (value instanceof Double) {
|
||||
return new BigDecimal(((Double) value).doubleValue());
|
||||
return new BigDecimal((Double) value);
|
||||
}
|
||||
return (BigDecimal) value;
|
||||
}
|
||||
@@ -967,7 +967,7 @@ public class GenericEntity implements Map<String, Object>, LocalizedMap<Object>,
|
||||
}
|
||||
Iterator<ModelField> iter = null;
|
||||
if (pks != null) {
|
||||
if (pks.booleanValue()) {
|
||||
if (pks) {
|
||||
iter = this.getModelEntity().getPksIterator();
|
||||
} else {
|
||||
iter = this.getModelEntity().getNopksIterator();
|
||||
|
||||
+1
-1
@@ -137,7 +137,7 @@ public abstract class EntityComparisonOperator<L, R> extends EntityOperator<L, R
|
||||
public abstract boolean compare(L lhs, R rhs);
|
||||
|
||||
public Boolean eval(Delegator delegator, Map<String, ? extends Object> map, L lhs, R rhs) {
|
||||
return Boolean.valueOf(mapMatches(delegator, map, lhs, rhs));
|
||||
return mapMatches(delegator, map, lhs, rhs);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -81,9 +81,9 @@ public class CursorStatement extends AbstractCursorHandler {
|
||||
} else if ("setCursorName".equals(method.getName())) {
|
||||
setCursorName((String) args[0]);
|
||||
} else if ("getFetchSize".equals(method.getName())) {
|
||||
return Integer.valueOf(getFetchSize());
|
||||
return getFetchSize();
|
||||
} else if ("setFetchSize".equals(method.getName())) {
|
||||
setFetchSize(((Integer) args[0]).intValue());
|
||||
setFetchSize((Integer) args[0]);
|
||||
}
|
||||
return super.invoke(stmt, proxy, method, args);
|
||||
}
|
||||
|
||||
@@ -381,7 +381,7 @@ public abstract class JdbcValueHandler<T> {
|
||||
@Override
|
||||
public Boolean getValue(ResultSet rs, int columnIndex) throws SQLException {
|
||||
boolean value = rs.getBoolean(columnIndex);
|
||||
return rs.wasNull() ? null : Boolean.valueOf(value);
|
||||
return rs.wasNull() ? null : value;
|
||||
}
|
||||
@Override
|
||||
protected JdbcValueHandler<Boolean> newInstance(int sqlType) {
|
||||
@@ -523,7 +523,7 @@ public abstract class JdbcValueHandler<T> {
|
||||
@Override
|
||||
public Double getValue(ResultSet rs, int columnIndex) throws SQLException {
|
||||
double value = rs.getDouble(columnIndex);
|
||||
return rs.wasNull() ? null : Double.valueOf(value);
|
||||
return rs.wasNull() ? null : value;
|
||||
}
|
||||
@Override
|
||||
protected JdbcValueHandler<Double> newInstance(int sqlType) {
|
||||
@@ -549,7 +549,7 @@ public abstract class JdbcValueHandler<T> {
|
||||
@Override
|
||||
public Float getValue(ResultSet rs, int columnIndex) throws SQLException {
|
||||
float value = rs.getFloat(columnIndex);
|
||||
return rs.wasNull() ? null : Float.valueOf(value);
|
||||
return rs.wasNull() ? null : value;
|
||||
}
|
||||
@Override
|
||||
protected JdbcValueHandler<Float> newInstance(int sqlType) {
|
||||
@@ -575,7 +575,7 @@ public abstract class JdbcValueHandler<T> {
|
||||
@Override
|
||||
public Integer getValue(ResultSet rs, int columnIndex) throws SQLException {
|
||||
int value = rs.getInt(columnIndex);
|
||||
return rs.wasNull() ? null : Integer.valueOf(value);
|
||||
return rs.wasNull() ? null : value;
|
||||
}
|
||||
@Override
|
||||
protected JdbcValueHandler<Integer> newInstance(int sqlType) {
|
||||
@@ -601,7 +601,7 @@ public abstract class JdbcValueHandler<T> {
|
||||
@Override
|
||||
public Long getValue(ResultSet rs, int columnIndex) throws SQLException {
|
||||
long value = rs.getLong(columnIndex);
|
||||
return rs.wasNull() ? null : Long.valueOf(value);
|
||||
return rs.wasNull() ? null : value;
|
||||
}
|
||||
@Override
|
||||
protected JdbcValueHandler<Long> newInstance(int sqlType) {
|
||||
@@ -699,7 +699,7 @@ public abstract class JdbcValueHandler<T> {
|
||||
@Override
|
||||
public Short getValue(ResultSet rs, int columnIndex) throws SQLException {
|
||||
short value = rs.getShort(columnIndex);
|
||||
return rs.wasNull() ? null : Short.valueOf(value);
|
||||
return rs.wasNull() ? null : value;
|
||||
}
|
||||
@Override
|
||||
protected JdbcValueHandler<Short> newInstance(int sqlType) {
|
||||
|
||||
@@ -631,7 +631,7 @@ public class SQLProcessor implements AutoCloseable {
|
||||
*/
|
||||
public void setValue(Integer field) throws SQLException {
|
||||
if (field != null) {
|
||||
_ps.setInt(_ind, field.intValue());
|
||||
_ps.setInt(_ind, field);
|
||||
} else {
|
||||
_ps.setNull(_ind, Types.NUMERIC);
|
||||
}
|
||||
@@ -647,7 +647,7 @@ public class SQLProcessor implements AutoCloseable {
|
||||
*/
|
||||
public void setValue(Long field) throws SQLException {
|
||||
if (field != null) {
|
||||
_ps.setLong(_ind, field.longValue());
|
||||
_ps.setLong(_ind, field);
|
||||
} else {
|
||||
_ps.setNull(_ind, Types.NUMERIC);
|
||||
}
|
||||
@@ -663,7 +663,7 @@ public class SQLProcessor implements AutoCloseable {
|
||||
*/
|
||||
public void setValue(Float field) throws SQLException {
|
||||
if (field != null) {
|
||||
_ps.setFloat(_ind, field.floatValue());
|
||||
_ps.setFloat(_ind, field);
|
||||
} else {
|
||||
_ps.setNull(_ind, Types.NUMERIC);
|
||||
}
|
||||
@@ -679,7 +679,7 @@ public class SQLProcessor implements AutoCloseable {
|
||||
*/
|
||||
public void setValue(Double field) throws SQLException {
|
||||
if (field != null) {
|
||||
_ps.setDouble(_ind, field.doubleValue());
|
||||
_ps.setDouble(_ind, field);
|
||||
} else {
|
||||
_ps.setNull(_ind, Types.NUMERIC);
|
||||
}
|
||||
@@ -711,7 +711,7 @@ public class SQLProcessor implements AutoCloseable {
|
||||
*/
|
||||
public void setValue(Boolean field) throws SQLException {
|
||||
if (field != null) {
|
||||
_ps.setBoolean(_ind, field.booleanValue());
|
||||
_ps.setBoolean(_ind, field);
|
||||
} else {
|
||||
_ps.setNull(_ind, Types.BOOLEAN);
|
||||
}
|
||||
|
||||
@@ -713,7 +713,7 @@ public final class SqlJdbcUtil {
|
||||
if (rs.wasNull()) {
|
||||
entity.dangerousSetNoCheckButFast(curField, null);
|
||||
} else {
|
||||
entity.dangerousSetNoCheckButFast(curField, Integer.valueOf(intValue));
|
||||
entity.dangerousSetNoCheckButFast(curField, intValue);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -722,7 +722,7 @@ public final class SqlJdbcUtil {
|
||||
if (rs.wasNull()) {
|
||||
entity.dangerousSetNoCheckButFast(curField, null);
|
||||
} else {
|
||||
entity.dangerousSetNoCheckButFast(curField, Long.valueOf(longValue));
|
||||
entity.dangerousSetNoCheckButFast(curField, longValue);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -731,7 +731,7 @@ public final class SqlJdbcUtil {
|
||||
if (rs.wasNull()) {
|
||||
entity.dangerousSetNoCheckButFast(curField, null);
|
||||
} else {
|
||||
entity.dangerousSetNoCheckButFast(curField, Float.valueOf(floatValue));
|
||||
entity.dangerousSetNoCheckButFast(curField, floatValue);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -740,7 +740,7 @@ public final class SqlJdbcUtil {
|
||||
if (rs.wasNull()) {
|
||||
entity.dangerousSetNoCheckButFast(curField, null);
|
||||
} else {
|
||||
entity.dangerousSetNoCheckButFast(curField, Double.valueOf(doubleValue));
|
||||
entity.dangerousSetNoCheckButFast(curField, doubleValue);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -758,7 +758,7 @@ public final class SqlJdbcUtil {
|
||||
if (rs.wasNull()) {
|
||||
entity.dangerousSetNoCheckButFast(curField, null);
|
||||
} else {
|
||||
entity.dangerousSetNoCheckButFast(curField, Boolean.valueOf(booleanValue));
|
||||
entity.dangerousSetNoCheckButFast(curField, booleanValue);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -961,7 +961,7 @@ public final class SqlJdbcUtil {
|
||||
if (val == null) {
|
||||
throw new GenericNotImplementedException("Java type " + fieldType + " not currently supported. Sorry.");
|
||||
}
|
||||
return val.intValue();
|
||||
return val;
|
||||
}
|
||||
|
||||
public static void addValueSingle(StringBuffer buffer, ModelField field, Object value, List<EntityConditionParam> params) {
|
||||
|
||||
@@ -464,7 +464,7 @@ public class ModelViewEntity extends ModelEntity {
|
||||
continue;
|
||||
}
|
||||
if (alias.isPk != null) {
|
||||
isPk = alias.isPk.booleanValue();
|
||||
isPk = alias.isPk;
|
||||
} else {
|
||||
isPk = aliasedField.getIsPk();
|
||||
}
|
||||
@@ -871,7 +871,7 @@ public class ModelViewEntity extends ModelEntity {
|
||||
String primKeyValue = UtilXml.checkEmpty(aliasElement.getAttribute("prim-key"));
|
||||
|
||||
if (UtilValidate.isNotEmpty(primKeyValue)) {
|
||||
this.isPk = Boolean.valueOf("true".equals(primKeyValue));
|
||||
this.isPk = "true".equals(primKeyValue);
|
||||
} else {
|
||||
this.isPk = null;
|
||||
}
|
||||
@@ -903,7 +903,7 @@ public class ModelViewEntity extends ModelEntity {
|
||||
this.colAlias = UtilXml.checkEmpty(colAlias, ModelUtil.javaNameToDbName(UtilXml.checkEmpty(this.name)));
|
||||
this.isPk = isPk;
|
||||
if (groupBy != null) {
|
||||
this.groupBy = groupBy.booleanValue();
|
||||
this.groupBy = groupBy;
|
||||
} else {
|
||||
this.groupBy = false;
|
||||
}
|
||||
@@ -1141,7 +1141,7 @@ public class ModelViewEntity extends ModelEntity {
|
||||
this.entityAlias = entityAlias;
|
||||
this.relEntityAlias = relEntityAlias;
|
||||
if (relOptional != null) {
|
||||
this.relOptional = relOptional.booleanValue();
|
||||
this.relOptional = relOptional;
|
||||
} else {
|
||||
this.relOptional = false;
|
||||
}
|
||||
|
||||
@@ -388,7 +388,7 @@ public class EntityTestSuite extends EntityTestCase {
|
||||
testing.put("testingName", "leaf-#" + node.getString("testingNodeId"));
|
||||
testing.put("description", "level1 leaf");
|
||||
testing.put("comments", "No-comments");
|
||||
testing.put("testingSize", Long.valueOf(10));
|
||||
testing.put("testingSize", 10L);
|
||||
testing.put("testingDate", now);
|
||||
|
||||
newValues.add(testing);
|
||||
@@ -484,15 +484,15 @@ public class EntityTestSuite extends EntityTestCase {
|
||||
testValue = EntityQuery.use(delegator).from("TestingType").where("testingTypeId", "TEST-DISTINCT-1").cache(true).queryOne();
|
||||
assertNotNull("Found newly created type value", testValue);
|
||||
|
||||
delegator.create("Testing", "testingId", "TEST-DISTINCT-1", "testingTypeId", "TEST-DISTINCT-1", "testingSize", Long.valueOf(10), "comments", "No-comments");
|
||||
delegator.create("Testing", "testingId", "TEST-DISTINCT-2", "testingTypeId", "TEST-DISTINCT-1", "testingSize", Long.valueOf(10), "comments", "Some-comments");
|
||||
delegator.create("Testing", "testingId", "TEST-DISTINCT-3", "testingTypeId", "TEST-DISTINCT-1", "testingSize", Long.valueOf(9), "comments", "No-comments");
|
||||
delegator.create("Testing", "testingId", "TEST-DISTINCT-4", "testingTypeId", "TEST-DISTINCT-1", "testingSize", Long.valueOf(11), "comments", "Some-comments");
|
||||
delegator.create("Testing", "testingId", "TEST-DISTINCT-1", "testingTypeId", "TEST-DISTINCT-1", "testingSize", 10L, "comments", "No-comments");
|
||||
delegator.create("Testing", "testingId", "TEST-DISTINCT-2", "testingTypeId", "TEST-DISTINCT-1", "testingSize", 10L, "comments", "Some-comments");
|
||||
delegator.create("Testing", "testingId", "TEST-DISTINCT-3", "testingTypeId", "TEST-DISTINCT-1", "testingSize", 9L, "comments", "No-comments");
|
||||
delegator.create("Testing", "testingId", "TEST-DISTINCT-4", "testingTypeId", "TEST-DISTINCT-1", "testingSize", 11L, "comments", "Some-comments");
|
||||
|
||||
List<GenericValue> testingSize10 = EntityQuery.use(delegator)
|
||||
.select("testingSize", "comments")
|
||||
.from("Testing")
|
||||
.where("testingSize", Long.valueOf(10), "comments", "No-comments")
|
||||
.where("testingSize", 10L, "comments", "No-comments")
|
||||
.distinct()
|
||||
.cache()
|
||||
.queryList();
|
||||
|
||||
+3
-3
@@ -159,7 +159,7 @@ public abstract class GenericXaResource extends Thread implements XAResource {
|
||||
* @see javax.transaction.xa.XAResource#getTransactionTimeout()
|
||||
*/
|
||||
public int getTransactionTimeout() throws XAException {
|
||||
return this.timeout == null ? 0 : this.timeout.intValue();
|
||||
return this.timeout == null ? 0 : this.timeout;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -167,7 +167,7 @@ public abstract class GenericXaResource extends Thread implements XAResource {
|
||||
* Note: the valus is saved but in the current implementation this is not used.
|
||||
*/
|
||||
public boolean setTransactionTimeout(int seconds) throws XAException {
|
||||
this.timeout = (seconds == 0 ? null : Integer.valueOf(seconds));
|
||||
this.timeout = (seconds == 0 ? null : seconds);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ public abstract class GenericXaResource extends Thread implements XAResource {
|
||||
try {
|
||||
if (timeout != null) {
|
||||
// sleep until the transaction times out
|
||||
sleep(timeout.intValue() * 1000L);
|
||||
sleep(timeout * 1000L);
|
||||
|
||||
if (active) {
|
||||
// get the current status
|
||||
|
||||
@@ -487,7 +487,7 @@ public class EntityListIterator implements AutoCloseable, ListIterator<GenericVa
|
||||
if (resultSize == null) {
|
||||
resultSize = (int) getResultSize();
|
||||
}
|
||||
return resultSize.intValue();
|
||||
return resultSize;
|
||||
}
|
||||
return this.last() ? this.currentIndex() : 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user