jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1167113 - in /jackrabbit/sandbox/jackrabbit-mk: jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ jackrabbit-spi-commons/src/main/java/org/apache/jackra...
Date Fri, 09 Sep 2011 11:43:50 GMT
Author: mduerig
Date: Fri Sep  9 11:43:50 2011
New Revision: 1167113

URL: http://svn.apache.org/viewvc?rev=1167113&view=rev
Log:
Microkernel based Jackrabbit prototype (WIP) 
refactor: reduce use of suppress(unchecked)

Modified:
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemCacheImpl.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistryImpl.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/ItemInfoCacheImpl.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/iterator/Iterators.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/iterator/Predicates.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/HashCache.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeDefinitionFactory.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/util/WeakIdentityCollection.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/util/Exceptions.java

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemCacheImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemCacheImpl.java?rev=1167113&r1=1167112&r2=1167113&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemCacheImpl.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemCacheImpl.java
Fri Sep  9 11:43:50 2011
@@ -16,16 +16,17 @@
  */
 package org.apache.jackrabbit.jcr2spi;
 
-import java.util.Map;
-
-import javax.jcr.Item;
-import javax.jcr.RepositoryException;
-
 import org.apache.commons.collections.map.LRUMap;
 import org.apache.jackrabbit.jcr2spi.state.ItemState;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.jcr.Item;
+import javax.jcr.RepositoryException;
+import java.util.Map;
+
+import static org.apache.jackrabbit.spi.commons.util.Unchecked.cast;
+
 /**
  * {@code ItemCacheImpl}...
  */
@@ -34,9 +35,8 @@ public class ItemCacheImpl implements It
 
     private final Map<ItemState, Item> cache;
 
-    @SuppressWarnings("unchecked")
     ItemCacheImpl(int maxSize) {
-        cache = new LRUMap(maxSize);
+        cache = cast(new LRUMap(maxSize));
     }
 
     //----------------------------------------------------------< ItemCache >---

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java?rev=1167113&r1=1167112&r2=1167113&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java
Fri Sep  9 11:43:50 2011
@@ -30,6 +30,7 @@ import org.apache.jackrabbit.jcr2spi.sta
 import org.apache.jackrabbit.jcr2spi.util.LogUtil;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.Path;
+import org.apache.jackrabbit.spi.commons.util.Unchecked;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -61,9 +62,9 @@ public abstract class ItemImpl implement
     /**
      * Listeners (weak references)
      */
-    @SuppressWarnings("unchecked")
     protected final Map<ItemLifeCycleListener, ItemLifeCycleListener> listeners =
