Return-Path: Delivered-To: apmail-ofbiz-commits-archive@www.apache.org Received: (qmail 47815 invoked from network); 1 Mar 2010 18:15:49 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 1 Mar 2010 18:15:49 -0000 Received: (qmail 74287 invoked by uid 500); 1 Mar 2010 18:15:48 -0000 Delivered-To: apmail-ofbiz-commits-archive@ofbiz.apache.org Received: (qmail 74266 invoked by uid 500); 1 Mar 2010 18:15:48 -0000 Mailing-List: contact commits-help@ofbiz.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ofbiz.apache.org Delivered-To: mailing list commits@ofbiz.apache.org Received: (qmail 74259 invoked by uid 99); 1 Mar 2010 18:15:48 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Mar 2010 18:15:48 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Mar 2010 18:15:46 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 8D5D323888D2; Mon, 1 Mar 2010 18:15:24 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r917625 - /ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/NumberConverters.java Date: Mon, 01 Mar 2010 18:15:24 -0000 To: commits@ofbiz.apache.org From: doogie@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100301181524.8D5D323888D2@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: doogie Date: Mon Mar 1 18:15:24 2010 New Revision: 917625 URL: http://svn.apache.org/viewvc?rev=917625&view=rev Log: All the Number->Number variants now have generic base classes. Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/NumberConverters.java Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/NumberConverters.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/NumberConverters.java?rev=917625&r1=917624&r2=917625&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/NumberConverters.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/NumberConverters.java Mon Mar 1 18:15:24 2010 @@ -54,49 +54,83 @@ } } - public static class BigDecimalToDouble extends AbstractConverter { - public BigDecimalToDouble() { - super(BigDecimal.class, Double.class); + public static class GenericNumberToDouble extends AbstractConverter { + public GenericNumberToDouble(Class sourceClass) { + super(sourceClass, Double.class); } - public Double convert(BigDecimal obj) throws ConversionException { + public Double convert(N obj) throws ConversionException { return obj.doubleValue(); } } - public static class BigDecimalToFloat extends AbstractConverter { - public BigDecimalToFloat() { - super(BigDecimal.class, Float.class); + public static class GenericNumberToFloat extends AbstractConverter { + public GenericNumberToFloat(Class sourceClass) { + super(sourceClass, Float.class); } - public Float convert(BigDecimal obj) throws ConversionException { + public Float convert(N obj) throws ConversionException { return obj.floatValue(); } } - public static class BigDecimalToInteger extends AbstractConverter { - public BigDecimalToInteger() { - super(BigDecimal.class, Integer.class); + public static class GenericNumberToInteger extends AbstractConverter { + public GenericNumberToInteger(Class sourceClass) { + super(sourceClass, Integer.class); } - public Integer convert(BigDecimal obj) throws ConversionException { + public Integer convert(N obj) throws ConversionException { return obj.intValue(); } } + public static class GenericNumberToLong extends AbstractConverter { + public GenericNumberToLong(Class sourceClass) { + super(sourceClass, Long.class); + } + + public Long convert(N obj) throws ConversionException { + return obj.longValue(); + } + } + + public static class GenericNumberToShort extends AbstractConverter { + public GenericNumberToShort(Class sourceClass) { + super(sourceClass, Short.class); + } + + public Short convert(N obj) throws ConversionException { + return obj.shortValue(); + } + } + + public static class BigDecimalToDouble extends GenericNumberToDouble { + public BigDecimalToDouble() { + super(BigDecimal.class); + } + } + + public static class BigDecimalToFloat extends GenericNumberToFloat { + public BigDecimalToFloat() { + super(BigDecimal.class); + } + } + + public static class BigDecimalToInteger extends GenericNumberToInteger { + public BigDecimalToInteger() { + super(BigDecimal.class); + } + } + public static class BigDecimalToList extends GenericSingletonToList { public BigDecimalToList() { super(BigDecimal.class); } } - public static class BigDecimalToLong extends AbstractConverter { + public static class BigDecimalToLong extends GenericNumberToLong { public BigDecimalToLong() { - super(BigDecimal.class, Long.class); - } - - public Long convert(BigDecimal obj) throws ConversionException { - return obj.longValue(); + super(BigDecimal.class); } } @@ -131,33 +165,21 @@ } } - public static class BigIntegerToDouble extends AbstractConverter { + public static class BigIntegerToDouble extends GenericNumberToDouble { public BigIntegerToDouble() { - super(BigInteger.class, Double.class); - } - - public Double convert(BigInteger obj) throws ConversionException { - return obj.doubleValue(); + super(BigInteger.class); } } - public static class BigIntegerToFloat extends AbstractConverter { + public static class BigIntegerToFloat extends GenericNumberToFloat { public BigIntegerToFloat() { - super(BigInteger.class, Float.class); - } - - public Float convert(BigInteger obj) throws ConversionException { - return obj.floatValue(); + super(BigInteger.class); } } - public static class BigIntegerToInteger extends AbstractConverter { + public static class BigIntegerToInteger extends GenericNumberToInteger { public BigIntegerToInteger() { - super(BigInteger.class, Integer.class); - } - - public Integer convert(BigInteger obj) throws ConversionException { - return obj.intValue(); + super(BigInteger.class); } } @@ -167,13 +189,9 @@ } } - public static class BigIntegerToLong extends AbstractConverter { + public static class BigIntegerToLong extends GenericNumberToLong { public BigIntegerToLong() { - super(BigInteger.class, Long.class); - } - - public Long convert(BigInteger obj) throws ConversionException { - return obj.longValue(); + super(BigInteger.class); } } @@ -198,33 +216,21 @@ } } - public static class ByteToDouble extends AbstractConverter { + public static class ByteToDouble extends GenericNumberToDouble { public ByteToDouble() { - super(Byte.class, Double.class); - } - - public Double convert(Byte obj) throws ConversionException { - return obj.doubleValue(); + super(Byte.class); } } - public static class ByteToFloat extends AbstractConverter { + public static class ByteToFloat extends GenericNumberToFloat { public ByteToFloat() { - super(Byte.class, Float.class); - } - - public Float convert(Byte obj) throws ConversionException { - return obj.floatValue(); + super(Byte.class); } } - public static class ByteToInteger extends AbstractConverter { + public static class ByteToInteger extends GenericNumberToInteger { public ByteToInteger() { - super(Byte.class, Integer.class); - } - - public Integer convert(Byte obj) throws ConversionException { - return obj.intValue(); + super(Byte.class); } } @@ -234,13 +240,9 @@ } } - public static class ByteToLong extends AbstractConverter { + public static class ByteToLong extends GenericNumberToLong { public ByteToLong() { - super(Byte.class, Long.class); - } - - public Long convert(Byte obj) throws ConversionException { - return obj.longValue(); + super(Byte.class); } } @@ -283,23 +285,15 @@ } } - public static class DoubleToFloat extends AbstractConverter { + public static class DoubleToFloat extends GenericNumberToFloat { public DoubleToFloat() { - super(Double.class, Float.class); - } - - public Float convert(Double obj) throws ConversionException { - return obj.floatValue(); + super(Double.class); } } - public static class DoubleToInteger extends AbstractConverter { + public static class DoubleToInteger extends GenericNumberToInteger { public DoubleToInteger() { - super(Double.class, Integer.class); - } - - public Integer convert(Double obj) throws ConversionException { - return obj.intValue(); + super(Double.class); } } @@ -309,13 +303,9 @@ } } - public static class DoubleToLong extends AbstractConverter { + public static class DoubleToLong extends GenericNumberToLong { public DoubleToLong() { - super(Double.class, Long.class); - } - - public Long convert(Double obj) throws ConversionException { - return obj.longValue(); + super(Double.class); } } @@ -350,23 +340,15 @@ } } - public static class FloatToDouble extends AbstractConverter { + public static class FloatToDouble extends GenericNumberToDouble { public FloatToDouble() { - super(Float.class, Double.class); - } - - public Double convert(Float obj) throws ConversionException { - return obj.doubleValue(); + super(Float.class); } } - public static class FloatToInteger extends AbstractConverter { + public static class FloatToInteger extends GenericNumberToInteger { public FloatToInteger() { - super(Float.class, Integer.class); - } - - public Integer convert(Float obj) throws ConversionException { - return obj.intValue(); + super(Float.class); } } @@ -376,13 +358,9 @@ } } - public static class FloatToLong extends AbstractConverter { + public static class FloatToLong extends GenericNumberToLong { public FloatToLong() { - super(Float.class, Long.class); - } - - public Long convert(Float obj) throws ConversionException { - return obj.longValue(); + super(Float.class); } } @@ -427,23 +405,15 @@ } } - public static class IntegerToDouble extends AbstractConverter { + public static class IntegerToDouble extends GenericNumberToDouble { public IntegerToDouble() { - super(Integer.class, Double.class); - } - - public Double convert(Integer obj) throws ConversionException { - return obj.doubleValue(); + super(Integer.class); } } - public static class IntegerToFloat extends AbstractConverter { + public static class IntegerToFloat extends GenericNumberToFloat { public IntegerToFloat() { - super(Integer.class, Float.class); - } - - public Float convert(Integer obj) throws ConversionException { - return obj.floatValue(); + super(Integer.class); } } @@ -453,13 +423,9 @@ } } - public static class IntegerToLong extends AbstractConverter { + public static class IntegerToLong extends GenericNumberToLong { public IntegerToLong() { - super(Integer.class, Long.class); - } - - public Long convert(Integer obj) throws ConversionException { - return obj.longValue(); + super(Integer.class); } } @@ -469,13 +435,9 @@ } } - public static class IntegerToShort extends AbstractConverter { + public static class IntegerToShort extends GenericNumberToShort { public IntegerToShort() { - super(Integer.class, Short.class); - } - - public Short convert(Integer obj) throws ConversionException { - return obj.shortValue(); + super(Integer.class); } } @@ -514,33 +476,21 @@ } } - public static class LongToDouble extends AbstractConverter { + public static class LongToDouble extends GenericNumberToDouble { public LongToDouble() { - super(Long.class, Double.class); - } - - public Double convert(Long obj) throws ConversionException { - return obj.doubleValue(); + super(Long.class); } } - public static class LongToFloat extends AbstractConverter { + public static class LongToFloat extends GenericNumberToFloat { public LongToFloat() { - super(Long.class, Float.class); - } - - public Float convert(Long obj) throws ConversionException { - return obj.floatValue(); + super(Long.class); } } - public static class LongToInteger extends AbstractConverter { + public static class LongToInteger extends GenericNumberToInteger { public LongToInteger() { - super(Long.class, Integer.class); - } - - public Integer convert(Long obj) throws ConversionException { - return obj.intValue(); + super(Long.class); } } @@ -556,13 +506,9 @@ } } - public static class LongToShort extends AbstractConverter { + public static class LongToShort extends GenericNumberToShort { public LongToShort() { - super(Long.class, Short.class); - } - - public Short convert(Long obj) throws ConversionException { - return obj.shortValue(); + super(Long.class); } } @@ -581,33 +527,21 @@ } } - public static class ShortToDouble extends AbstractConverter { + public static class ShortToDouble extends GenericNumberToDouble { public ShortToDouble() { - super(Short.class, Double.class); - } - - public Double convert(Short obj) throws ConversionException { - return obj.doubleValue(); + super(Short.class); } } - public static class ShortToFloat extends AbstractConverter { + public static class ShortToFloat extends GenericNumberToFloat { public ShortToFloat() { - super(Short.class, Float.class); - } - - public Float convert(Short obj) throws ConversionException { - return obj.floatValue(); + super(Short.class); } } - public static class ShortToInteger extends AbstractConverter { + public static class ShortToInteger extends GenericNumberToInteger { public ShortToInteger() { - super(Short.class, Integer.class); - } - - public Integer convert(Short obj) throws ConversionException { - return obj.intValue(); + super(Short.class); } } @@ -617,13 +551,9 @@ } } - public static class ShortToLong extends AbstractConverter { + public static class ShortToLong extends GenericNumberToLong { public ShortToLong() { - super(Short.class, Long.class); - } - - public Long convert(Short obj) throws ConversionException { - return obj.longValue(); + super(Short.class); } }