Author: pete.muir(a)jboss.org
Date: 2009-07-02 14:46:59 -0400 (Thu, 02 Jul 2009)
New Revision: 2955
Removed:
ri/trunk/impl/src/main/java/org/jboss/webbeans/ManagerAttachedIterable.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/AbstractIterator.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ConcurrentCollection.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ConcurrentList.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/EnumerationIterator.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/EnumerationVector.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ForwardingCollection.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ForwardingConcurrentMap.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ForwardingIterable.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ForwardingIterator.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ForwardingMap.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ForwardingObject.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ForwardingSet.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/Iterables.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/Iterators.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/UnmodifiableIterator.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/
Modified:
ri/trunk/impl/pom.xml
ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/AnnotationStore.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBAnnotationImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBClassImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBConstructorImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBMethodImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/TypeStore.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ConcurrentCache.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/EnumerationIterable.java
ri/trunk/version-matrix/pom.xml
Log:
switch to using google collections
Modified: ri/trunk/impl/pom.xml
===================================================================
--- ri/trunk/impl/pom.xml 2009-07-02 16:19:34 UTC (rev 2954)
+++ ri/trunk/impl/pom.xml 2009-07-02 18:46:59 UTC (rev 2955)
@@ -79,6 +79,11 @@
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
</dependency>
+
+ <dependency>
+ <groupId>com.google.collections</groupId>
+ <artifactId>google-collections</artifactId>
+ </dependency>
<dependency>
<groupId>javax.jms</groupId>
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java 2009-07-02
16:19:34 UTC (rev 2954)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java 2009-07-02
18:46:59 UTC (rev 2955)
@@ -98,12 +98,14 @@
import org.jboss.webbeans.util.Observers;
import org.jboss.webbeans.util.Proxies;
import org.jboss.webbeans.util.Reflections;
-import org.jboss.webbeans.util.collections.ForwardingIterable;
-import org.jboss.webbeans.util.collections.Iterables;
-import org.jboss.webbeans.util.collections.Iterators;
-import org.jboss.webbeans.util.collections.multi.ConcurrentListHashMultiMap;
-import org.jboss.webbeans.util.collections.multi.ConcurrentListMultiMap;
+import com.google.common.base.Function;
+import com.google.common.base.Supplier;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Iterators;
+import com.google.common.collect.ListMultimap;
+import com.google.common.collect.Multimaps;
+
/**
* Implementation of the Web Beans Manager.
*
@@ -184,7 +186,7 @@
*/
// Contexts are shared across the application
- private transient final ConcurrentListMultiMap<Class<? extends Annotation>,
Context> contexts;
+ private transient final ListMultimap<Class<? extends Annotation>, Context>
contexts;
// Client proxies can be used application wide
private transient final ClientProxyProvider clientProxyProvider;
@@ -278,6 +280,16 @@
defaultEnabledDeploymentTypes.add(1, Production.class);
List<Class<?>> defaultEnabledDecoratorClasses = new
ArrayList<Class<?>>();
+
+ ListMultimap<Class<? extends Annotation>, Context> contexts =
Multimaps.newListMultimap(new ConcurrentHashMap<Class<? extends Annotation>,
Collection<Context>>(), new Supplier<List<Context>>()
+ {
+
+ public List<Context> get()
+ {
+ return new CopyOnWriteArrayList<Context>();
+ }
+
+ });
return new BeanManagerImpl(
serviceRegistry,
@@ -288,7 +300,7 @@
new ConcurrentHashMap<Class<?>, EnterpriseBean<?>>(),
new ConcurrentHashMap<String, RIBean<?>>(),
new ClientProxyProvider(),
- new ConcurrentListHashMultiMap<Class<? extends Annotation>,
Context>(),
+ contexts,
new CopyOnWriteArraySet<CurrentActivity>(),
new HashMap<Contextual<?>, Contextual<?>>(),
defaultEnabledDeploymentTypes, defaultEnabledDecoratorClasses,
new AtomicInteger());
@@ -342,8 +354,7 @@
Map<Class<?>, EnterpriseBean<?>> newEnterpriseBeans,
Map<String, RIBean<?>> riBeans,
ClientProxyProvider clientProxyProvider,
- ConcurrentListMultiMap<Class<? extends Annotation>,
- Context> contexts,
+ ListMultimap<Class<? extends Annotation>, Context> contexts,
Set<CurrentActivity> currentActivities,
Map<Contextual<?>, Contextual<?>> specializedBeans,
List<Class<? extends Annotation>> enabledDeploymentTypes,
@@ -409,11 +420,21 @@
{
return new Iterable<T>()
{
+
+ private Function<Iterable<T>, Iterator<T>> function = new
Function<Iterable<T>, Iterator<T>>()
+ {
+ public Iterator<T> apply(Iterable<T> iterable)
+ {
+ return iterable.iterator();
+ }
+
+ };
+
public Iterator<T> iterator()
{
Set<Iterable<T>> iterable = buildAccessibleClosure(new
ArrayList<BeanManagerImpl>(), transform);
- return Iterators.concat(Iterators.transform(iterable.iterator(),
Iterables.<T>iteratorTransform()));
+ return Iterators.concat(Iterators.transform(iterable.iterator(), function));
}
};
@@ -477,31 +498,6 @@
accessibleManagers.add(accessibleBeanManager);
}
- private static class ManagerAttachedIterable<X> extends
ForwardingIterable<X>
- {
-
- private final BeanManagerImpl beanManager;
- private final Iterable<X> iterable;
-
- public ManagerAttachedIterable(BeanManagerImpl beanManager, Iterable<X>
iterable)
- {
- this.beanManager = beanManager;
- this.iterable = iterable;
- }
-
- public BeanManagerImpl getBeanManager()
- {
- return beanManager;
- }
-
- @Override
- protected Iterable<X> delegate()
- {
- return iterable;
- }
-
- }
-
protected Set<BeanManagerImpl> getAccessibleManagers()
{
return accessibleManagers;
@@ -1216,7 +1212,7 @@
return clientProxyProvider;
}
- protected ConcurrentListMultiMap<Class<? extends Annotation>, Context>
getContexts()
+ protected ListMultimap<Class<? extends Annotation>, Context>
getContexts()
{
return contexts;
}
Deleted: ri/trunk/impl/src/main/java/org/jboss/webbeans/ManagerAttachedIterable.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/ManagerAttachedIterable.java 2009-07-02
16:19:34 UTC (rev 2954)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/ManagerAttachedIterable.java 2009-07-02
18:46:59 UTC (rev 2955)
@@ -1,44 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed 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.jboss.webbeans;
-
-import org.jboss.webbeans.util.collections.ForwardingIterable;
-
-class ManagerAttachedIterable<X> extends ForwardingIterable<X>
-{
-
- private final BeanManagerImpl beanManager;
- private final Iterable<X> iterable;
-
- public ManagerAttachedIterable(BeanManagerImpl beanManager, Iterable<X>
iterable)
- {
- this.beanManager = beanManager;
- this.iterable = iterable;
- }
-
- public BeanManagerImpl getBeanManager()
- {
- return beanManager;
- }
-
- @Override
- protected Iterable<X> delegate()
- {
- return iterable;
- }
-
-}
\ No newline at end of file
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/AnnotationStore.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/AnnotationStore.java 2009-07-02
16:19:34 UTC (rev 2954)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/AnnotationStore.java 2009-07-02
18:46:59 UTC (rev 2955)
@@ -21,6 +21,7 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -31,9 +32,11 @@
import org.jboss.webbeans.literal.CurrentLiteral;
import org.jboss.webbeans.metadata.TypeStore;
-import org.jboss.webbeans.util.collections.multi.SetHashMultiMap;
-import org.jboss.webbeans.util.collections.multi.SetMultiMap;
+import com.google.common.base.Supplier;
+import com.google.common.collect.Multimaps;
+import com.google.common.collect.SetMultimap;
+
public class AnnotationStore
{
@@ -127,7 +130,7 @@
private final Map<Class<? extends Annotation>, Annotation> annotationMap;
// The meta-annotation map (annotation type -> set of annotations containing
// meta-annotation) of the item
- private final SetMultiMap<Class<? extends Annotation>, Annotation>
metaAnnotationMap;
+ private final SetMultimap<Class<? extends Annotation>, Annotation>
metaAnnotationMap;
// The set of all annotations on the item
private final Set<Annotation> annotationSet;
@@ -135,7 +138,7 @@
private final Map<Class<? extends Annotation>, Annotation>
declaredAnnotationMap;
// The meta-annotation map (annotation type -> set of annotations containing
// meta-annotation) of the item
- private final SetMultiMap<Class<? extends Annotation>, Annotation>
declaredMetaAnnotationMap;
+ private final SetMultimap<Class<? extends Annotation>, Annotation>
declaredMetaAnnotationMap;
// The set of all annotations on the item
private final Set<Annotation> declaredAnnotationSet;
@@ -156,7 +159,14 @@
}
this.annotationMap = annotationMap;
this.annotationSet = new HashSet<Annotation>();
- this.metaAnnotationMap = new SetHashMultiMap<Class<? extends Annotation>,
Annotation>();
+ this.metaAnnotationMap = Multimaps.newSetMultimap(new HashMap<Class<? extends
Annotation>, Collection<Annotation>>(), new
Supplier<Set<Annotation>>()
+ {
+
+ public Set<Annotation> get()
+ {
+ return new HashSet<Annotation>();
+ }
+ });
for (Annotation annotation : annotationMap.values())
{
addMetaAnnotations(metaAnnotationMap, annotation,
annotation.annotationType().getAnnotations());
@@ -170,7 +180,14 @@
}
this.declaredAnnotationMap = declaredAnnotationMap;
this.declaredAnnotationSet = new HashSet<Annotation>();
- this.declaredMetaAnnotationMap = new SetHashMultiMap<Class<? extends
Annotation>, Annotation>();
+ this.declaredMetaAnnotationMap = Multimaps.newSetMultimap(new HashMap<Class<?
extends Annotation>, Collection<Annotation>>(), new
Supplier<Set<Annotation>>()
+ {
+
+ public Set<Annotation> get()
+ {
+ return new HashSet<Annotation>();
+ }
+ });
for (Annotation declaredAnnotation : declaredAnnotationMap.values())
{
addMetaAnnotations(declaredMetaAnnotationMap, declaredAnnotation,
declaredAnnotation.annotationType().getAnnotations());
@@ -179,7 +196,7 @@
}
}
- private static void addMetaAnnotations(SetMultiMap<Class<? extends
Annotation>, Annotation> metaAnnotationMap, Annotation annotation, Annotation[]
metaAnnotations)
+ private static void addMetaAnnotations(SetMultimap<Class<? extends
Annotation>, Annotation> metaAnnotationMap, Annotation annotation, Annotation[]
metaAnnotations)
{
for (Annotation metaAnnotation : metaAnnotations)
{
@@ -187,7 +204,7 @@
}
}
- private static void addMetaAnnotations(SetMultiMap<Class<? extends
Annotation>, Annotation> metaAnnotationMap, Annotation annotation,
Iterable<Annotation> metaAnnotations)
+ private static void addMetaAnnotations(SetMultimap<Class<? extends
Annotation>, Annotation> metaAnnotationMap, Annotation annotation,
Iterable<Annotation> metaAnnotations)
{
for (Annotation metaAnnotation : metaAnnotations)
{
@@ -195,7 +212,7 @@
}
}
- private static void addMetaAnnotation(SetMultiMap<Class<? extends
Annotation>, Annotation> metaAnnotationMap, Annotation annotation, Class<?
extends Annotation> metaAnnotationType)
+ private static void addMetaAnnotation(SetMultimap<Class<? extends
Annotation>, Annotation> metaAnnotationMap, Annotation annotation, Class<?
extends Annotation> metaAnnotationType)
{
// Only map meta-annotations we are interested in
if (MAPPED_METAANNOTATIONS.contains(metaAnnotationType))
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBAnnotationImpl.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBAnnotationImpl.java 2009-07-02
16:19:34 UTC (rev 2954)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBAnnotationImpl.java 2009-07-02
18:46:59 UTC (rev 2955)
@@ -18,6 +18,7 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
+import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -29,9 +30,11 @@
import org.jboss.webbeans.introspector.WBClass;
import org.jboss.webbeans.introspector.WBMethod;
import org.jboss.webbeans.resources.ClassTransformer;
-import org.jboss.webbeans.util.collections.multi.SetHashMultiMap;
-import org.jboss.webbeans.util.collections.multi.SetMultiMap;
+import com.google.common.base.Supplier;
+import com.google.common.collect.Multimaps;
+import com.google.common.collect.SetMultimap;
+
/**
* Represents an annotated annotation
*
@@ -45,7 +48,7 @@
{
// The annotated members map (annotation -> member with annotation)
- private final SetMultiMap<Class<? extends Annotation>, WBMethod<?>>
annotatedMembers;
+ private final SetMultimap<Class<? extends Annotation>, WBMethod<?>>
annotatedMembers;
// The implementation class of the annotation
private final Class<T> clazz;
// The set of abstracted members
@@ -73,7 +76,15 @@
super(AnnotationStore.of(annotationType,
classTransformer.getTypeStore().get(annotationType),
classTransformer.getTypeStore().get(annotationType), classTransformer.getTypeStore()),
annotationType, annotationType, classTransformer);
this.clazz = annotationType;
members = new HashSet<WBMethod<?>>();
- annotatedMembers = new SetHashMultiMap<Class<? extends Annotation>,
WBMethod<?>>();
+ annotatedMembers = Multimaps.newSetMultimap(new HashMap<Class<? extends
Annotation>, Collection<WBMethod<?>>>(), new
Supplier<Set<WBMethod<?>>>()
+ {
+
+ public Set<WBMethod<?>> get()
+ {
+ return new HashSet<WBMethod<?>>();
+ }
+
+ });
this.namedMembers = new HashMap<String, WBMethod<?>>();
for (Method member : clazz.getDeclaredMethods())
{
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBClassImpl.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBClassImpl.java 2009-07-02
16:19:34 UTC (rev 2954)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBClassImpl.java 2009-07-02
18:46:59 UTC (rev 2955)
@@ -22,6 +22,7 @@
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -41,9 +42,11 @@
import org.jboss.webbeans.resources.ClassTransformer;
import org.jboss.webbeans.util.Names;
import org.jboss.webbeans.util.Reflections;
-import org.jboss.webbeans.util.collections.multi.SetHashMultiMap;
-import org.jboss.webbeans.util.collections.multi.SetMultiMap;
+import com.google.common.base.Supplier;
+import com.google.common.collect.Multimaps;
+import com.google.common.collect.SetMultimap;
+
/**
* Represents an annotated class
*
@@ -61,43 +64,43 @@
// The set of abstracted fields
private final Set<WBField<?>> fields;
// The map from annotation type to abstracted field with annotation
- private final SetMultiMap<Class<? extends Annotation>, WBField<?>>
annotatedFields;
+ private final SetMultimap<Class<? extends Annotation>, WBField<?>>
annotatedFields;
// The map from annotation type to abstracted field with meta-annotation
- private final SetMultiMap<Class<? extends Annotation>, WBField<?>>
metaAnnotatedFields;
+ private final SetMultimap<Class<? extends Annotation>, WBField<?>>
metaAnnotatedFields;
// The set of abstracted fields
private final Set<WBField<?>> declaredFields;
private final Map<String, WBField<?>> declaredFieldsByName;
// The map from annotation type to abstracted field with annotation
- private final SetMultiMap<Class<? extends Annotation>, WBField<?>>
declaredAnnotatedFields;
+ private final SetMultimap<Class<? extends Annotation>, WBField<?>>
declaredAnnotatedFields;
// The map from annotation type to abstracted field with meta-annotation
- private final SetMultiMap<Class<? extends Annotation>, WBField<?>>
declaredMetaAnnotatedFields;
+ private final SetMultimap<Class<? extends Annotation>, WBField<?>>
declaredMetaAnnotatedFields;
// The set of abstracted methods
private final Set<WBMethod<?>> methods;
private final Map<MethodSignature, WBMethod<?>>
declaredMethodsBySignature;
private final Map<MethodSignature, WBMethod<?>> methodsBySignature;
// The map from annotation type to abstracted method with annotation
- private final SetMultiMap<Class<? extends Annotation>, WBMethod<?>>
annotatedMethods;
+ private final SetMultimap<Class<? extends Annotation>, WBMethod<?>>
annotatedMethods;
// The map from annotation type to method with a parameter with annotation
- private final SetMultiMap<Class<? extends Annotation>, WBMethod<?>>
methodsByAnnotatedParameters;
+ private final SetMultimap<Class<? extends Annotation>, WBMethod<?>>
methodsByAnnotatedParameters;
// The set of abstracted methods
private final Set<WBMethod<?>> declaredMethods;
// The map from annotation type to abstracted method with annotation
- private final SetMultiMap<Class<? extends Annotation>, WBMethod<?>>
declaredAnnotatedMethods;
+ private final SetMultimap<Class<? extends Annotation>, WBMethod<?>>
declaredAnnotatedMethods;
// The map from annotation type to method with a parameter with annotation
- private final SetMultiMap<Class<? extends Annotation>, WBMethod<?>>
declaredMethodsByAnnotatedParameters;
+ private final SetMultimap<Class<? extends Annotation>, WBMethod<?>>
declaredMethodsByAnnotatedParameters;
// The set of abstracted constructors
private final Set<WBConstructor<T>> constructors;
private final Map<ConstructorSignature, WBConstructor<?>>
declaredConstructorsBySignature;
// The map from annotation type to abstracted constructor with annotation
- private final SetMultiMap<Class<? extends Annotation>,
WBConstructor<T>> annotatedConstructors;
+ private final SetMultimap<Class<? extends Annotation>,
WBConstructor<T>> annotatedConstructors;
// The map from class list to abstracted constructor
private final Map<List<Class<?>>, WBConstructor<T>>
constructorsByArgumentMap;
- private final SetMultiMap<Class<? extends Annotation>,
WBConstructor<?>> constructorsByAnnotatedParameters;
+ private final SetMultimap<Class<? extends Annotation>,
WBConstructor<?>> constructorsByAnnotatedParameters;
// Cached string representation
private String toString;
@@ -123,12 +126,44 @@
super(annotationStore, rawType, type, classTransformer);
this.fields = new HashSet<WBField<?>>();
- this.annotatedFields = new SetHashMultiMap<Class<? extends Annotation>,
WBField<?>>();
- this.metaAnnotatedFields = new SetHashMultiMap<Class<? extends
Annotation>, WBField<?>>();
+ this.annotatedFields = Multimaps.newSetMultimap(new HashMap<Class<? extends
Annotation>, Collection<WBField<?>>>(), new Supplier<
Set<WBField<?>>>()
+ {
+
+ public Set<WBField<?>> get()
+ {
+ return new HashSet<WBField<?>>();
+ }
+
+ });
+ this.metaAnnotatedFields = Multimaps.newSetMultimap(new HashMap<Class<?
extends Annotation>, Collection<WBField<?>>>(), new Supplier<
Set<WBField<?>>>()
+ {
+
+ public Set<WBField<?>> get()
+ {
+ return new HashSet<WBField<?>>();
+ }
+
+ });
this.declaredFields = new HashSet<WBField<?>>();
this.declaredFieldsByName = new HashMap<String, WBField<?>>();
- this.declaredAnnotatedFields = new SetHashMultiMap<Class<? extends
Annotation>, WBField<?>>();
- this.declaredMetaAnnotatedFields = new SetHashMultiMap<Class<? extends
Annotation>, WBField<?>>();
+ this.declaredAnnotatedFields = Multimaps.newSetMultimap(new HashMap<Class<?
extends Annotation>, Collection<WBField<?>>>(), new Supplier<
Set<WBField<?>>>()
+ {
+
+ public Set<WBField<?>> get()
+ {
+ return new HashSet<WBField<?>>();
+ }
+
+ });
+ this.declaredMetaAnnotatedFields = Multimaps.newSetMultimap(new
HashMap<Class<? extends Annotation>, Collection<WBField<?>>>(),
new Supplier< Set<WBField<?>>>()
+ {
+
+ public Set<WBField<?>> get()
+ {
+ return new HashSet<WBField<?>>();
+ }
+
+ });
this._nonStaticMemberClass = Reflections.isNonStaticInnerClass(rawType);
this._abstract = Reflections.isAbstract(rawType);
this._enum = rawType.isEnum();
@@ -169,8 +204,24 @@
this.constructors = new HashSet<WBConstructor<T>>();
this.constructorsByArgumentMap = new HashMap<List<Class<?>>,
WBConstructor<T>>();
- this.annotatedConstructors = new SetHashMultiMap<Class<? extends
Annotation>, WBConstructor<T>>();
- this.constructorsByAnnotatedParameters = new SetHashMultiMap<Class<? extends
Annotation>, WBConstructor<?>>();
+ this.annotatedConstructors = Multimaps.newSetMultimap(new HashMap<Class<?
extends Annotation>, Collection<WBConstructor<T>>>(), new Supplier<
Set<WBConstructor<T>>>()
+ {
+
+ public Set<WBConstructor<T>> get()
+ {
+ return new HashSet<WBConstructor<T>>();
+ }
+
+ });
+ this.constructorsByAnnotatedParameters = Multimaps.newSetMultimap(new
HashMap<Class<? extends Annotation>,
Collection<WBConstructor<?>>>(), new Supplier<
Set<WBConstructor<?>>>()
+ {
+
+ public Set<WBConstructor<?>> get()
+ {
+ return new HashSet<WBConstructor<?>>();
+ }
+
+ });
this.declaredConstructorsBySignature = new HashMap<ConstructorSignature,
WBConstructor<?>>();
for (Constructor<?> constructor : rawType.getDeclaredConstructors())
{
@@ -190,7 +241,7 @@
{
if (!annotatedConstructors.containsKey(annotation.annotationType()))
{
- annotatedConstructors.put(annotation.annotationType(), new
HashSet<WBConstructor<T>>());
+ annotatedConstructors.putAll(annotation.annotationType(), new
HashSet<WBConstructor<T>>());
}
annotatedConstructors.get(annotation.annotationType()).add(annotatedConstructor);
}
@@ -205,11 +256,43 @@
}
this.methods = new HashSet<WBMethod<?>>();
- this.annotatedMethods = new SetHashMultiMap<Class<? extends Annotation>,
WBMethod<?>>();
- this.methodsByAnnotatedParameters = new SetHashMultiMap<Class<? extends
Annotation>, WBMethod<?>>();
+ this.annotatedMethods = Multimaps.newSetMultimap(new HashMap<Class<? extends
Annotation>, Collection<WBMethod<?>>>(), new Supplier<
Set<WBMethod<?>>>()
+ {
+
+ public Set<WBMethod<?>> get()
+ {
+ return new HashSet<WBMethod<?>>();
+ }
+
+ });
+ this.methodsByAnnotatedParameters = Multimaps.newSetMultimap(new
HashMap<Class<? extends Annotation>, Collection<WBMethod<?>>>(),
new Supplier< Set<WBMethod<?>>>()
+ {
+
+ public Set<WBMethod<?>> get()
+ {
+ return new HashSet<WBMethod<?>>();
+ }
+
+ });
this.declaredMethods = new HashSet<WBMethod<?>>();
- this.declaredAnnotatedMethods = new SetHashMultiMap<Class<? extends
Annotation>, WBMethod<?>>();
- this.declaredMethodsByAnnotatedParameters = new SetHashMultiMap<Class<?
extends Annotation>, WBMethod<?>>();
+ this.declaredAnnotatedMethods = Multimaps.newSetMultimap(new HashMap<Class<?
extends Annotation>, Collection<WBMethod<?>>>(), new Supplier<
Set<WBMethod<?>>>()
+ {
+
+ public Set<WBMethod<?>> get()
+ {
+ return new HashSet<WBMethod<?>>();
+ }
+
+ });
+ this.declaredMethodsByAnnotatedParameters = Multimaps.newSetMultimap(new
HashMap<Class<? extends Annotation>, Collection<WBMethod<?>>>(),
new Supplier< Set<WBMethod<?>>>()
+ {
+
+ public Set<WBMethod<?>> get()
+ {
+ return new HashSet<WBMethod<?>>();
+ }
+
+ });
this.declaredMethodsBySignature = new HashMap<MethodSignature,
WBMethod<?>>();
this.methodsBySignature = new HashMap<MethodSignature, WBMethod<?>>();
for (Class<?> c = rawType; c != Object.class && c != null; c =
c.getSuperclass())
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBConstructorImpl.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBConstructorImpl.java 2009-07-02
16:19:34 UTC (rev 2954)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBConstructorImpl.java 2009-07-02
18:46:59 UTC (rev 2955)
@@ -21,7 +21,9 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Type;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
import org.jboss.webbeans.BeanManagerImpl;
@@ -32,9 +34,11 @@
import org.jboss.webbeans.introspector.WBType;
import org.jboss.webbeans.resources.ClassTransformer;
import org.jboss.webbeans.util.Names;
-import org.jboss.webbeans.util.collections.multi.ListHashMultiMap;
-import org.jboss.webbeans.util.collections.multi.ListMultiMap;
+import com.google.common.base.Supplier;
+import com.google.common.collect.ListMultimap;
+import com.google.common.collect.Multimaps;
+
/**
* Represents an annotated constructor
*
@@ -53,7 +57,7 @@
// The list of parameter abstractions
private final List<WBParameter<?>> parameters;
// The mapping of annotation -> parameter abstraction
- private final ListMultiMap<Class<? extends Annotation>,
WBParameter<?>> annotatedParameters;
+ private final ListMultimap<Class<? extends Annotation>,
WBParameter<?>> annotatedParameters;
// The declaring class abstraction
private final WBType<T> declaringClass;
@@ -83,7 +87,15 @@
this.declaringClass = declaringClass;
this.parameters = new ArrayList<WBParameter<?>>();
- annotatedParameters = new ListHashMultiMap<Class<? extends Annotation>,
WBParameter<?>>();
+ annotatedParameters = Multimaps.newListMultimap(new HashMap<Class<? extends
Annotation>, Collection<WBParameter<?>>>(), new Supplier<
List<WBParameter<?>>>()
+ {
+
+ public List<WBParameter<?>> get()
+ {
+ return new ArrayList<WBParameter<?>>();
+ }
+
+ });
for (int i = 0; i < constructor.getParameterTypes().length; i++)
{
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBMethodImpl.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBMethodImpl.java 2009-07-02
16:19:34 UTC (rev 2954)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBMethodImpl.java 2009-07-02
18:46:59 UTC (rev 2955)
@@ -22,7 +22,9 @@
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
import org.jboss.webbeans.introspector.AnnotationStore;
@@ -33,9 +35,11 @@
import org.jboss.webbeans.resources.ClassTransformer;
import org.jboss.webbeans.util.Names;
import org.jboss.webbeans.util.Reflections;
-import org.jboss.webbeans.util.collections.multi.ListHashMultiMap;
-import org.jboss.webbeans.util.collections.multi.ListMultiMap;
+import com.google.common.base.Supplier;
+import com.google.common.collect.ListMultimap;
+import com.google.common.collect.Multimaps;
+
/**
* Represents an annotated method
*
@@ -55,7 +59,7 @@
private final List<WBParameter<?>> parameters;
// A mapping from annotation type to parameter abstraction with that
// annotation present
- private final ListMultiMap<Class<? extends Annotation>,
WBParameter<?>> annotatedParameters;
+ private final ListMultimap<Class<? extends Annotation>,
WBParameter<?>> annotatedParameters;
// The property name
private final String propertyName;
@@ -90,7 +94,15 @@
this.method.setAccessible(true);
this.declaringClass = declaringClass;
this.parameters = new ArrayList<WBParameter<?>>();
- this.annotatedParameters = new ListHashMultiMap<Class<? extends
Annotation>, WBParameter<?>>();
+ this.annotatedParameters = Multimaps.newListMultimap(new HashMap<Class<?
extends Annotation>, Collection<WBParameter<?>>>(), new Supplier<
List<WBParameter<?>>>()
+ {
+
+ public List<WBParameter<?>> get()
+ {
+ return new ArrayList<WBParameter<?>>();
+ }
+
+ });
for (int i = 0; i < method.getParameterTypes().length; i++)
{
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/TypeStore.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/TypeStore.java 2009-07-02
16:19:34 UTC (rev 2954)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/TypeStore.java 2009-07-02
18:46:59 UTC (rev 2955)
@@ -17,13 +17,17 @@
package org.jboss.webbeans.metadata;
import java.lang.annotation.Annotation;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
import java.util.Set;
-import java.util.concurrent.CopyOnWriteArraySet;
import org.jboss.webbeans.bootstrap.api.Service;
-import org.jboss.webbeans.util.collections.multi.ConcurrentSetHashMultiMap;
-import org.jboss.webbeans.util.collections.multi.ConcurrentSetMultiMap;
+import com.google.common.base.Supplier;
+import com.google.common.collect.Multimaps;
+import com.google.common.collect.SetMultimap;
+
/**
* @author pmuir
*
@@ -31,11 +35,19 @@
public class TypeStore implements Service
{
- private final ConcurrentSetMultiMap<Class<? extends Annotation>,
Annotation> extraAnnotations;
+ private final SetMultimap<Class<? extends Annotation>, Annotation>
extraAnnotations;
public TypeStore()
{
- this.extraAnnotations = new ConcurrentSetHashMultiMap<Class<? extends
Annotation>, Annotation>();
+ this.extraAnnotations =
Multimaps.synchronizedSetMultimap(Multimaps.newSetMultimap(new HashMap<Class<?
extends Annotation>, Collection<Annotation>>(), new
Supplier<Set<Annotation>>()
+ {
+
+ public Set<Annotation> get()
+ {
+ return new HashSet<Annotation>();
+ }
+
+ }));
}
public Set<Annotation> get(Class<? extends Annotation> annotationType)
@@ -50,7 +62,6 @@
public void addAll(Class<? extends Annotation> annotationType,
Set<Annotation> annotations)
{
- this.extraAnnotations.putIfAbsent(annotationType, new
CopyOnWriteArraySet<Annotation>());
this.extraAnnotations.get(annotationType).addAll(annotations);
}
}
Deleted:
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/AbstractIterator.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/AbstractIterator.java 2009-07-02
16:19:34 UTC (rev 2954)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/AbstractIterator.java 2009-07-02
18:46:59 UTC (rev 2955)
@@ -1,184 +0,0 @@
-/*
- * Copyright (C) 2007 Google Inc.
- *
- * Licensed 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.jboss.webbeans.util.collections;
-
-import java.util.NoSuchElementException;
-
-/**
- * This class provides a skeletal implementation of the {@code Iterator}
- * interface, to make this interface easier to implement for certain types of
- * data sources.
- *
- * <p>
- * {@code Iterator} requires its implementations to support querying the
- * end-of-data status!
without changing the iterator's state, using the
- * {@link #hasNext} method. But many data sources, such as
- * {@link java.io.Reader#read()}), do not expose this information; the only way
- * to discover whether there is any data left is by trying to retrieve it. These
- * types of data sources are ordinarily difficult to write iterators for. But
- * using this class, one must implement only the {@link #computeNext} method,
- * and invoke the {@link #endOfData} method when appropriate.
- *
- * <p>
- * Another example is an iterator that skips over null elements in a backing
- * iterator. This could be implemented as:
- *
- * <pre>
- * @code
- * public static Iterator<String> skipNulls(final
Iterator<String> in) {
- * return new AbstractIterator<String>() {
- * protected String computeNext() {
- * while (in.hasNext()) {
- * String s = in.next();
- * if (s != null) {
- * return s;
- * }
!
- * }
- * return endOfData();
- * }
- * !
};
-
* }}
- * </pre>
- *
- * This class supports iterators that include null elements.
- *
- * @author Kevin Bourrillion
- */
-public abstract class AbstractIterator<T> extends UnmodifiableIterator<T>
-{
- private State state = State.NOT_READY;
-
- private enum State
- {
- /** We have computed the next element and haven't returned it yet. */
- READY,
-
- /** We haven't yet computed or have already returned the element. */
- NOT_READY,
-
- /** We have reached the end of the data and are finished. */
- DONE,
-
- /** We've suffered an exception and are kaput. */
- FAILED,
- }
-
- private T next;
-
- /**
- * Returns the next element. <b>Note:</b> the implementation must call
- * {@link #endOfData()} when there are no elements left in the iteration.
- * Failure to do so could result in an infinite loop.
- *
- * <p>
- * The initial invocation of {@link #hasNext()} or {@link #next()} calls this
- * method, as!
does the first invocation of {@code hasNext} or {@code next}
- * following each successful call to {@code next}. Once the implementation
- * either invokes {@code endOfData} or throws an exception, {@code
- * computeNext} is guaranteed to never be called again.
- *
- * <p>
- * If this method throws an exception, it will propagate outward to the
- * {@code hasNext} or {@code next} invocation that invoked this method. Any
- * further attempts to use the iterator will result in an
- * {@link IllegalStateException}.
- *
- * <p>
- * The implementation of this method many not invoke the {@code hasNext},
- * {@code next}, or {@link #peek()} methods on this instance; if it does, an
- * {@code IllegalStateException} will result.
- *
- * @return the next element if there was one. If {@code endOfData} was called
- * during execution, the return value will be ignored.
- * @throws RuntimeException if any unrecoverable err!
or happens. This
- * exception will propagate ou!
tward to
the {@code hasNext()},
- * {@code next()}, or {@code peek()} invocation that invoked this
- * method. Any further attempts to use the iterator will result in
- * an {@link IllegalStateException}.
- */
- protected abstract T computeNext();
-
- /**
- * Implementations of {@code computeNext} <b>must</b> invoke this method
when
- * there are no elements left in the iteration.
- *
- * @return {@code null}; a convenience so your {@link #computeNext}
- * implementation can use the simple statement {@code return
- * endOfData();}
- */
- protected final T endOfData()
- {
- state = State.DONE;
- return null;
- }
-
- public final boolean hasNext()
- {
- if (state == State.FAILED)
- {
- throw new IllegalStateException();
- }
- switch (state)
- {
- case DONE:
- return false;
- case READY:
- return true;
- default:
- !
}
- return tryToComputeNext();
- }
-
- private boolean tryToComputeNext()
- {
- state = State.FAILED; // temporary pessimism
- next = computeNext();
- if (state != State.DONE)
- {
- state = State.READY;
- return true;
- }
- return false;
- }
-
- public final T next()
- {
- if (!hasNext())
- {
- throw new NoSuchElementException();
- }
- state = State.NOT_READY;
- return next;
- }
-
- /**
- * Returns the next element in the iteration without advancing the iteration,
- * according to the contract of {@link PeekingIterator#peek()}.
- *
- * <p>
- * Implementations of {@code AbstractIterator} that wish to expose this
- * functionality should implement {@code PeekingIterator}.
- */
- public final T peek()
- {
- if (!hasNext())
- {
- throw new NoSuchElementException();
- }
- return next;
- }
-}
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ConcurrentCache.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ConcurrentCache.java 2009-07-02
16:19:34 UTC (rev 2954)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ConcurrentCache.java 2009-07-02
18:46:59 UTC (rev 2955)
@@ -23,6 +23,8 @@
import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;
+import com.google.common.collect.ForwardingMap;
+
/**
* Represents a thread safe map
*
Deleted:
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ConcurrentCollection.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ConcurrentCollection.java 2009-07-02
16:19:34 UTC (rev 2954)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ConcurrentCollection.java 2009-07-02
18:46:59 UTC (rev 2955)
@@ -1,54 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
-import java.util.Collection;
-import java.util.concurrent.CopyOnWriteArrayList;
-e @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed 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.jboss.webbeans.util.collections;
-
-import java.util.Collection;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-/**
- * Adds concurrent add operations to the collection interface. Signatures and
- * javadoc taken from {@link CopyOnWriteArrayList}.
- *
- * @author Pete Muir
- *
- */
-public interface ConcurrentCollection<E> extends Collection<E>
-{
- /**
- * Appends all of the elements in the specified collection that are not
- * already contained in this list, to the end of this list, in the order that
- * they are returned by the specified collection's iterator.
- *
- * @param c
- * collection containing elements to be added to this list
- * @return the number of elements added
- * @throws NullPointerException
- * if the specified collection is null
- */
- public int addAllAbsent(Collection<? extends E> c);
-
- /**
- * Append the element if not present.
- *
- * @param e
- * element to be added to this list, if absent
- * @return true if the element was added
- */
- public boolean addIfAbsent(E e);
-
-}
Deleted:
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ConcurrentList.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ConcurrentList.java 2009-07-02
16:19:34 UTC (rev 2954)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ConcurrentList.java 2009-07-02
18:46:59 UTC (rev 2955)
@@ -1,60 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed 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.jboss.webbeans.util.collections;
-
-import java.util.Collection;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-/**
- * Implementation of {@link ConcurrentCollection} using a
- * {@link CopyOnWriteArrayList}
- *
- * @author Pete Muir
- *
- */
-public class ConcurrentList<E> extends CopyOnWriteArrayList<E> implements
ConcurrentCollection<E>
-{
-
- @SuppressWarnings("unchecked")
- private static final ConcurrentList EMPTY_LIST = new ConcurrentList();
-
- @SuppressWarnings("unchecked")
- public static <E> ConcurrentList<E> emptyList()
- {
- return EMPTY_LIST;
- }
-
- private static final long serialVersionUID = -7489797765014324457L;
-
- public ConcurrentList()
- {
- super();
- }
-
- public ConcurrentList(Collection<? extends E> collection)
- {
- super(collection);
- }
-
- public ConcurrentList(E[] array)
- {
- super(array);
- }
-
-
-
-}
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/EnumerationIterable.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/EnumerationIterable.java 2009-07-02
16:19:34 UTC (rev 2954)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/EnumerationIterable.java 2009-07-02
18:46:59 UTC (rev 2955)
@@ -17,11 +17,13 @@
package org.jboss.webbeans.util.collections;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
+import com.google.common.collect.Iterables;
+
+
/**
* An Enumeration -> Iteratble adaptor
*
@@ -53,7 +55,7 @@
*/
public Iterator<T> iterator()
{
- return Collections.unmodifiableList(list).iterator();
+ return Iterables.unmodifiableIterable(list).iterator();
}
}
Deleted:
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/EnumerationIterator.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/EnumerationIterator.java 2009-07-02
16:19:34 UTC (rev 2954)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/EnumerationIterator.java 2009-07-02
18:46:59 UTC (rev 2955)
@@ -1,70 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed 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.jboss.webbeans.util.collections;
-
-import java.util.Enumeration;
-import java.util.Iterator;
-
-/**
- * An enumeration -> iterator adapter
- *
- * @author Pete Muir
- */
-public class EnumerationIterator<T> implements Iterator<T>
-{
- // The enumeration
- private Enumeration<T> e;
-
- /**
- * Constructor
- *
- * @param e The enumeration
- */
- public EnumerationIterator(Enumeration<T> e)
- {
- this.e = e;
- }
-
- /**
- * Indicates if there are more items to iterate
- *
- * @return True if more, false otherwise
- */
- public boolean hasNext()
- {
- return e.hasMoreElements();
- }
-
- /**
- * Gets the next item
- *
- * @return The next items
- */
- public T next()
- {
- return (T) e.nextElement();
- }
-
- /**
- * Removes an item. Not supported
- */
- public void remove()
- {
- throw new UnsupportedOperationException();
- }
-
-}
Deleted:
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/EnumerationVector.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/EnumerationVector.java 2009-07-02
16:19:34 UTC (rev 2954)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/EnumerationVector.java 2009-07-02
18:46:59 UTC (rev 2955)
@@ -1,19 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed 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.jboss.webbeans.util.collections;
-
-
Deleted:
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ForwardingCollection.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ForwardingCollection.java 2009-07-02
16:19:34 UTC (rev 2954)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ForwardingCollection.java 2009-07-02
18:46:59 UTC (rev 2955)
@@ -1,135 +0,0 @@
-/*
- * Copyright (C) 2007 Google Inc.
- *
- * Licensed 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.jboss.webbeans.util.collections;
-
-import java.util.Collection;
-import java.util.Iterator;
-
-/**
- * A collection which forwards all its method calls to another collection.
- * Subclasses should override one or more methods to modify the behavior of the
- * backing collection as desired per the <a
- *
href="http://en.wikipedia.org/wiki/Decorator_pattern">decora!
tor pattern</a>.
- *
- * @see ForwardingObject
- * @author Kevin Bourrillion
- * @author Pete Muir
- */
-public abstract class ForwardingCollection<E> extends ForwardingObject implements
Collection<E>
-{
-
- @Override
- protected abstract Collection<E> delegate();
-
- public Iterator<E> iterator()
- {
- return delegate().iterator();
- }
-
- public int size()
- {
- return delegate().size();
- }
-
- /**
- * {@inheritDoc}
- *
- * <p>
- * This method always throws a {@link NullPointerException} when {@code
- * collection} is null.
- */
- public boolean removeAll(Collection<?> collection)
- {
- return delegate().removeAll(checkNotNull(collection));
- }
-
- public boolean isEmpty()
- {
- return delegate().isEmpty();
- }
-
- public boolean contains(Object object)
- {
- return delegate().contains(object);
- }
-
- public Object[] toArray()
- {
- return delegate().toArray();!
- }
-
- public <T> T[] toArray(T[] array)
- {
- !
return
delegate().toArray(array);
- }
-
- public boolean add(E element)
- {
- return delegate().add(element);
- }
-
- public boolean remove(Object object)
- {
- return delegate().remove(object);
- }
-
- public boolean containsAll(Collection<?> collection)
- {
- return delegate().containsAll(collection);
- }
-
- public boolean addAll(Collection<? extends E> collection)
- {
- return delegate().addAll(collection);
- }
-
- /**
- * {@inheritDoc}
- *
- * <p>
- * This method always throws a {@link NullPointerException} when {@code
- * collection} is null.
- */
- public boolean retainAll(Collection<?> collection)
- {
- return delegate().retainAll(checkNotNull(collection));
- }
-
- public void clear()
- {
- delegate().clear();
- }
-
- /**
- * Ensures that an object reference passed as a parameter to the calling
- * method is not null.
- *
- * @param reference
- * !
an object reference
- * @return the non-null reference that was validated
- * @throws NullPointerException
- * if {@code reference} is null
- */
- public static <T> T checkNotNull(T reference)
- {
- if (reference == null)
- {
- throw new NullPointerException();
- }
- return reference;
- }
-
-}
Deleted:
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ForwardingConcurrentMap.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ForwardingConcurrentMap.java 2009-07-02
16:19:34 UTC (rev 2954)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ForwardingConcurrentMap.java 2009-07-02
18:46:59 UTC (rev 2955)
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2007 Google Inc.
- *
- * Licensed 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.jboss.webbeans.util.collections;
-
-import java.util.concurrent.ConcurrentMap;
-
-/**
- * A concurrent map which forwards all its method calls to another concurrent
- * map. Subclasses should override one or more methods to modify the behavior of
- * the backing map as desired per the <a
- *
href="http://en.wikipedia.org/wiki/Decorator_pattern">decorator
pattern</!
a>.
- *
- * @see ForwardingObject
- * @author Charles Fry
- */
-public abstract class ForwardingConcurrentMap<K, V> extends ForwardingMap<K,
V> implements ConcurrentMap<K, V>
-{
-
- @Override
- protected abstract ConcurrentMap<K, V> delegate();
-
- public V putIfAbsent(K key, V value)
- {
- return delegate().putIfAbsent(key, value);
- }
-
- public boolean remove(Object key, Object value)
- {
- return delegate().remove(key, value);
- }
-
- public V replace(K key, V value)
- {
- return delegate().replace(key, value);
- }
-
- public boolean replace(K key, V oldValue, V newValue)
- {
- return delegate().replace(key, oldValue, newValue);
- }
-
-}
Deleted:
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ForwardingIterable.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ForwardingIterable.java 2009-07-02
16:19:34 UTC (rev 2954)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ForwardingIterable.java 2009-07-02
18:46:59 UTC (rev 2955)
@@ -1,35 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed 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.jboss.webbeans.util.collections;
-
-import java.util.Iterator;
-
-/**
- * @author pmuir
- *
- */
-public abstract class ForwardingIterable<T> implements java.lang.Iterable<T>
-{
-
- public Iterator<T> iterator()
- {
- return delegate().iterator();
- }
-
- protected abstract Iterable<T> delegate();
-
-}
Deleted:
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ForwardingIterator.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ForwardingIterator.java 2009-07-02
16:19:34 UTC (rev 2954)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ForwardingIterator.java 2009-07-02
18:46:59 UTC (rev 2955)
@@ -1,63 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed 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.jboss.webbeans.util.collections;
-
-import java.util.Iterator;
-
-/**
- * @author pmuir
- *
- */
-public abstract class ForwardingIterator<E> implements Iterator<E>
-{
-
- protected abstract Iterator<E> delegate();
-
- public boolean hasNext()
- {
- return hasNext();
- }
-
- public E next()
- {
- return next();
- }
-
- public void remove()
- {
- remove();
- }
-
- @Override
- public String toString()
- {
- return delegate().toString();
- }
-
- @Override
- public int hashCode()
- {
- return delegate().hashCode();
- }
-
- @Override
- public boolean equals(Object obj)
- {
- return delegate().equals(obj);
- }
-
-}
Deleted:
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ForwardingMap.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ForwardingMap.java 2009-07-02
16:19:34 UTC (rev 2954)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ForwardingMap.java 2009-07-02
18:46:59 UTC (rev 2955)
@@ -1,211 +0,0 @@
-/*
- * Copyright (C) 2007 Google Inc.
- *
- * Licensed 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.jboss.webbeans.util.collections;
-
-import java.util.Collection;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * A map which forwards all its method calls to another map. Subclasses should
- * override one or more methods to modify the behavior of the backing map as
- * desired per the <a
- *
href="http://en.wikipedia.org/wiki/Decorator_pattern">decorator!
pattern</a>.
- *
- * @see ForwardingObject
- * @author Kevin Bourrillion
- * @author Jared Levy
- */
-public abstract class ForwardingMap<K, V> extends ForwardingObject implements
Map<K, V>
-{
-
- @Override
- protected abstract Map<K, V> delegate();
-
- public int size()
- {
- return delegate().size();
- }
-
- public boolean isEmpty()
- {
- return delegate().isEmpty();
- }
-
- public V remove(Object object)
- {
- return delegate().remove(object);
- }
-
- public void clear()
- {
- delegate().clear();
- }
-
- public boolean containsKey(Object key)
- {
- return delegate().containsKey(key);
- }
-
- public boolean containsValue(Object value)
- {
- return delegate().containsValue(value);
- }
-
- public V get(Object key)
- {
- return delegate().get(key);
- }
-
- public V put(K key, V value)
- {
- return delegate().put(key, value);
- }
-
- public void putAll!
(Map<? extends K, ? extends V> map)
- {
- delegate().pu!
tAll(map
);
- }
-
- private transient Set<K> keySet;
-
- /**
- * {@inheritDoc}
- *
- * <p>
- * The returned set's {@code removeAll} and {@code retainAll} methods always
- * throw a {@link NullPointerException} when given a null collection.
- */
- public Set<K> keySet()
- {
- return (keySet == null) ? keySet = createKeySet() : keySet;
- }
-
- /**
- * Generates a {@link Set} for use by {@link #keySet()}.
- *
- * <p>
- * ForwardingMap's implementation of keySet() calls this method to generate a
- * collection of values, and then reuses that Set for subsequent invocations.
- * By default, this Set is essentially the result of invoking keySet() on the
- * delegate. Override this method if you want to provide another
- * implementation.
- *
- * @return A set for use by keySet().
- */
- protected Set<K> createKeySet()
- {
- final Set<K> delegate = delegate().keySet();
- return new ForwardingSet<K!
()
- {
- @Override
- protected Set<K> delegate()
- {
- return delegate;
- }
- };
- }
-
- private transient Collection<V> values;
-
- /**
- * {@inheritDoc}
- *
- * <p>
- * The returned collection's {@code removeAll} and {@code retainAll} methods
- * always throw a {@link NullPointerException} when given a null collection.
- */
- public Collection<V> values()
- {
- return (values == null) ? values = createValues() : values;
- }
-
- /**
- * Generates a {@link Collection} for use by {@link #values()}.
- *
- * <p>
- * ForwardingMap's implementation of {@code values()} calls this method to
- * generate a collection of values, and then reuses that collection for
- * subsequent invocations. By default, this collection is essentially the
- * result of invoking values() on the delegate. Override this method if you
- * want to provide another implementation.
- !
*
- * @return A set for use by values().
- */
- pr!
otected
Collection<V> createValues()
- {
- final Collection<V> delegate = delegate().values();
- return new ForwardingCollection<V>()
- {
- @Override
- protected Collection<V> delegate()
- {
- return delegate;
- }
- };
- }
-
- private transient Set<Entry<K, V>> entrySet;
-
- /**
- * {@inheritDoc}
- *
- * <p>
- * The returned set's {@code removeAll} and {@code retainAll} methods always
- * throw a {@link NullPointerException} when given a null collection.
- */
- public Set<Entry<K, V>> entrySet()
- {
- return (entrySet == null) ? entrySet = createEntrySet() : entrySet;
- }
-
- /**
- * Generates a {@link Set} for use by {@link #entrySet()}.
- *
- * <p>
- * ForwardingMap's implementation of entrySet() calls this method to generate
- * a set of entries, and then reuses that set for subsequent invocations. By
- * default, this set is essentially the result of!
invoking entrySet() on the
- * delegate. Override this method if you want to provide another
- * implementation.
- *
- * @return A set for use by entrySet().
- */
- protected Set<Entry<K, V>> createEntrySet()
- {
- final Set<Entry<K, V>> delegate = delegate().entrySet();
- return new ForwardingSet<Entry<K, V>>()
- {
- @Override
- protected Set<Entry<K, V>> delegate()
- {
- return delegate;
- }
- };
- }
-
- @Override
- public boolean equals(Object object)
- {
- return object == this || delegate().equals(object);
- }
-
- @Override
- public int hashCode()
- {
- return delegate().hashCode();
- }
-}
Deleted:
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ForwardingObject.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ForwardingObject.java 2009-07-02
16:19:34 UTC (rev 2954)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ForwardingObject.java 2009-07-02
18:46:59 UTC (rev 2955)
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2007 Google Inc.
- *
- * Licensed 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.jboss.webbeans.util.collections;
-
-import java.io.Serializable;
-
-/**
- * An abstract base class for implementing the <a
- *
href="http://en.wikipedia.org/wiki/Decorator_pattern">decorator
pattern</a>.
- * The {@link #delegate()} method must be overridden to return the instance
- * being decorated.
- *
- * This class does <i>not</i> forward the {@code hashCode}!
and {@code equals}
- * methods through to the backing object, but relies on {@code Object}'s
- * implementation. This is necessary to preserve the symmetry of {@code equals}.
- * Custom definitions of equality are usually based on an interface, such as
- * {@code Set} or {@code List}, so that the implementation of {@code equals} can
- * cast the object being tested for equality to the custom interface. {@code
- * ForwardingObject} implements no such custom interfaces directly; they are
- * implemented only in subclasses. Therefore, forwarding {@code equals} would
- * break symmetry, as the forwarding object might consider itself equal to the
- * object being tested, but the reverse could not be true. This behavior is
- * consistent with the JDK's collection wrappers, such as
- * {@link java.util.Collections#unmodifiableCollection}. Use an
- * interface-specific subclass of {@code ForwardingObject}, such as
- * {@link ForwardingList}, to preserve equality behavior, or overr!
ide {@code
- * equals} directly.
- *
- * <p>
- * The {@code t!
oString}
method is forwarded to the delegate. Although this class
- * does not implement {@link Serializable}, a serializable subclass may be
- * created since this class has a parameter-less constructor.
- *
- * @author Mike Bostock
- */
-public abstract class ForwardingObject
-{
-
- /** Sole constructor. */
- protected ForwardingObject()
- {
- }
-
- /**
- * Returns the backing delegate instance that methods are forwarded to.
- * Abstract subclasses generally override the {@link ForwardingObject} method
- * with an abstract method that has a more specific return type, such as
- * {@link ForwardingSet#delegate}. Concrete subclasses override this method
- * to supply the instance being decorated.
- */
- protected abstract Object delegate();
-
- /**
- * Returns the string representation generated by the delegate's {@code
- * toString} method.
- */
- @Override
- public String toString()
- {
- return delegate().toString();
- !
}
-
- /* No equals or hashCode. See class comments for details. */
-}
Deleted:
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ForwardingSet.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ForwardingSet.java 2009-07-02
16:19:34 UTC (rev 2954)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ForwardingSet.java 2009-07-02
18:46:59 UTC (rev 2955)
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2007 Google Inc.
- *
- * Licensed 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.jboss.webbeans.util.collections;
-
-import java.util.Set;
-
-/**
- * A set which forwards all its method calls to another set. Subclasses should
- * override one or more methods to modify the behavior of the backing set as
- * desired per the <a
- *
href="http://en.wikipedia.org/wiki/Decorator_pattern">decorator
pattern</a>.
- *
- * @see ForwardingObject
- * @aut!
hor Kevin Bourrillion
- */
-public abstract class ForwardingSet<E> extends ForwardingCollection<E>
implements Set<E>
-{
-
- @Override
- protected abstract Set<E> delegate();
-
- @Override
- public boolean equals(Object object)
- {
- return object == this || delegate().equals(object);
- }
-
- @Override
- public int hashCode()
- {
- return delegate().hashCode();
- }
-}
Deleted: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/Iterables.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/Iterables.java 2009-07-02
16:19:34 UTC (rev 2954)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/Iterables.java 2009-07-02
18:46:59 UTC (rev 2955)
@@ -1,56 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed 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.jboss.webbeans.util.collections;
-
-import java.util.Iterator;
-
-/**
- * @author pmuir
- *
- */
-public class Iterables
-{
-
- private Iterables() {}
-
- public static <T> Iterators.Function<Iterable<? extends T>,
Iterator<? extends T>> iteratorTransform()
- {
- return new Iterators.Function<Iterable<? extends T>, Iterator<? extends
T>>()
- {
-
- public Iterator<? extends T> apply(Iterable<? extends T> from)
- {
- return from.iterator();
- }
-
- };
- }
-
- public static <T> Iterable<T> concat(final Iterable<? extends
Iterable<? extends T>> inputs)
- {
- return new Iterable<T>()
- {
-
- public Iterator<T> iterator()
- {
- return Iterators.concat(Iterators.transform(inputs.iterator(),
Iterables.<T>iteratorTransform()));
- }
-
- };
- }
-
-}
Deleted: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/Iterators.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/Iterators.java 2009-07-02
16:19:34 UTC (rev 2954)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/Iterators.java 2009-07-02
18:46:59 UTC (rev 2955)
@@ -1,140 +0,0 @@
-/*
- *
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Copyright (C) 2007 Google Inc.
- *
- * Licensed 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.jboss.webbeans.util.collections;
-
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-/**
- * @author Pete Muir
- * @author Kevin Bourrillion
- * @author Scott Bonneau
- *
- */
-public class Iterators
-{
-
- static final UnmodifiableIterator<Object> EMPTY_ITERATOR = new
UnmodifiableIterator<Object>()
- {
- public boolean hasNext()
- {
- return false;
- }
-
- public Object next()
- {
- throw new NoSuchElementException();
- }
- };
-
- /** Returns the empty {@code Iterator}. */
- // Casting to any type is safe since there are no actual elements.
- @SuppressWarnings("unchecked")
- public static <T> UnmodifiableIterator<T> emptyIterator()
- {
- return (UnmodifiableIterator<T>) EMPTY_ITERATOR;
- }
-
- /**
- * Combines multiple iterators into a single iterator. The returned iterator
- * iterates across the elements of each iterator in {@code inputs}. The input
- * iterators are not polled until necessary.
- *
- * <p>
- * The returned iterator supports {@code remove()} when the corresponding
- * input iterator supports it. The methods of the returned iterator may throw
- * {@code NullPointerException} if any of the input iterators are null.
- */
- public static <E> Iterator<E> concat(final Iterator<? extends
Iterator<? extends E>> inputs)
- {
- if (inputs == null)
- {
- throw new NullPointerException();
- }
-
- return new Iterator<E>()
- {
- Iterator<? extends E> current = emptyIterator();
- Iterator<? extends E> removeFrom;
-
- public boolean hasNext()
- {
- boolean currentHasNext;
- while (!(currentHasNext = current.hasNext()) && inputs.hasNext())
- {
- current = inputs.next();
- }
- return currentHasNext;
- }
-
- public E next()
- {
- if (!hasNext())
- {
- throw new NoSuchElementException();
- }
- removeFrom = current;
- return current.next();
- }
-
- public void remove()
- {
- if (removeFrom == null)
- {
- throw new IllegalStateException("no calls to next() since last call
to remove()");
- }
- removeFrom.remove();
- removeFrom = null;
- }
- };
- }
-
- public static interface Function<F, T>
- {
- public T apply(F from);
- }
-
- public static <F, T> Iterator<T> transform(final Iterator<F>
fromIterator, final Function<? super F, ? extends T> function)
- {
- if (function == null)
- {
- throw new IllegalStateException();
- }
- return new Iterator<T>()
- {
- public boolean hasNext()
- {
- return fromIterator.hasNext();
- }
-
- public T next()
- {
- F from = fromIterator.next();
- return function.apply(from);
- }
-
- public void remove()
- {
- fromIterator.remove();
- }
- };
- }
-
-}
Deleted:
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/UnmodifiableIterator.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/UnmodifiableIterator.java 2009-07-02
16:19:34 UTC (rev 2954)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/UnmodifiableIterator.java 2009-07-02
18:46:59 UTC (rev 2955)
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2008 Google Inc.
- *
- * Licensed 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.jboss.webbeans.util.collections;
-
-import java.util.Iterator;
-
-/**
- * An iterator that does not support {@link #remove}.
- *
- * @author Jared Levy
- */
-public abstract class UnmodifiableIterator<E> implements Iterator<E> {
- /**
- * Guaranteed to throw an exception and leave the underlying data unmodified.
- *
- * @throws UnsupportedOperationExcepti!
on always
- */
- public final void remove() {
- throw new UnsupportedOperationException();
- }
-}
-
Modified: ri/trunk/version-matrix/pom.xml
===================================================================
--- ri/trunk/version-matrix/pom.xml 2009-07-02 16:19:34 UTC (rev 2954)
+++ ri/trunk/version-matrix/pom.xml 2009-07-02 18:46:59 UTC (rev 2955)
@@ -93,6 +93,12 @@
<artifactId>scannotation</artifactId>
<version>1.0.2</version>
</dependency>
+
+ <dependency>
+ <groupId>com.google.collections</groupId>
+ <artifactId>google-collections</artifactId>
+ <version>1.0-rc2</version>
+ </dependency>
<dependency>
<groupId>javassist</groupId>