Author: doogie
Date: Mon Mar 1 18:14:19 2010
New Revision: 917624
URL: http://svn.apache.org/viewvc?rev=917624&view=rev
Log:
Add abstract classes to unify simple object to singleton collections.
Added:
ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/GenericSingletonToList.java
ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/GenericSingletonToSet.java
Modified:
ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/BooleanConverters.java
ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/CollectionConverters.java
ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/DateTimeConverters.java
ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/NumberConverters.java
Modified:
ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/BooleanConverters.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/BooleanConverters.java?rev=917624&r1=917623&r2=917624&view=diff
==============================================================================
---
ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/BooleanConverters.java
(original)
+++
ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/BooleanConverters.java
Mon Mar 1 18:14:19 2010
@@ -36,27 +36,15 @@
}
}
- public static class BooleanToList extends AbstractConverter<Boolean,
List<Boolean>> {
+ public static class BooleanToList extends GenericSingletonToList<Boolean> {
public BooleanToList() {
- super(Boolean.class, List.class);
- }
-
- public List<Boolean> convert(Boolean obj) throws ConversionException {
- List<Boolean> tempList = FastList.newInstance();
- tempList.add(obj);
- return tempList;
+ super(Boolean.class);
}
}
- public static class BooleanToSet extends AbstractConverter<Boolean,
Set<Boolean>> {
+ public static class BooleanToSet extends GenericSingletonToSet<Boolean> {
public BooleanToSet() {
- super(Boolean.class, Set.class);
- }
-
- public Set<Boolean> convert(Boolean obj) throws ConversionException {
- Set<Boolean> tempSet = FastSet.newInstance();
- tempSet.add(obj);
- return tempSet;
+ super(Boolean.class);
}
}
Modified:
ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/CollectionConverters.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/CollectionConverters.java?rev=917624&r1=917623&r2=917624&view=diff
==============================================================================
---
ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/CollectionConverters.java
(original)
+++
ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/CollectionConverters.java
Mon Mar 1 18:14:19 2010
@@ -139,18 +139,16 @@
}
}
- public static class StringToList extends AbstractConverter<String,
List<String>> {
+ public static class StringToList extends GenericSingletonToList<String> {
public StringToList() {
- super(String.class, List.class);
+ super(String.class);
}
public List<String> convert(String obj) throws ConversionException {
if (obj.startsWith("[") && obj.endsWith("]")) {
return StringUtil.toList(obj);
} else {
- List<String> tempList = FastList.newInstance();
- tempList.add(obj);
- return tempList;
+ return super.convert(obj);
}
}
}
@@ -168,18 +166,16 @@
}
}
- public static class StringToSet extends AbstractConverter<String,
Set<String>> {
+ public static class StringToSet extends GenericSingletonToSet<String> {
public StringToSet() {
- super(String.class, Set.class);
+ super(String.class);
}
public Set<String> convert(String obj) throws ConversionException {
if (obj.startsWith("[") && obj.endsWith("]")) {
return StringUtil.toSet(obj);
} else {
- Set<String> tempSet = FastSet.newInstance();
- tempSet.add(obj);
- return tempSet;
+ return super.convert(obj);
}
}
}
Modified:
ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/DateTimeConverters.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/DateTimeConverters.java?rev=917624&r1=917623&r2=917624&view=diff
==============================================================================
---
ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/DateTimeConverters.java
(original)
+++
ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/DateTimeConverters.java
Mon Mar 1 18:14:19 2010
@@ -152,27 +152,15 @@
}
}
- public static class DurationToList extends AbstractConverter<TimeDuration,
List<TimeDuration>> {
+ public static class DurationToList extends
GenericSingletonToList<TimeDuration> {
public DurationToList() {
- super(TimeDuration.class, List.class);
- }
-
- public List<TimeDuration> convert(TimeDuration obj) throws
ConversionException {
- List<TimeDuration> tempList = FastList.newInstance();
- tempList.add(obj);
- return tempList;
+ super(TimeDuration.class);
}
}
- public static class DurationToSet extends AbstractConverter<TimeDuration,
Set<TimeDuration>> {
+ public static class DurationToSet extends
GenericSingletonToSet<TimeDuration> {
public DurationToSet() {
- super(TimeDuration.class, Set.class);
- }
-
- public Set<TimeDuration> convert(TimeDuration obj) throws
ConversionException {
- Set<TimeDuration> tempSet = FastSet.newInstance();
- tempSet.add(obj);
- return tempSet;
+ super(TimeDuration.class);
}
}
@@ -278,27 +266,15 @@
}
}
- public static class SqlDateToList extends AbstractConverter<java.sql.Date,
List<java.sql.Date>> {
+ public static class SqlDateToList extends
GenericSingletonToList<java.sql.Date> {
public SqlDateToList() {
- super(java.sql.Date.class, List.class);
- }
-
- public List<java.sql.Date> convert(java.sql.Date obj) throws
ConversionException {
- List<java.sql.Date> tempList = FastList.newInstance();
- tempList.add(obj);
- return tempList;
+ super(java.sql.Date.class);
}
}
- public static class SqlDateToSet extends AbstractConverter<java.sql.Date,
Set<java.sql.Date>> {
+ public static class SqlDateToSet extends
GenericSingletonToSet<java.sql.Date> {
public SqlDateToSet() {
- super(java.sql.Date.class, Set.class);
- }
-
- public Set<java.sql.Date> convert(java.sql.Date obj) throws
ConversionException {
- Set<java.sql.Date> tempSet = FastSet.newInstance();
- tempSet.add(obj);
- return tempSet;
+ super(java.sql.Date.class);
}
}
@@ -343,15 +319,9 @@
}
}
- public static class SqlTimeToList extends AbstractConverter<java.sql.Time,
List<java.sql.Time>> {
+ public static class SqlTimeToList extends
GenericSingletonToList<java.sql.Time> {
public SqlTimeToList() {
- super(java.sql.Time.class, List.class);
- }
-
- public List<java.sql.Time> convert(java.sql.Time obj) throws
ConversionException {
- List<java.sql.Time> tempList = FastList.newInstance();
- tempList.add(obj);
- return tempList;
+ super(java.sql.Time.class);
}
}
@@ -365,15 +335,9 @@
}
}
- public static class SqlTimeToSet extends AbstractConverter<java.sql.Time,
Set<java.sql.Time>> {
+ public static class SqlTimeToSet extends
GenericSingletonToSet<java.sql.Time> {
public SqlTimeToSet() {
- super(java.sql.Time.class, Set.class);
- }
-
- public Set<java.sql.Time> convert(java.sql.Time obj) throws
ConversionException {
- Set<java.sql.Time> tempSet = FastSet.newInstance();
- tempSet.add(obj);
- return tempSet;
+ super(java.sql.Time.class);
}
}
@@ -613,27 +577,15 @@
}
}
- public static class TimestampToList extends
AbstractConverter<java.sql.Timestamp, List<java.sql.Timestamp>> {
+ public static class TimestampToList extends
GenericSingletonToList<java.sql.Timestamp> {
public TimestampToList() {
- super(java.sql.Timestamp.class, List.class);
- }
-
- public List<java.sql.Timestamp> convert(java.sql.Timestamp obj) throws
ConversionException {
- List<java.sql.Timestamp> tempList = FastList.newInstance();
- tempList.add(obj);
- return tempList;
+ super(java.sql.Timestamp.class);
}
}
- public static class TimestampToSet extends
AbstractConverter<java.sql.Timestamp, Set<java.sql.Timestamp>> {
+ public static class TimestampToSet extends
GenericSingletonToSet<java.sql.Timestamp> {
public TimestampToSet() {
- super(java.sql.Timestamp.class, Set.class);
- }
-
- public Set<java.sql.Timestamp> convert(java.sql.Timestamp obj) throws
ConversionException {
- Set<java.sql.Timestamp> tempSet = FastSet.newInstance();
- tempSet.add(obj);
- return tempSet;
+ super(java.sql.Timestamp.class);
}
}
Added:
ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/GenericSingletonToList.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/GenericSingletonToList.java?rev=917624&view=auto
==============================================================================
---
ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/GenericSingletonToList.java
(added)
+++
ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/GenericSingletonToList.java
Mon Mar 1 18:14:19 2010
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+
*******************************************************************************/
+package org.ofbiz.base.conversion;
+
+import java.util.List;
+
+import javolution.util.FastList;
+
+public class GenericSingletonToList<T> extends AbstractConverter<T, List<T>> {
+ public GenericSingletonToList(Class<T> sourceClass) {
+ super(sourceClass, List.class);
+ }
+
+ public List<T> convert(T obj) throws ConversionException {
+ List<T> tempList = FastList.newInstance();
+ tempList.add(obj);
+ return tempList;
+ }
+}
Added:
ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/GenericSingletonToSet.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/GenericSingletonToSet.java?rev=917624&view=auto
==============================================================================
---
ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/GenericSingletonToSet.java
(added)
+++
ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/GenericSingletonToSet.java
Mon Mar 1 18:14:19 2010
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+
*******************************************************************************/
+package org.ofbiz.base.conversion;
+
+import java.util.Set;
+
+import javolution.util.FastSet;
+
+public class GenericSingletonToSet<T> extends AbstractConverter<T, Set<T>> {
+ public GenericSingletonToSet(Class<T> sourceClass) {
+ super(sourceClass, Set.class);
+ }
+
+ public Set<T> convert(T obj) throws ConversionException {
+ Set<T> tempSet = FastSet.newInstance();
+ tempSet.add(obj);
+ return tempSet;
+ }
+}
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=917624&r1=917623&r2=917624&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:14:19 2010
@@ -84,15 +84,9 @@
}
}
- public static class BigDecimalToList extends AbstractConverter<BigDecimal,
List<BigDecimal>> {
+ public static class BigDecimalToList extends
GenericSingletonToList<BigDecimal> {
public BigDecimalToList() {
- super(BigDecimal.class, List.class);
- }
-
- public List<BigDecimal> convert(BigDecimal obj) throws
ConversionException {
- List<BigDecimal> tempList = FastList.newInstance();
- tempList.add(obj);
- return tempList;
+ super(BigDecimal.class);
}
}
@@ -106,15 +100,9 @@
}
}
- public static class BigDecimalToSet extends AbstractConverter<BigDecimal,
Set<BigDecimal>> {
+ public static class BigDecimalToSet extends
GenericSingletonToSet<BigDecimal> {
public BigDecimalToSet() {
- super(BigDecimal.class, Set.class);
- }
-
- public Set<BigDecimal> convert(BigDecimal obj) throws
ConversionException {
- Set<BigDecimal> tempSet = FastSet.newInstance();
- tempSet.add(obj);
- return tempSet;
+ super(BigDecimal.class);
}
}
@@ -173,15 +161,9 @@
}
}
- public static class BigIntegerToList extends AbstractConverter<BigInteger,
List<BigInteger>> {
+ public static class BigIntegerToList extends
GenericSingletonToList<BigInteger> {
public BigIntegerToList() {
- super(BigInteger.class, List.class);
- }
-
- public List<BigInteger> convert(BigInteger obj) throws
ConversionException {
- List<BigInteger> tempList = FastList.newInstance();
- tempList.add(obj);
- return tempList;
+ super(BigInteger.class);
}
}
@@ -195,15 +177,9 @@
}
}
- public static class BigIntegerToSet extends AbstractConverter<BigInteger,
Set<BigInteger>> {
+ public static class BigIntegerToSet extends
GenericSingletonToSet<BigInteger> {
public BigIntegerToSet() {
- super(BigInteger.class, Set.class);
- }
-
- public Set<BigInteger> convert(BigInteger obj) throws
ConversionException {
- Set<BigInteger> tempSet = FastSet.newInstance();
- tempSet.add(obj);
- return tempSet;
+ super(BigInteger.class);
}
}
@@ -252,15 +228,9 @@
}
}
- public static class ByteToList extends AbstractConverter<Byte, List<Byte>>
{
+ public static class ByteToList extends GenericSingletonToList<Byte> {
public ByteToList() {
- super(Byte.class, List.class);
- }
-
- public List<Byte> convert(Byte obj) throws ConversionException {
- List<Byte> tempList = FastList.newInstance();
- tempList.add(obj);
- return tempList;
+ super(Byte.class);
}
}
@@ -274,15 +244,9 @@
}
}
- public static class ByteToSet extends AbstractConverter<Byte, Set<Byte>> {
+ public static class ByteToSet extends GenericSingletonToSet<Byte> {
public ByteToSet() {
- super(Byte.class, Set.class);
- }
-
- public Set<Byte> convert(Byte obj) throws ConversionException {
- Set<Byte> tempSet = FastSet.newInstance();
- tempSet.add(obj);
- return tempSet;
+ super(Byte.class);
}
}
@@ -339,15 +303,9 @@
}
}
- public static class DoubleToList extends AbstractConverter<Double,
List<Double>> {
+ public static class DoubleToList extends GenericSingletonToList<Double> {
public DoubleToList() {
- super(Double.class, List.class);
- }
-
- public List<Double> convert(Double obj) throws ConversionException {
- List<Double> tempList = FastList.newInstance();
- tempList.add(obj);
- return tempList;
+ super(Double.class);
}
}
@@ -361,15 +319,9 @@
}
}
- public static class DoubleToSet extends AbstractConverter<Double,
Set<Double>> {
+ public static class DoubleToSet extends GenericSingletonToSet<Double> {
public DoubleToSet() {
- super(Double.class, Set.class);
- }
-
- public Set<Double> convert(Double obj) throws ConversionException {
- Set<Double> tempSet = FastSet.newInstance();
- tempSet.add(obj);
- return tempSet;
+ super(Double.class);
}
}
@@ -418,15 +370,9 @@
}
}
- public static class FloatToList extends AbstractConverter<Float,
List<Float>> {
+ public static class FloatToList extends GenericSingletonToList<Float> {
public FloatToList() {
- super(Float.class, List.class);
- }
-
- public List<Float> convert(Float obj) throws ConversionException {
- List<Float> tempList = FastList.newInstance();
- tempList.add(obj);
- return tempList;
+ super(Float.class);
}
}
@@ -440,15 +386,9 @@
}
}
- public static class FloatToSet extends AbstractConverter<Float,
Set<Float>> {
+ public static class FloatToSet extends GenericSingletonToSet<Float> {
public FloatToSet() {
- super(Float.class, Set.class);
- }
-
- public Set<Float> convert(Float obj) throws ConversionException {
- Set<Float> tempSet = FastSet.newInstance();
- tempSet.add(obj);
- return tempSet;
+ super(Float.class);
}
}
@@ -507,15 +447,9 @@
}
}
- public static class IntegerToList extends AbstractConverter<Integer,
List<Integer>> {
+ public static class IntegerToList extends GenericSingletonToList<Integer> {
public IntegerToList() {
- super(Integer.class, List.class);
- }
-
- public List<Integer> convert(Integer obj) throws ConversionException {
- List<Integer> tempList = FastList.newInstance();
- tempList.add(obj);
- return tempList;
+ super(Integer.class);
}
}
@@ -529,15 +463,9 @@
}
}
- public static class IntegerToSet extends AbstractConverter<Integer,
Set<Integer>> {
+ public static class IntegerToSet extends GenericSingletonToSet<Integer> {
public IntegerToSet() {
- super(Integer.class, Set.class);
- }
-
- public Set<Integer> convert(Integer obj) throws ConversionException {
- Set<Integer> tempSet = FastSet.newInstance();
- tempSet.add(obj);
- return tempSet;
+ super(Integer.class);
}
}
@@ -616,27 +544,15 @@
}
}
- public static class LongToList extends AbstractConverter<Long, List<Long>>
{
+ public static class LongToList extends GenericSingletonToList<Long> {
public LongToList() {
- super(Long.class, List.class);
- }
-
- public List<Long> convert(Long obj) throws ConversionException {
- List<Long> tempList = FastList.newInstance();
- tempList.add(obj);
- return tempList;
+ super(Long.class);
}
}
- public static class LongToSet extends AbstractConverter<Long, Set<Long>> {
+ public static class LongToSet extends GenericSingletonToSet<Long> {
public LongToSet() {
- super(Long.class, Set.class);
- }
-
- public Set<Long> convert(Long obj) throws ConversionException {
- Set<Long> tempSet = FastSet.newInstance();
- tempSet.add(obj);
- return tempSet;
+ super(Long.class);
}
}
@@ -695,15 +611,9 @@
}
}
- public static class ShortToList extends AbstractConverter<Short,
List<Short>> {
+ public static class ShortToList extends GenericSingletonToList<Short> {
public ShortToList() {
- super(Short.class, List.class);
- }
-
- public List<Short> convert(Short obj) throws ConversionException {
- List<Short> tempList = FastList.newInstance();
- tempList.add(obj);
- return tempList;
+ super(Short.class);
}
}
@@ -717,15 +627,9 @@
}
}
- public static class ShortToSet extends AbstractConverter<Short,
Set<Short>> {
+ public static class ShortToSet extends GenericSingletonToSet<Short> {
public ShortToSet() {
- super(Short.class, Set.class);
- }
-
- public Set<Short> convert(Short obj) throws ConversionException {
- Set<Short> tempSet = FastSet.newInstance();
- tempSet.add(obj);
- return tempSet;
+ super(Short.class);
}
}