Make fields private (and final) if possible

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@1477400 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sebastian Bazley 2013-04-29 22:58:50 +00:00
parent 06cec18d4a
commit fcf4320023
22 changed files with 40 additions and 40 deletions

View File

@ -78,7 +78,7 @@ public class SynchronizedBag<E> extends SynchronizedCollection<E> implements Bag
* @return the decorated bag * @return the decorated bag
*/ */
protected Bag<E> getBag() { protected Bag<E> getBag() {
return (Bag<E>) collection; return (Bag<E>) decorated();
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------

View File

@ -78,7 +78,7 @@ public class SynchronizedSortedBag<E> extends SynchronizedBag<E> implements Sort
* @return the decorated bag * @return the decorated bag
*/ */
protected SortedBag<E> getSortedBag() { protected SortedBag<E> getSortedBag() {
return (SortedBag<E>) collection; return (SortedBag<E>) decorated();
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------

View File

@ -59,10 +59,10 @@ public class DualTreeBidiMap<K, V> extends AbstractDualBidiMap<K, V>
private static final long serialVersionUID = 721969328361809L; private static final long serialVersionUID = 721969328361809L;
/** The key comparator to use */ /** The key comparator to use */
protected final Comparator<? super K> comparator; private final Comparator<? super K> comparator;
/** The value comparator to use */ /** The value comparator to use */
protected final Comparator<? super V> valueComparator; private final Comparator<? super V> valueComparator;
/** /**
* Creates an empty <code>DualTreeBidiMap</code> * Creates an empty <code>DualTreeBidiMap</code>

View File

@ -1610,13 +1610,13 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>>
abstract class ViewIterator { abstract class ViewIterator {
/** Whether to return KEY or VALUE order. */ /** Whether to return KEY or VALUE order. */
protected final DataElement orderType; private final DataElement orderType;
/** The last node returned by the iterator. */ /** The last node returned by the iterator. */
protected Node<K, V> lastReturnedNode; Node<K, V> lastReturnedNode;
/** The next node to be returned by the iterator. */ /** The next node to be returned by the iterator. */
protected Node<K, V> nextNode; private Node<K, V> nextNode;
/** The previous node in the sequence returned by the iterator. */ /** The previous node in the sequence returned by the iterator. */
protected Node<K, V> previousNode; private Node<K, V> previousNode;
/** The modification count. */ /** The modification count. */
private int expectedModifications; private int expectedModifications;

View File

@ -45,10 +45,10 @@ public class CompositeCollection<E> implements Collection<E>, Serializable {
private static final long serialVersionUID = 8417515734108306801L; private static final long serialVersionUID = 8417515734108306801L;
/** CollectionMutator to handle changes to the collection */ /** CollectionMutator to handle changes to the collection */
protected CollectionMutator<E> mutator; private CollectionMutator<E> mutator;
/** Collections in the composite */ /** Collections in the composite */
protected List<Collection<E>> all = new ArrayList<Collection<E>>(); private final List<Collection<E>> all = new ArrayList<Collection<E>>();
/** /**
* Create an empty CompositeCollection. * Create an empty CompositeCollection.

View File

@ -44,7 +44,7 @@ public class SynchronizedCollection<E> implements Collection<E>, Serializable {
private static final long serialVersionUID = 2412805092710877986L; private static final long serialVersionUID = 2412805092710877986L;
/** The collection to decorate */ /** The collection to decorate */
protected final Collection<E> collection; private final Collection<E> collection;
/** The object to lock on, needed for List/SortedSet views */ /** The object to lock on, needed for List/SortedSet views */
protected final Object lock; protected final Object lock;

View File

@ -82,7 +82,7 @@ public final class UnmodifiableBoundedCollection<E> extends AbstractCollectionDe
if (coll instanceof AbstractCollectionDecorator) { if (coll instanceof AbstractCollectionDecorator) {
coll = ((AbstractCollectionDecorator<E>) coll).collection; coll = ((AbstractCollectionDecorator<E>) coll).collection;
} else if (coll instanceof SynchronizedCollection) { } else if (coll instanceof SynchronizedCollection) {
coll = ((SynchronizedCollection<E>) coll).collection; coll = ((SynchronizedCollection<E>) coll).decorated();
} }
} }

View File

@ -53,11 +53,11 @@ public class ComparatorChain<E> implements Comparator<E>, Serializable {
private static final long serialVersionUID = -721644942746081630L; private static final long serialVersionUID = -721644942746081630L;
/** The list of comparators in the chain. */ /** The list of comparators in the chain. */
protected List<Comparator<E>> comparatorChain = null; private final List<Comparator<E>> comparatorChain;
/** Order - false (clear) = ascend; true (set) = descend. */ /** Order - false (clear) = ascend; true (set) = descend. */
protected BitSet orderingBits = null; private BitSet orderingBits = null;
/** Whether the chain has been "locked". */ /** Whether the chain has been "locked". */
protected boolean isLocked = false; private boolean isLocked = false;
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
/** /**

View File

@ -41,9 +41,9 @@ public class TransformingComparator<I, O> implements Comparator<I>, Serializable
private static final long serialVersionUID = 3456940356043606220L; private static final long serialVersionUID = 3456940356043606220L;
/** The decorated comparator. */ /** The decorated comparator. */
protected final Comparator<O> decorated; private final Comparator<O> decorated;
/** The transformer being used. */ /** The transformer being used. */
protected final Transformer<? super I, ? extends O> transformer; private final Transformer<? super I, ? extends O> transformer;
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
/** /**

View File

@ -29,7 +29,7 @@ import java.util.ListIterator;
public class AbstractListIteratorDecorator<E> implements ListIterator<E> { public class AbstractListIteratorDecorator<E> implements ListIterator<E> {
/** The iterator being decorated */ /** The iterator being decorated */
protected final ListIterator<E> iterator; private final ListIterator<E> iterator;
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
/** /**

View File

@ -29,7 +29,7 @@ import org.apache.commons.collections4.MapIterator;
public class AbstractMapIteratorDecorator<K, V> implements MapIterator<K, V> { public class AbstractMapIteratorDecorator<K, V> implements MapIterator<K, V> {
/** The iterator being decorated */ /** The iterator being decorated */
protected final MapIterator<K, V> iterator; private final MapIterator<K, V> iterator;
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
/** /**

View File

@ -29,7 +29,7 @@ import org.apache.commons.collections4.OrderedMapIterator;
public class AbstractOrderedMapIteratorDecorator<K, V> implements OrderedMapIterator<K, V> { public class AbstractOrderedMapIteratorDecorator<K, V> implements OrderedMapIterator<K, V> {
/** The iterator being decorated */ /** The iterator being decorated */
protected final OrderedMapIterator<K, V> iterator; private final OrderedMapIterator<K, V> iterator;
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
/** /**

View File

@ -30,7 +30,7 @@ import java.util.Iterator;
public abstract class AbstractUntypedIteratorDecorator<I, O> implements Iterator<O> { public abstract class AbstractUntypedIteratorDecorator<I, O> implements Iterator<O> {
/** The iterator being decorated */ /** The iterator being decorated */
protected final Iterator<I> iterator; private final Iterator<I> iterator;
/** /**
* Create a new AbstractUntypedIteratorDecorator. * Create a new AbstractUntypedIteratorDecorator.

View File

@ -48,25 +48,25 @@ import org.apache.commons.collections4.list.UnmodifiableList;
public class IteratorChain<E> implements Iterator<E> { public class IteratorChain<E> implements Iterator<E> {
/** The chain of iterators */ /** The chain of iterators */
protected final List<Iterator<? extends E>> iteratorChain = new ArrayList<Iterator<? extends E>>(); private final List<Iterator<? extends E>> iteratorChain = new ArrayList<Iterator<? extends E>>();
/** The index of the current iterator */ /** The index of the current iterator */
protected int currentIteratorIndex = 0; private int currentIteratorIndex = 0;
/** The current iterator */ /** The current iterator */
protected Iterator<? extends E> currentIterator = null; private Iterator<? extends E> currentIterator = null;
/** /**
* The "last used" Iterator is the Iterator upon which next() or hasNext() * The "last used" Iterator is the Iterator upon which next() or hasNext()
* was most recently called used for the remove() operation only * was most recently called used for the remove() operation only
*/ */
protected Iterator<? extends E> lastUsedIterator = null; private Iterator<? extends E> lastUsedIterator = null;
/** /**
* ComparatorChain is "locked" after the first time compare(Object,Object) * ComparatorChain is "locked" after the first time compare(Object,Object)
* is called * is called
*/ */
protected boolean isLocked = false; private boolean isLocked = false;
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
/** /**

View File

@ -35,7 +35,7 @@ public class NodeListIterator implements Iterator<Node> {
/** the original NodeList instance */ /** the original NodeList instance */
private final NodeList nodeList; private final NodeList nodeList;
/** The current iterator index */ /** The current iterator index */
protected int index = 0; private int index = 0;
/** /**
* Convenience constructor, which creates a new NodeListIterator from * Convenience constructor, which creates a new NodeListIterator from

View File

@ -46,7 +46,7 @@ public class ObjectArrayListIterator<E> extends ObjectArrayIterator<E>
* has yet been invoked. <code>lastItemIndex</code> is used to to implement the * has yet been invoked. <code>lastItemIndex</code> is used to to implement the
* {@link #set} method. * {@link #set} method.
*/ */
protected int lastItemIndex = -1; private int lastItemIndex = -1;
/** /**
* Constructor for use with <code>setArray</code>. * Constructor for use with <code>setArray</code>.

View File

@ -30,7 +30,7 @@ import org.apache.commons.collections4.KeyValue;
public abstract class AbstractMapEntryDecorator<K, V> implements Map.Entry<K, V>, KeyValue<K, V> { public abstract class AbstractMapEntryDecorator<K, V> implements Map.Entry<K, V>, KeyValue<K, V> {
/** The <code>Map.Entry</code> to decorate */ /** The <code>Map.Entry</code> to decorate */
protected final Map.Entry<K, V> entry; private final Map.Entry<K, V> entry;
/** /**
* Constructor that wraps (not copies). * Constructor that wraps (not copies).

View File

@ -155,13 +155,13 @@ public class PredicatedList<E> extends PredicatedCollection<E> implements List<E
@Override @Override
public void add(final E object) { public void add(final E object) {
validate(object); validate(object);
iterator.add(object); getListIterator().add(object);
} }
@Override @Override
public void set(final E object) { public void set(final E object) {
validate(object); validate(object);
iterator.set(object); getListIterator().set(object);
} }
} }

View File

@ -178,13 +178,13 @@ public class TransformedList<E> extends TransformedCollection<E> implements List
@Override @Override
public void add(E object) { public void add(E object) {
object = transform(object); object = transform(object);
iterator.add(object); getListIterator().add(object);
} }
@Override @Override
public void set(E object) { public void set(E object) {
object = transform(object); object = transform(object);
iterator.set(object); getListIterator().set(object);
} }
} }

View File

@ -178,7 +178,7 @@ abstract class AbstractInputCheckedMapDecorator<K, V>
@Override @Override
public Map.Entry<K, V> next() { public Map.Entry<K, V> next() {
final Map.Entry<K, V> entry = iterator.next(); final Map.Entry<K, V> entry = getIterator().next();
return new MapEntry(entry, parent); return new MapEntry(entry, parent);
} }
} }
@ -199,7 +199,7 @@ abstract class AbstractInputCheckedMapDecorator<K, V>
@Override @Override
public V setValue(V value) { public V setValue(V value) {
value = parent.checkSetValue(value); value = parent.checkSetValue(value);
return entry.setValue(value); return getMapEntry().setValue(value);
} }
} }

View File

@ -154,7 +154,7 @@ public final class UnmodifiableEntrySet<K, V>
@Override @Override
public Map.Entry<K, V> next() { public Map.Entry<K, V> next() {
return new UnmodifiableEntry(iterator.next()); return new UnmodifiableEntry(getIterator().next());
} }
@Override @Override

View File

@ -380,23 +380,23 @@ public class ListOrderedSet<E>
@Override @Override
public E next() { public E next() {
last = iterator.next(); last = getIterator().next();
return last; return last;
} }
@Override @Override
public void remove() { public void remove() {
set.remove(last); set.remove(last);
iterator.remove(); getIterator().remove();
last = null; last = null;
} }
public boolean hasPrevious() { public boolean hasPrevious() {
return ((ListIterator<E>) iterator).hasPrevious(); return ((ListIterator<E>) getIterator()).hasPrevious();
} }
public E previous() { public E previous() {
last = ((ListIterator<E>) iterator).previous(); last = ((ListIterator<E>) getIterator()).previous();
return last; return last;
} }
} }