Title: [2277] trunk/xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate: Generify.

Diff

Modified: trunk/xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate/converter/HibernatePersistentCollectionConverter.java (2276 => 2277)


--- trunk/xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate/converter/HibernatePersistentCollectionConverter.java	2014-03-12 23:19:40 UTC (rev 2276)
+++ trunk/xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate/converter/HibernatePersistentCollectionConverter.java	2014-04-05 19:39:40 UTC (rev 2277)
@@ -1,11 +1,11 @@
 /*
- * Copyright (C) 2011, 2012, 2013 XStream Committers.
+ * Copyright (C) 2011, 2012, 2013, 2014 XStream Committers.
  * All rights reserved.
  *
  * The software in this package is published under the terms of the BSD
  * style license a copy of which has been included with this distribution in
  * the LICENSE.txt file.
- * 
+ *
  * Created on 19. April 2011 by Joerg Schaible
  */
 package com.thoughtworks.xstream.hibernate.converter;
@@ -19,10 +19,10 @@
 
 
 /**
- * A converter for Hibernate's PersistentBag, PersistentList and PersistentSet and for ListProxy
- * and SetProxy from Hibernate's Envers add-on. The converter will drop any reference to the
- * Hibernate collection and emit at serialization time an equivalent JDK collection instead.
- * 
+ * A converter for Hibernate's PersistentBag, PersistentList and PersistentSet and for ListProxy and SetProxy from
+ * Hibernate's Envers add-on. The converter will drop any reference to the Hibernate collection and emit at
+ * serialization time an equivalent JDK collection instead.
+ *
  * @author Jörg Schaible
  * @since 1.4
  */
@@ -30,7 +30,7 @@
 
     /**
      * Construct a HibernatePersistentCollectionConverter.
-     * 
+     *
      * @param mapper
      * @since 1.4
      */
@@ -38,19 +38,17 @@
         super(mapper);
     }
 
-    public boolean canConvert(final Class type) {
+    @Override
+    public boolean canConvert(final Class<?> type) {
         return type != null
-            && (
-                   type == Hibernate.PersistentBag
+            && (type == Hibernate.PersistentBag
                 || type == Hibernate.PersistentList
                 || type == Hibernate.PersistentSet
-                || type == Hibernate.EnversList
-                || type == Hibernate.EnversSet
-            );
+                || type == Hibernate.EnversList || type == Hibernate.EnversSet);
     }
 
-    public Object unmarshal(final HierarchicalStreamReader reader,
-        final UnmarshallingContext context) {
+    @Override
+    public Object unmarshal(final HierarchicalStreamReader reader, final UnmarshallingContext context) {
         throw new ConversionException("Cannot deserialize Hibernate collection");
     }
 }

Modified: trunk/xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate/converter/HibernatePersistentMapConverter.java (2276 => 2277)


--- trunk/xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate/converter/HibernatePersistentMapConverter.java	2014-03-12 23:19:40 UTC (rev 2276)
+++ trunk/xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate/converter/HibernatePersistentMapConverter.java	2014-04-05 19:39:40 UTC (rev 2277)
@@ -1,11 +1,11 @@
 /*
- * Copyright (C) 2011, 2012, 2013 XStream Committers.
+ * Copyright (C) 2011, 2012, 2013, 2014 XStream Committers.
  * All rights reserved.
  *
  * The software in this package is published under the terms of the BSD
  * style license a copy of which has been included with this distribution in
  * the LICENSE.txt file.
- * 
+ *
  * Created on 19. April 2011 by Joerg Schaible
  */
 package com.thoughtworks.xstream.hibernate.converter;
@@ -19,10 +19,9 @@
 
 
 /**
- * A converter for Hibernate's PersistentMap and for the MapProxy from Hibernate's Envers
- * add-on. The converter will drop any reference to the Hibernate collection and emit at
- * serialization time an equivalent JDK collection instead.
- * 
+ * A converter for Hibernate's PersistentMap and for the MapProxy from Hibernate's Envers add-on. The converter will
+ * drop any reference to the Hibernate collection and emit at serialization time an equivalent JDK collection instead.
+ *
  * @author J&ouml;rg Schaible
  * @since 1.4
  */
@@ -30,7 +29,7 @@
 
     /**
      * Construct a HibernatePersistentMapConverter.
-     * 
+     *
      * @param mapper
      * @since 1.4
      */
@@ -38,12 +37,13 @@
         super(mapper);
     }
 
