Java 5 code style
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2007 the original author or authors.
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -105,6 +105,16 @@ public class ToStringCreator {
|
||||
return append(fieldName, new Integer(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Append a long field value.
|
||||
* @param fieldName the name of the field, usually the member variable name
|
||||
* @param value the field value
|
||||
* @return this, to support call-chaining
|
||||
*/
|
||||
public ToStringCreator append(String fieldName, long value) {
|
||||
return append(fieldName, new Long(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Append a float field value.
|
||||
* @param fieldName the name of the field, usually the member variable name
|
||||
@@ -125,16 +135,6 @@ public class ToStringCreator {
|
||||
return append(fieldName, new Double(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Append a long field value.
|
||||
* @param fieldName the name of the field, usually the member variable name
|
||||
* @param value the field value
|
||||
* @return this, to support call-chaining
|
||||
*/
|
||||
public ToStringCreator append(String fieldName, long value) {
|
||||
return append(fieldName, new Long(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Append a boolean field value.
|
||||
* @param fieldName the name of the field, usually the member variable name
|
||||
@@ -142,7 +142,7 @@ public class ToStringCreator {
|
||||
* @return this, to support call-chaining
|
||||
*/
|
||||
public ToStringCreator append(String fieldName, boolean value) {
|
||||
return append(fieldName, value ? Boolean.TRUE : Boolean.FALSE);
|
||||
return append(fieldName, Boolean.valueOf(value));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -63,24 +63,24 @@ public abstract class NumberUtils {
|
||||
if (value < Byte.MIN_VALUE || value > Byte.MAX_VALUE) {
|
||||
raiseOverflowException(number, targetClass);
|
||||
}
|
||||
return new Byte(number.byteValue());
|
||||
return number.byteValue();
|
||||
}
|
||||
else if (targetClass.equals(Short.class)) {
|
||||
long value = number.longValue();
|
||||
if (value < Short.MIN_VALUE || value > Short.MAX_VALUE) {
|
||||
raiseOverflowException(number, targetClass);
|
||||
}
|
||||
return new Short(number.shortValue());
|
||||
return number.shortValue();
|
||||
}
|
||||
else if (targetClass.equals(Integer.class)) {
|
||||
long value = number.longValue();
|
||||
if (value < Integer.MIN_VALUE || value > Integer.MAX_VALUE) {
|
||||
raiseOverflowException(number, targetClass);
|
||||
}
|
||||
return new Integer(number.intValue());
|
||||
return number.intValue();
|
||||
}
|
||||
else if (targetClass.equals(Long.class)) {
|
||||
return new Long(number.longValue());
|
||||
return number.longValue();
|
||||
}
|
||||
else if (targetClass.equals(BigInteger.class)) {
|
||||
if (number instanceof BigDecimal) {
|
||||
@@ -93,10 +93,10 @@ public abstract class NumberUtils {
|
||||
}
|
||||
}
|
||||
else if (targetClass.equals(Float.class)) {
|
||||
return new Float(number.floatValue());
|
||||
return number.floatValue();
|
||||
}
|
||||
else if (targetClass.equals(Double.class)) {
|
||||
return new Double(number.doubleValue());
|
||||
return number.doubleValue();
|
||||
}
|
||||
else if (targetClass.equals(BigDecimal.class)) {
|
||||
// always use BigDecimal(String) here to avoid unpredictability of BigDecimal(double)
|
||||
|
||||
Reference in New Issue
Block a user