-        Collections.synchronizedMap(new ReferenceMap(ReferenceMap.WEAK, ReferenceMap.WEAK));
+        Collections.synchronizedMap(Unchecked.<Map<ItemLifeCycleListener, ItemLifeCycleListener>>cast(
+                new ReferenceMap(ReferenceMap.WEAK, ReferenceMap.WEAK)));
 
     protected ItemImpl(SessionImpl session, ItemState state, ItemLifeCycleListener[] listeners)
{
         this.session = session;

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java?rev=1167113&r1=1167112&r2=1167113&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
Fri Sep  9 11:43:50 2011
@@ -94,6 +94,8 @@ import java.io.InputStream;
 import java.security.AccessControlException;
 import java.util.Map;
 
+import static org.apache.jackrabbit.spi.commons.util.Unchecked.cast;
+
 /**
  * {@code SessionImpl}...
  */
@@ -105,8 +107,8 @@ public class SessionImpl extends Abstrac
     /**
      * Listeners (weak references)
      */
-    @SuppressWarnings("unchecked")
-    private final Map<SessionListener, SessionListener> listeners = new ReferenceMap(ReferenceMap.WEAK,
ReferenceMap.WEAK);
+    private final Map<SessionListener, SessionListener> listeners =
+            cast(new ReferenceMap(ReferenceMap.WEAK, ReferenceMap.WEAK));
 
     private final Repository repository;
     private final RepositoryConfig config;

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistryImpl.java?rev=1167113&r1=1167112&r2=1167113&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistryImpl.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistryImpl.java
Fri Sep  9 11:43:50 2011
@@ -16,6 +16,25 @@
  */
 package org.apache.jackrabbit.jcr2spi.nodetype;
 
+import org.apache.commons.collections.map.ReferenceMap;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.QItemDefinition;
+import org.apache.jackrabbit.spi.QNodeDefinition;
+import org.apache.jackrabbit.spi.QNodeTypeDefinition;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
+import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.spi.QValueConstraint;
+import org.apache.jackrabbit.spi.commons.nodetype.NodeTypeStorage;
+import org.apache.jackrabbit.spi.commons.util.Unchecked;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.jcr.NamespaceRegistry;
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.nodetype.NoSuchNodeTypeException;
+import javax.jcr.version.OnParentVersionAction;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -29,27 +48,6 @@ import java.util.Set;
 import java.util.TreeSet;
 import java.util.concurrent.ConcurrentHashMap;
 
-import javax.jcr.NamespaceRegistry;
-import javax.jcr.PropertyType;
-import javax.jcr.RepositoryException;
-import javax.jcr.nodetype.ConstraintViolationException;
-import javax.jcr.nodetype.InvalidNodeTypeDefinitionException;
-import javax.jcr.nodetype.NoSuchNodeTypeException;
-import javax.jcr.nodetype.NodeTypeExistsException;
-import javax.jcr.version.OnParentVersionAction;
-
-import org.apache.commons.collections.map.ReferenceMap;
-import org.apache.jackrabbit.spi.Name;
-import org.apache.jackrabbit.spi.QItemDefinition;
-import org.apache.jackrabbit.spi.QNodeDefinition;
-import org.apache.jackrabbit.spi.QNodeTypeDefinition;
-import org.apache.jackrabbit.spi.QPropertyDefinition;
-import org.apache.jackrabbit.spi.QValue;
-import org.apache.jackrabbit.spi.QValueConstraint;
-import org.apache.jackrabbit.spi.commons.nodetype.NodeTypeStorage;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 /**
  * A {@code NodeTypeRegistry} ...
  */
@@ -75,9 +73,9 @@ public class NodeTypeRegistryImpl implem
     /**
      * Listeners (soft references)
      */
-    @SuppressWarnings("unchecked")
     private final Map<NodeTypeRegistryListener, NodeTypeRegistryListener> listeners
=
-            Collections.synchronizedMap(new ReferenceMap(ReferenceMap.WEAK, ReferenceMap.WEAK));
+            Collections.synchronizedMap(Unchecked.<Map<NodeTypeRegistryListener, NodeTypeRegistryListener>>cast(
+                    new ReferenceMap(ReferenceMap.WEAK, ReferenceMap.WEAK)));
 
     /**
      * Create a new {@code NodeTypeRegistry</codes>}

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/ItemInfoCacheImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/ItemInfoCacheImpl.java?rev=1167113&r1=1167112&r2=1167113&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/ItemInfoCacheImpl.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/ItemInfoCacheImpl.java
Fri Sep  9 11:43:50 2011
@@ -26,6 +26,8 @@ import org.apache.jackrabbit.spi.Propert
 import org.apache.jackrabbit.spi.PropertyInfo;
 import org.apache.jackrabbit.spi.RepositoryService;
 
+import static org.apache.jackrabbit.spi.commons.util.Unchecked.cast;
+
 /**
  * This implementation of {@link ItemInfoCache} has a default size of 5000 items.
  * Item infos are put into the cache after they have been read from the {@link RepositoryService}.
@@ -136,20 +138,18 @@ public class ItemInfoCacheImpl implement
         entries.put(key, entry);
     }
 
-    @SuppressWarnings("unchecked")
     private static Entry<NodeInfo> node(Object entry) {
-        if (entry != null && ((Entry<? extends ItemInfo>) entry).info.denotesNode())
{
-            return (Entry<NodeInfo>) entry;
+        if (entry != null && ((Entry<?>) entry).info.denotesNode()) {
+            return cast(entry);
         }
         else {
             return null;
         }
     }
 
-    @SuppressWarnings("unchecked")
     private static Entry<PropertyInfo> property(Object entry) {
-        if (entry != null && !((Entry<? extends ItemInfo>) entry).info.denotesNode())
{
-            return (Entry<PropertyInfo>) entry;
+        if (entry != null && !((Entry<?>) entry).info.denotesNode()) {
+            return cast(entry);
         }
         else {
             return null;

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/iterator/Iterators.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/iterator/Iterators.java?rev=1167113&r1=1167112&r2=1167113&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/iterator/Iterators.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/iterator/Iterators.java
Fri Sep  9 11:43:50 2011
@@ -22,6 +22,7 @@ import org.apache.commons.collections.it
 import org.apache.commons.collections.iterators.IteratorChain;
 import org.apache.commons.collections.iterators.SingletonIterator;
 import org.apache.commons.collections.iterators.TransformIterator;
+import org.apache.jackrabbit.spi.commons.util.Unchecked;
 
 import javax.jcr.Node;
 import javax.jcr.NodeIterator;
@@ -31,6 +32,8 @@ import javax.jcr.PropertyIterator;
 import java.util.Collection;
 import java.util.Iterator;
 
+import static org.apache.jackrabbit.spi.commons.util.Unchecked.cast;
+
 /**
  * Utility class containing type safe adapters for some of the iterators of
  * commons-collections.
@@ -48,9 +51,8 @@ public final class Iterators {
      * @param element
      * @return
      */
-    @SuppressWarnings("unchecked")
     public static <T> Iterator<T> singleton(T element) {
-        return new SingletonIterator(element);
+        return cast(new SingletonIterator(element));
     }
 
     /**
@@ -59,9 +61,8 @@ public final class Iterators {
      * @param <T>
      * @return
      */
-    @SuppressWarnings("unchecked")
     public static <T> Iterator<T> empty() {
-        return EmptyIterator.INSTANCE;
+        return cast(EmptyIterator.INSTANCE);
     }
 
     /**
@@ -73,9 +74,8 @@ public final class Iterators {
      * @param iterator2
      * @return
      */
-    @SuppressWarnings("unchecked")
     public static <T> Iterator<T> iteratorChain(Iterator<? extends T> iterator1,
Iterator<? extends T> iterator2) {
-        return new IteratorChain(iterator1, iterator2);
+        return cast(new IteratorChain(iterator1, iterator2));
     }
 
     /**
@@ -85,9 +85,8 @@ public final class Iterators {
      * @param iterators
      * @return
      */
-    @SuppressWarnings("unchecked")
     public static <T> Iterator<T> iteratorChain(Iterator<? extends T>[]
iterators) {
-        return new IteratorChain(iterators);
+        return cast(new IteratorChain(iterators));
     }
 
     /**
@@ -97,9 +96,8 @@ public final class Iterators {
      * @param iterators
      * @return
      */
-    @SuppressWarnings("unchecked")
     public static <T> Iterator<T> iteratorChain(Collection<? extends T>
iterators) {
-        return new IteratorChain(iterators);
+        return cast(new IteratorChain(iterators));
     }
 
     /**
@@ -111,9 +109,8 @@ public final class Iterators {
      * @param to  the index to finish iterating at.
      * @return
      */
-    @SuppressWarnings("unchecked")
     public static <T> Iterator<T> arrayIterator(T[] values, int from, int to)
{
-        return new ArrayIterator(values, from, to);
+        return cast(new ArrayIterator(values, from, to));
     }
 
     /**
@@ -125,16 +122,15 @@ public final class Iterators {
      * @param predicate
      * @return
      */
-    @SuppressWarnings("unchecked")
     public static <T> Iterator<T> filterIterator(Iterator<? extends T>
iterator,
             final Predicate<? super T> predicate) {
 
-        return new FilterIterator(iterator, new org.apache.commons.collections.Predicate()
{
+        return cast(new FilterIterator(iterator, new org.apache.commons.collections.Predicate()
{
             @Override
             public boolean evaluate(Object object) {
-                return predicate.evaluate((T) object);
+                return predicate.evaluate(Unchecked.<T>cast(object));
             }
-        });
+        }));
     }
 
     /**
@@ -148,16 +144,15 @@ public final class Iterators {
      * @param transformer
      * @return
      */
-    @SuppressWarnings("unchecked")
     public static <T, R, S extends T> Iterator<R> transformIterator(Iterator<?
extends T> iterator,
             final Transformer<S, ? super R> transformer) {
 
-        return new TransformIterator(iterator, new org.apache.commons.collections.Transformer()
{
+        return cast(new TransformIterator(iterator, new org.apache.commons.collections.Transformer()
{
             @Override
             public Object transform(Object input) {
-                return transformer.transform((S) input);
+                return transformer.transform(Unchecked.<S>cast(input));
             }
-        });
+        }));
     }
 
     /**
@@ -166,9 +161,8 @@ public final class Iterators {
      * @param propertyIterator
      * @return
      */
-    @SuppressWarnings("unchecked")
     public static Iterator<Property> properties(PropertyIterator propertyIterator)
{
-        return propertyIterator;
+        return cast(propertyIterator);
     }
 
     /**
@@ -176,9 +170,8 @@ public final class Iterators {
      * @param nodeIterator
      * @return
      */
-    @SuppressWarnings("unchecked")
     public static Iterator<Node> nodes(NodeIterator nodeIterator) {
-        return nodeIterator;
+        return cast(nodeIterator);
     }
 
 }

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/iterator/Predicates.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/iterator/Predicates.java?rev=1167113&r1=1167112&r2=1167113&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/iterator/Predicates.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/iterator/Predicates.java
Fri Sep  9 11:43:50 2011
@@ -17,6 +17,8 @@
 
 package org.apache.jackrabbit.spi.commons.iterator;
 