-    public boolean canConvert(final Class type) {
+    @Override
+    public boolean canConvert(final Class<?> type) {
         return type != null && (type == Hibernate.PersistentMap || type == Hibernate.EnversMap);
     }
 
-    public Object unmarshal(final HierarchicalStreamReader reader,
-        final UnmarshallingContext context) {
+    @Override
+    public Object unmarshal(final HierarchicalStreamReader reader, final UnmarshallingContext context) {
         throw new ConversionException("Cannot deserialize Hibernate collection");
     }
 }

Modified: trunk/xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate/converter/HibernatePersistentSortedMapConverter.java (2276 => 2277)


--- trunk/xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate/converter/HibernatePersistentSortedMapConverter.java	2014-03-12 23:19:40 UTC (rev 2276)
+++ trunk/xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate/converter/HibernatePersistentSortedMapConverter.java	2014-04-05 19:39:40 UTC (rev 2277)
@@ -1,11 +1,11 @@
 /*
- * Copyright (C) 2011, 2012, 2013 XStream Committers.
+ * Copyright (C) 2011, 2012, 2013, 2014 XStream Committers.
  * All rights reserved.
  *
  * The software in this package is published under the terms of the BSD
  * style license a copy of which has been included with this distribution in
  * the LICENSE.txt file.
- * 
+ *
  * Created on 19. April 2011 by Joerg Schaible
  */
 package com.thoughtworks.xstream.hibernate.converter;
@@ -19,10 +19,10 @@
 
 
 /**
- * A converter for Hibernate's PersistentSortedMap and for the SortedMapProxy from Hibernate's
- * Envers add-on. The converter will drop any reference to the Hibernate collection and emit at
- * serialization time an equivalent JDK collection instead.
- * 
+ * A converter for Hibernate's PersistentSortedMap and for the SortedMapProxy from Hibernate's Envers add-on. The
+ * converter will drop any reference to the Hibernate collection and emit at serialization time an equivalent JDK
+ * collection instead.
+ *
  * @author J&ouml;rg Schaible
  * @since 1.4
  */
@@ -30,7 +30,7 @@
 
     /**
      * Construct a HibernatePersistentSortedMapConverter.
-     * 
+     *
      * @param mapper
      * @since 1.4
      */
@@ -38,12 +38,13 @@
         super(mapper);
     }
 
-    public boolean canConvert(final Class type) {
+    @Override
+    public boolean canConvert(final Class<?> type) {
         return type != null && (type == Hibernate.PersistentSortedMap || type == Hibernate.EnversSortedMap);
     }
 
-    public Object unmarshal(final HierarchicalStreamReader reader,
-        final UnmarshallingContext context) {
+    @Override
+    public Object unmarshal(final HierarchicalStreamReader reader, final UnmarshallingContext context) {
         throw new ConversionException("Cannot deserialize Hibernate collection");
     }
 }

Modified: trunk/xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate/converter/HibernatePersistentSortedSetConverter.java (2276 => 2277)


--- trunk/xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate/converter/HibernatePersistentSortedSetConverter.java	2014-03-12 23:19:40 UTC (rev 2276)
+++ trunk/xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate/converter/HibernatePersistentSortedSetConverter.java	2014-04-05 19:39:40 UTC (rev 2277)
@@ -1,11 +1,11 @@
 /*
- * Copyright (C) 2011, 2012, 2013 XStream Committers.
+ * Copyright (C) 2011, 2012, 2013, 2014 XStream Committers.
  * All rights reserved.
  *
  * The software in this package is published under the terms of the BSD
  * style license a copy of which has been included with this distribution in
  * the LICENSE.txt file.
- * 
+ *
  * Created on 19. April 2011 by Joerg Schaible
  */
 package com.thoughtworks.xstream.hibernate.converter;
@@ -19,10 +19,10 @@
 
 
 /**
- * A converter for Hibernate's PersistentSortedSet and for the SortedSetProxy from Hibernate's
- * Envers add-on. The converter will drop any reference to the Hibernate collection and emit at
- * serialization time an equivalent JDK collection instead.
- * 
+ * A converter for Hibernate's PersistentSortedSet and for the SortedSetProxy from Hibernate's Envers add-on. The
+ * converter will drop any reference to the Hibernate collection and emit at serialization time an equivalent JDK
+ * collection instead.
+ *
  * @author J&ouml;rg Schaible
  * @since 1.4
  */
@@ -30,7 +30,7 @@
 
     /**
      * Construct a HibernatePersistentSortedSetConverter.
-     * 
+     *
      * @param mapper
      * @since 1.4
      */
@@ -38,12 +38,13 @@
         super(mapper);
     }
 
