You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2009/09/11 19:50:42 UTC
svn commit: r813954 -
/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/StaticBucketMap.java
Author: sebb
Date: Fri Sep 11 17:50:42 2009
New Revision: 813954
URL: http://svn.apache.org/viewvc?rev=813954&view=rev
Log:
Make private immutable variables final
Add missing @Override markers and fix some raw types
Modified:
commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/StaticBucketMap.java
Modified: commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/StaticBucketMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/StaticBucketMap.java?rev=813954&r1=813953&r2=813954&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/StaticBucketMap.java (original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/StaticBucketMap.java Fri Sep 11 17:50:42 2009
@@ -106,9 +106,9 @@
/** The default number of buckets to use */
private static final int DEFAULT_BUCKETS = 255;
/** The array of buckets, where the actual data is held */
- private Node<K, V>[] buckets;
+ private final Node<K, V>[] buckets;
/** The matching array of locks */
- private Lock[] locks;
+ private final Lock[] locks;
/**
* Initializes the map with the default number of buckets (255).
@@ -410,11 +410,12 @@
* @param obj the object to compare to
* @return true if equal
*/
+ @Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
- if (obj instanceof Map == false) {
+ if (obj instanceof Map<?, ?> == false) {
return false;
}
Map<?, ?> other = (Map<?, ?>) obj;
@@ -426,6 +427,7 @@
*
* @return the hash code
*/
+ @Override
public int hashCode() {
int hashCode = 0;
@@ -459,16 +461,18 @@
return value;
}
+ @Override
public int hashCode() {
return ((key == null ? 0 : key.hashCode()) ^
(value == null ? 0 : value.hashCode()));
}
+ @Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
- if (obj instanceof Map.Entry == false) {
+ if (obj instanceof Map.Entry<?, ?> == false) {
return false;
}
@@ -553,18 +557,22 @@
private class EntrySet extends AbstractSet<Map.Entry<K, V>> {
+ @Override
public int size() {
return StaticBucketMap.this.size();
}
+ @Override
public void clear() {
StaticBucketMap.this.clear();
}
+ @Override
public Iterator<Map.Entry<K, V>> iterator() {
return new EntryIterator();
}
+ @Override
public boolean contains(Object obj) {
Map.Entry<?, ?> entry = (Map.Entry<?, ?>) obj;
int hash = getHash(entry.getKey());
@@ -576,8 +584,9 @@
return false;
}
+ @Override
public boolean remove(Object obj) {
- if (obj instanceof Map.Entry == false) {
+ if (obj instanceof Map.Entry<?, ?> == false) {
return false;
}
Map.Entry<?, ?> entry = (Map.Entry<?, ?>) obj;
@@ -597,22 +606,27 @@
private class KeySet extends AbstractSet<K> {
+ @Override
public int size() {
return StaticBucketMap.this.size();
}
+ @Override
public void clear() {
StaticBucketMap.this.clear();
}
+ @Override
public Iterator<K> iterator() {
return new KeyIterator();
}
+ @Override
public boolean contains(Object obj) {
return StaticBucketMap.this.containsKey(obj);
}
+ @Override
public boolean remove(Object obj) {
int hash = getHash(obj);
synchronized (locks[hash]) {
@@ -632,14 +646,17 @@
private class Values extends AbstractCollection<V> {
+ @Override
public int size() {
return StaticBucketMap.this.size();
}
+ @Override
public void clear() {
StaticBucketMap.this.clear();
}
+ @Override
public Iterator<V> iterator() {
return new ValueIterator();
}
Re: svn commit: r813954 - /commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/StaticBucketMap.java
Posted by Matt Benson <gu...@yahoo.com>.
Thanks, Seb! ;)
--- On Fri, 9/11/09, sebb@apache.org <se...@apache.org> wrote:
> From: sebb@apache.org <se...@apache.org>
> Subject: svn commit: r813954 - /commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/StaticBucketMap.java
> To: commits@commons.apache.org
> Date: Friday, September 11, 2009, 12:50 PM
> Author: sebb
> Date: Fri Sep 11 17:50:42 2009
> New Revision: 813954
>
> URL: http://svn.apache.org/viewvc?rev=813954&view=rev
> Log:
> Make private immutable variables final
> Add missing @Override markers and fix some raw types
>
> Modified:
>
> commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/StaticBucketMap.java
>
> Modified:
> commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/StaticBucketMap.java
> URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/StaticBucketMap.java?rev=813954&r1=813953&r2=813954&view=diff
> ==============================================================================
> ---
> commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/StaticBucketMap.java
> (original)
> +++
> commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/map/StaticBucketMap.java
> Fri Sep 11 17:50:42 2009
> @@ -106,9 +106,9 @@
> /** The default number of buckets
> to use */
> private static final int
> DEFAULT_BUCKETS = 255;
> /** The array of buckets, where
> the actual data is held */
> - private Node<K, V>[] buckets;
> + private final Node<K, V>[] buckets;
> /** The matching array of locks
> */
> - private Lock[] locks;
> + private final Lock[] locks;
>
> /**
> * Initializes the map with the default
> number of buckets (255).
> @@ -410,11 +410,12 @@
> * @param obj the object to
> compare to
> * @return true if equal
> */
> + @Override
> public boolean equals(Object obj)
> {
> if (obj == this) {
> return
> true;
> }
> - if (obj instanceof Map ==
> false) {
> + if (obj instanceof Map<?,
> ?> == false) {
> return
> false;
> }
> Map<?, ?>
> other = (Map<?, ?>) obj;
> @@ -426,6 +427,7 @@
> *
> * @return the hash code
> */
> + @Override
> public int hashCode() {
> int hashCode = 0;
>
> @@ -459,16 +461,18 @@
> return
> value;
> }
>
> + @Override
> public int
> hashCode() {
> return
> ((key == null ? 0 : key.hashCode()) ^
>
> (value == null ? 0 :
> value.hashCode()));
> }
>
> + @Override
> public boolean
> equals(Object obj) {
> if
> (obj == this) {
>
> return true;
> }
> - if (obj
> instanceof Map.Entry == false) {
> + if (obj
> instanceof Map.Entry<?, ?> == false) {
>
> return false;
> }
>
> @@ -553,18 +557,22 @@
>
> private class EntrySet extends
> AbstractSet<Map.Entry<K, V>> {
>
> + @Override
> public int size() {
> return
> StaticBucketMap.this.size();
> }
>
> + @Override
> public void clear()
> {
>
> StaticBucketMap.this.clear();
> }
>
> + @Override
> public
> Iterator<Map.Entry<K, V>> iterator() {
> return
> new EntryIterator();
> }
>
> + @Override
> public boolean
> contains(Object obj) {
>
> Map.Entry<?, ?> entry =
> (Map.Entry<?, ?>) obj;
> int
> hash = getHash(entry.getKey());
> @@ -576,8 +584,9 @@
> return
> false;
> }
>
> + @Override
> public boolean
> remove(Object obj) {
> - if (obj
> instanceof Map.Entry == false) {
> + if (obj
> instanceof Map.Entry<?, ?> == false) {
>
> return false;
> }
>
> Map.Entry<?, ?> entry =
> (Map.Entry<?, ?>) obj;
> @@ -597,22 +606,27 @@
>
> private class KeySet extends
> AbstractSet<K> {
>
> + @Override
> public int size() {
> return
> StaticBucketMap.this.size();
> }
>
> + @Override
> public void clear()
> {
>
> StaticBucketMap.this.clear();
> }
>
> + @Override
> public
> Iterator<K> iterator() {
> return
> new KeyIterator();
> }
>
> + @Override
> public boolean
> contains(Object obj) {
> return
> StaticBucketMap.this.containsKey(obj);
> }
>
> + @Override
> public boolean
> remove(Object obj) {
> int
> hash = getHash(obj);
>
> synchronized (locks[hash]) {
> @@ -632,14 +646,17 @@
>
> private class Values extends
> AbstractCollection<V> {
>
> + @Override
> public int size() {
> return
> StaticBucketMap.this.size();
> }
>
> + @Override
> public void clear()
> {
>
> StaticBucketMap.this.clear();
> }
>
> + @Override
> public
> Iterator<V> iterator() {
> return
> new ValueIterator();
> }
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org