+import static org.apache.jackrabbit.spi.commons.util.Unchecked.cast;
+
 /**
  * Utility class containing pre defined {@link Predicate}s
  */
@@ -51,9 +53,8 @@ public final class Predicates {
      * @param <T>
      * @return
      */
-    @SuppressWarnings("unchecked")
     public static <T> Predicate<T> TRUE() {
-        return (Predicate<T>) TRUE;
+        return cast(TRUE);
     }
 
     /**
@@ -61,9 +62,8 @@ public final class Predicates {
      * @param <T>
      * @return
      */
-    @SuppressWarnings("unchecked")
     public static <T> Predicate<T> FALSE() {
-        return (Predicate<T>) FALSE;
+        return cast(FALSE);
     }
 
 }

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/HashCache.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/HashCache.java?rev=1167113&r1=1167112&r2=1167113&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/HashCache.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/HashCache.java
Fri Sep  9 11:43:50 2011
@@ -16,6 +16,8 @@
  */
 package org.apache.jackrabbit.spi.commons.name;
 
+import static org.apache.jackrabbit.spi.commons.util.Unchecked.cast;
+
 /**
  * Simple utility class that implements a fixed-size and thread-safe
  * (non-blocking) cache of objects. The cache is simply an array
@@ -45,9 +47,8 @@ public class HashCache<T> {
      *
      * @param exponent the exponent.
      */