-    public boolean canConvert(final Class type) {
+    @Override
+    public boolean canConvert(final Class<?> type) {
         return type != null && (type == Hibernate.PersistentSortedSet || type == Hibernate.EnversSortedSet);
     }
 
-    public Object unmarshal(final HierarchicalStreamReader reader,
-        final UnmarshallingContext context) {
+    @Override
+    public Object unmarshal(final HierarchicalStreamReader reader, final UnmarshallingContext context) {
         throw new ConversionException("Cannot deserialize Hibernate collection");
     }
 }

Modified: trunk/xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate/converter/HibernateProxyConverter.java (2276 => 2277)


--- trunk/xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate/converter/HibernateProxyConverter.java	2014-03-12 23:19:40 UTC (rev 2276)
+++ trunk/xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate/converter/HibernateProxyConverter.java	2014-04-05 19:39:40 UTC (rev 2277)
@@ -1,15 +1,17 @@
 /*
- * Copyright (C) 2007, 2011 XStream Committers.
+ * Copyright (C) 2007, 2011, 2014 XStream Committers.
  * All rights reserved.
  *
  * The software in this package is published under the terms of the BSD
  * style license a copy of which has been included with this distribution in
  * the LICENSE.txt file.
- * 
+ *
  * Created on 11. January 2007 by Konstantin Pribluda
  */
 package com.thoughtworks.xstream.hibernate.converter;
 
+import org.hibernate.proxy.HibernateProxy;
+
 import com.thoughtworks.xstream.converters.ConversionException;
 import com.thoughtworks.xstream.converters.Converter;
 import com.thoughtworks.xstream.converters.MarshallingContext;
@@ -17,32 +19,28 @@
 import com.thoughtworks.xstream.io.HierarchicalStreamReader;
 import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
 
-import org.hibernate.proxy.HibernateProxy;
 
-
 /**
- * Converter for Hibernate proxy instances. The converter will effectively remove any trace of
- * the proxy.
- * 
+ * Converter for Hibernate proxy instances. The converter will effectively remove any trace of the proxy.
+ *
  * @author Konstantin Pribluda
  * @author J&ouml;rg Schaible
  */
 public class HibernateProxyConverter implements Converter {
-    public boolean canConvert(final Class clazz) {
+    @Override
+    public boolean canConvert(final Class<?> clazz) {
         // be responsible for Hibernate proxy.
         return HibernateProxy.class.isAssignableFrom(clazz);
     }
 
-    public void marshal(final Object object, final HierarchicalStreamWriter writer,
-        final MarshallingContext context) {
-        final Object item = ((HibernateProxy)object)
-            .getHibernateLazyInitializer()
-            .getImplementation();
+    @Override
+    public void marshal(final Object object, final HierarchicalStreamWriter writer, final MarshallingContext context) {
+        final Object item = ((HibernateProxy)object).getHibernateLazyInitializer().getImplementation();
         context.convertAnother(item);
     }
 
-    public Object unmarshal(final HierarchicalStreamReader reader,
-        final UnmarshallingContext context) {
+    @Override
+    public Object unmarshal(final HierarchicalStreamReader reader, final UnmarshallingContext context) {
         throw new ConversionException("Cannot deserialize Hibernate proxy");
     }
 }

Modified: trunk/xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate/mapper/HibernateMapper.java (2276 => 2277)


--- trunk/xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate/mapper/HibernateMapper.java	2014-03-12 23:19:40 UTC (rev 2276)
+++ trunk/xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate/mapper/HibernateMapper.java	2014-04-05 19:39:40 UTC (rev 2277)
@@ -1,11 +1,11 @@
 /*
- * Copyright (C) 2007, 2011, 2012, 2013 XStream Committers.
+ * Copyright (C) 2007, 2011, 2012, 2013, 2014 XStream Committers.
  * All rights reserved.
  *
  * The software in this package is published under the terms of the BSD
  * style license a copy of which has been included with this distribution in
  * the LICENSE.txt file.
- * 
+ *
  * Created on 11. January 2007 by Konstantin Pribluda
  */
 package com.thoughtworks.xstream.hibernate.mapper;
@@ -17,24 +17,24 @@
 import java.util.TreeMap;
 import java.util.TreeSet;
 
+import org.hibernate.proxy.HibernateProxy;
+
 import com.thoughtworks.xstream.hibernate.util.Hibernate;
 import com.thoughtworks.xstream.mapper.MapperWrapper;
 
-import org.hibernate.proxy.HibernateProxy;
 
-
 /**
- * Mapper for Hibernate types. It will map the class names of the Hibernate collections and
- * Envers collection proxies with equivalents of the JDK at serialization time. It will also map
- * the names of the proxy types to the names of the proxies element's type.
- * 
+ * Mapper for Hibernate types. It will map the class names of the Hibernate collections and Envers collection proxies
+ * with equivalents of the JDK at serialization time. It will also map the names of the proxy types to the names of the
+ * proxies element's type.
+ *
  * @author Konstantin Pribluda
  * @author J&ouml;rg Schaible
  * @since 1.4
  */
 public class HibernateMapper extends MapperWrapper {
 
-    final private Map collectionMap = new HashMap();
+    final private Map<Class<?>, Class<?>> collectionMap = new HashMap<Class<?>, Class<?>>();
 
     public HibernateMapper(final MapperWrapper mapper) {
         super(mapper);
@@ -52,19 +52,21 @@
         collectionMap.remove(null);
     }
 
-    public Class defaultImplementationOf(final Class clazz) {
+    @Override
+    public Class<?> defaultImplementationOf(final Class<?> clazz) {
         if (collectionMap.containsKey(clazz)) {
-            return super.defaultImplementationOf((Class)collectionMap.get(clazz));
+            return super.defaultImplementationOf(collectionMap.get(clazz));
         }
 
         return super.defaultImplementationOf(clazz);
     }
 
-    public String serializedClass(final Class clazz) {
+    @Override
+    public String serializedClass(final Class<?> clazz) {
         if (clazz != null) {
             if (collectionMap.containsKey(clazz)) {
                 // Pretend this is the underlying collection class and map that instead
-                return super.serializedClass((Class)collectionMap.get(clazz));
+                return super.serializedClass(collectionMap.get(clazz));
             }
             // check whether we are Hibernate proxy and substitute real name
             if (HibernateProxy.class.isAssignableFrom(clazz)) {

Modified: trunk/xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate/util/Hibernate.java (2276 => 2277)


--- trunk/xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate/util/Hibernate.java	2014-03-12 23:19:40 UTC (rev 2276)
+++ trunk/xstream-hibernate/src/java/com/thoughtworks/xstream/hibernate/util/Hibernate.java	2014-04-05 19:39:40 UTC (rev 2277)
@@ -1,58 +1,64 @@
 /*
- * Copyright (C) 2012, 2013 Joerg Schaible.
+ * Copyright (C) 2012, 2013, 2014 Joerg Schaible.
  * All rights reserved.
  *
  * Created on 08.06.2012 by Joerg Schaible
  */
 package com.thoughtworks.xstream.hibernate.util;
 
-import com.thoughtworks.xstream.core.JVM;
-
 import org.hibernate.proxy.HibernateProxy;
 
 
 /**
  * Utility class for Hibernate support.
- * 
+ *
  * @author J&ouml;rg Schaible
  * @since 1.4.3
  */
 public class Hibernate {
-    public final static Class PersistentBag = loadHibernateType("org.hibernate.collection.internal.PersistentBag");
-    public final static Class PersistentList = loadHibernateType("org.hibernate.collection.internal.PersistentList");
-    public final static Class PersistentMap = loadHibernateType("org.hibernate.collection.internal.PersistentMap");
-    public final static Class PersistentSet = loadHibernateType("org.hibernate.collection.internal.PersistentSet");
-    public final static Class PersistentSortedMap = loadHibernateType("org.hibernate.collection.internal.PersistentSortedMap");
-    public final static Class PersistentSortedSet = loadHibernateType("org.hibernate.collection.internal.PersistentSortedSet");
-    public final static Class EnversList = loadHibernateEnversType("org.hibernate.envers.entities.mapper.relation.lazy.proxy.ListProxy");
-    public final static Class EnversMap = loadHibernateEnversType("org.hibernate.envers.entities.mapper.relation.lazy.proxy.MapProxy");
-    public final static Class EnversSet = loadHibernateEnversType("org.hibernate.envers.entities.mapper.relation.lazy.proxy.SetProxy");
-    public final static Class EnversSortedMap = loadHibernateEnversType("org.hibernate.envers.entities.mapper.relation.lazy.proxy.SortedMapProxy");
-    public final static Class EnversSortedSet = loadHibernateEnversType("org.hibernate.envers.entities.mapper.relation.lazy.proxy.SortedSetProxy");
+    /** <code>PersistentBag</code> contains Hibernate's PersistenBag class type. */
+    public final static Class<?> PersistentBag = loadHibernateType("org.hibernate.collection.internal.PersistentBag");
+    /** <code>PersistentList</code> contains Hibernate's PersistenList class type. */
+    public final static Class<?> PersistentList = loadHibernateType("org.hibernate.collection.internal.PersistentList");
+    /** <code>PersistentMap</code> contains Hibernate's PersistenMap class type. */
+    public final static Class<?> PersistentMap = loadHibernateType("org.hibernate.collection.internal.PersistentMap");
+    /** <code>PersistentSet</code> contains Hibernate's PersistenSet class type. */
+    public final static Class<?> PersistentSet = loadHibernateType("org.hibernate.collection.internal.PersistentSet");
+    /** <code>PersistentSortedMap</code> contains Hibernate's PersistenSortedMap class type. */
+    public final static Class<?> PersistentSortedMap = loadHibernateType("org.hibernate.collection.internal.PersistentSortedMap");
+    /** <code>PersistentSortedSet</code> contains Hibernate's PersistenSortedSet class type. */
+    public final static Class<?> PersistentSortedSet = loadHibernateType("org.hibernate.collection.internal.PersistentSortedSet");
+    /** <code>EnversList</code> contains the ListProxy class type for Hibernate Envers. */
+    public final static Class<?> EnversList = loadHibernateEnversType("org.hibernate.envers.entities.mapper.relation.lazy.proxy.ListProxy");
+    /** <code>EnversMap</code> contains the MapProxy class type for Hibernate Envers. */
+    public final static Class<?> EnversMap = loadHibernateEnversType("org.hibernate.envers.entities.mapper.relation.lazy.proxy.MapProxy");
+    /** <code>EnversSet</code> contains the SetProxy class type for Hibernate Envers. */
+    public final static Class<?> EnversSet = loadHibernateEnversType("org.hibernate.envers.entities.mapper.relation.lazy.proxy.SetProxy");
+    /** <code>EnversSortedMap</code> contains the SortedMapProxy class type for Hibernate Envers. */
+    public final static Class<?> EnversSortedMap = loadHibernateEnversType("org.hibernate.envers.entities.mapper.relation.lazy.proxy.SortedMapProxy");
+    /** <code>EnversSortedSet</code> contains the SortedSetProxy class type for Hibernate Envers. */
+    public final static Class<?> EnversSortedSet = loadHibernateEnversType("org.hibernate.envers.entities.mapper.relation.lazy.proxy.SortedSetProxy");
 
-    private static Class loadHibernateType(String name) {
-        Class type = null;
+    private static Class<?> loadHibernateType(final String name) {
+        Class<?> type = null;
         try {
             try {
                 type = HibernateProxy.class.getClassLoader().loadClass(name);
-            } catch (ClassNotFoundException e) {
-                type = HibernateProxy.class.getClassLoader().loadClass(
-                    name.replaceFirst("\\.internal\\.", "."));
+            } catch (final ClassNotFoundException e) {
+                type = HibernateProxy.class.getClassLoader().loadClass(name.replaceFirst("\\.internal\\.", "."));
             }
-        } catch (ClassNotFoundException e) {
+        } catch (final ClassNotFoundException e) {
             // not available
         }
         return type;
     }
 
-    private static Class loadHibernateEnversType(String name) {
-        Class type = null;
-        if (JVM.is15()) {
-            try {
-                type = HibernateProxy.class.getClassLoader().loadClass(name);
-            } catch (ClassNotFoundException e) {
-                // not available
-            }
+    private static Class<?> loadHibernateEnversType(final String name) {
+        Class<?> type = null;
+        try {
+            type = HibernateProxy.class.getClassLoader().loadClass(name);
+        } catch (final ClassNotFoundException e) {
+            // not available
         }
         return type;
     }

To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Reply via email to