-    @SuppressWarnings("unchecked")
     public HashCache(int exponent) {
-        array = (T[]) new Object[2 << exponent];
+        array = cast(new Object[2 << exponent]);
     }
 
     /**

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeDefinitionFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeDefinitionFactory.java?rev=1167113&r1=1167112&r2=1167113&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeDefinitionFactory.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeDefinitionFactory.java
Fri Sep  9 11:43:50 2011
@@ -42,6 +42,8 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
+import static org.apache.jackrabbit.spi.commons.util.Unchecked.cast;
+
 /**
  * {@code NodeTypeDefinitionFactory} can be used to convert the internal
  * SPI node type definitions to JCR {@link NodeTypeDefinition}s.
@@ -90,9 +92,7 @@ public class NodeTypeDefinitionFactory {
      * @return the corresponding JCR node type definition.
      * @throws RepositoryException if an error occurs.
      */
-    @SuppressWarnings("unchecked")
-    public NodeTypeDefinition create(QNodeTypeDefinition qNtd)
-            throws RepositoryException {
+    public NodeTypeDefinition create(QNodeTypeDefinition qNtd) throws RepositoryException
{
         NodeTypeTemplate nt = ntMgr.createNodeTypeTemplate();
         nt.setName(getJCRName(qNtd.getName()));
         nt.setDeclaredSuperTypeNames(getJCRNames(qNtd.getSupertypes()));
@@ -101,11 +101,11 @@ public class NodeTypeDefinitionFactory {
         nt.setOrderableChildNodes(qNtd.hasOrderableChildNodes());
         nt.setPrimaryItemName(getJCRName(qNtd.getPrimaryItemName()));
         nt.setQueryable(qNtd.isQueryable());
-        List nodeDefs = nt.getNodeDefinitionTemplates();
+        List<NodeDefinition> nodeDefs = cast(nt.getNodeDefinitionTemplates());
         for (QNodeDefinition qNd: qNtd.getChildNodeDefs()) {
             nodeDefs.add(create(qNd));
         }
-        List propDefs = nt.getPropertyDefinitionTemplates();
+        List<PropertyDefinition> propDefs = cast(nt.getPropertyDefinitionTemplates());
         for (QPropertyDefinition qPd: qNtd.getPropertyDefs()) {
             propDefs.add(create(qPd));
         }
@@ -119,8 +119,7 @@ public class NodeTypeDefinitionFactory {
      * @return The corresponding JCR node definition.
      * @throws RepositoryException if an error occurs.
      */
-    public NodeDefinition create(QNodeDefinition qNd)
-            throws RepositoryException {
+    public NodeDefinition create(QNodeDefinition qNd) throws RepositoryException {
         NodeDefinitionTemplate nt = ntMgr.createNodeDefinitionTemplate();
         nt.setName(getJCRName(qNd.getName()));
         nt.setAutoCreated(qNd.isAutoCreated());

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/util/WeakIdentityCollection.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/util/WeakIdentityCollection.java?rev=1167113&r1=1167112&r2=1167113&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/util/WeakIdentityCollection.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/util/WeakIdentityCollection.java
Fri Sep  9 11:43:50 2011
@@ -23,6 +23,8 @@ import java.util.BitSet;
 import java.util.Collection;
 import java.util.Iterator;
 
+import static org.apache.jackrabbit.spi.commons.util.Unchecked.cast;
+
 /**
  * {@code WeakIdentityCollection} implements a Collection with weak values.
  * Equality of elements is tested using the == operator.
@@ -236,16 +238,15 @@ public class WeakIdentityCollection<E> i
      * @inheritDoc
      */
     @Override
-    @SuppressWarnings("unchecked")
     public <T> T[] toArray(T[] a) {
         int size = elementData.size();
         
         if (a.length < size) {
-            a = (T[]) java.lang.reflect.Array.newInstance(a.getClass().getComponentType(),
size);
+            a = cast(java.lang.reflect.Array.newInstance(a.getClass().getComponentType(),
size));
         }
 
         for (int i = 0; i < size; i++) {
-            a[i] = (T) elementData.get(i).get();
+            a[i] = cast(elementData.get(i).get());
         }
 
         if (a.length > size) {

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/util/Exceptions.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/util/Exceptions.java?rev=1167113&r1=1167112&r2=1167113&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/util/Exceptions.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/util/Exceptions.java
Fri Sep  9 11:43:50 2011
@@ -19,12 +19,13 @@
 
 package org.apache.jackrabbit.spi2microkernel.util;
 
+import static org.apache.jackrabbit.spi.commons.util.Unchecked.cast;
+
 public final class Exceptions {
     private Exceptions() {}
 
-    @SuppressWarnings("unchecked")
     public static <E extends Throwable> E setCause(E exception, Throwable cause) {
-        return (E) exception.initCause(cause);
+        return cast(exception.initCause(cause));
     }
 
 }



Mime
View raw message