You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by no...@apache.org on 2012/01/19 14:06:05 UTC
svn commit: r1233343 -
/james/protocols/trunk/api/src/main/java/org/apache/james/protocols/api/handler/ProtocolHandlerChainImpl.java
Author: norman
Date: Thu Jan 19 13:06:05 2012
New Revision: 1233343
URL: http://svn.apache.org/viewvc?rev=1233343&view=rev
Log:
Remove some duplicated code
Modified:
james/protocols/trunk/api/src/main/java/org/apache/james/protocols/api/handler/ProtocolHandlerChainImpl.java
Modified: james/protocols/trunk/api/src/main/java/org/apache/james/protocols/api/handler/ProtocolHandlerChainImpl.java
URL: http://svn.apache.org/viewvc/james/protocols/trunk/api/src/main/java/org/apache/james/protocols/api/handler/ProtocolHandlerChainImpl.java?rev=1233343&r1=1233342&r2=1233343&view=diff
==============================================================================
--- james/protocols/trunk/api/src/main/java/org/apache/james/protocols/api/handler/ProtocolHandlerChainImpl.java (original)
+++ james/protocols/trunk/api/src/main/java/org/apache/james/protocols/api/handler/ProtocolHandlerChainImpl.java Thu Jan 19 13:06:05 2012
@@ -54,10 +54,12 @@ public class ProtocolHandlerChainImpl ex
return readyOnly;
}
+ /*
+ * (non-Javadoc)
+ * @see java.util.List#add(java.lang.Object)
+ */
public boolean add(ProtocolHandler handler) {
- if (readyOnly) {
- throw new UnsupportedOperationException("Ready-only");
- }
+ checkReadOnly();
return handlers.add(handler);
}
@@ -119,9 +121,8 @@ public class ProtocolHandlerChainImpl ex
* @see java.util.List#remove(java.lang.Object)
*/
public boolean remove(Object o) {
- if (readyOnly) {
- throw new UnsupportedOperationException("Ready-only");
- }
+ checkReadOnly();
+
return handlers.remove(o);
}
@@ -138,9 +139,8 @@ public class ProtocolHandlerChainImpl ex
* @see java.util.List#addAll(java.util.Collection)
*/
public boolean addAll(Collection<? extends ProtocolHandler> c) {
- if (readyOnly) {
- throw new UnsupportedOperationException("Ready-only");
- }
+ checkReadOnly();
+
return handlers.addAll(c);
}
@@ -149,9 +149,8 @@ public class ProtocolHandlerChainImpl ex
* @see java.util.List#addAll(int, java.util.Collection)
*/
public boolean addAll(int index, Collection<? extends ProtocolHandler> c) {
- if (readyOnly) {
- throw new UnsupportedOperationException("Ready-only");
- }
+ checkReadOnly();
+
return handlers.addAll(index, c);
}
@@ -160,9 +159,8 @@ public class ProtocolHandlerChainImpl ex
* @see java.util.List#removeAll(java.util.Collection)
*/
public boolean removeAll(Collection<?> c) {
- if (readyOnly) {
- throw new UnsupportedOperationException("Ready-only");
- }
+ checkReadOnly();
+
return handlers.removeAll(c);
}
@@ -179,9 +177,8 @@ public class ProtocolHandlerChainImpl ex
* @see java.util.List#clear()
*/
public void clear() {
- if (readyOnly) {
- throw new UnsupportedOperationException("Ready-only");
- }
+ checkReadOnly();
+
handlers.clear();
}
@@ -198,9 +195,8 @@ public class ProtocolHandlerChainImpl ex
* @see java.util.List#set(int, java.lang.Object)
*/
public ProtocolHandler set(int index, ProtocolHandler element) {
- if (readyOnly) {
- throw new UnsupportedOperationException("Ready-only");
- }
+ checkReadOnly();
+
return (ProtocolHandler) handlers.set(index, element);
}
@@ -209,9 +205,8 @@ public class ProtocolHandlerChainImpl ex
* @see java.util.List#add(int, java.lang.Object)
*/
public void add(int index, ProtocolHandler element) {
- if (readyOnly) {
- throw new UnsupportedOperationException("Ready-only");
- }
+ checkReadOnly();
+
handlers.add(index, element);
}
@@ -220,9 +215,8 @@ public class ProtocolHandlerChainImpl ex
* @see java.util.List#remove(int)
*/
public ProtocolHandler remove(int index) {
- if (readyOnly) {
- throw new UnsupportedOperationException("Ready-only");
- }
+ checkReadOnly();
+
return (ProtocolHandler) handlers.remove(index);
}
@@ -275,6 +269,12 @@ public class ProtocolHandlerChainImpl ex
return sList;
}
+ private void checkReadOnly() {
+ if (readyOnly) {
+ throw new UnsupportedOperationException("Ready-only");
+ }
+ }
+
private final class ProtocolHandlerIterator implements ListIterator<ProtocolHandler> {
private final ListIterator<ProtocolHandler> handlers;
@@ -335,9 +335,8 @@ public class ProtocolHandlerChainImpl ex
* @see java.util.ListIterator#remove()
*/
public void remove() {
- if (readyOnly) {
- throw new UnsupportedOperationException("Ready-only");
- }
+ checkReadOnly();
+
handlers.previousIndex();
}
@@ -346,9 +345,8 @@ public class ProtocolHandlerChainImpl ex
* @see java.util.ListIterator#set(java.lang.Object)
*/
public void set(ProtocolHandler e) {
- if (readyOnly) {
- throw new UnsupportedOperationException("Ready-only");
- }
+ checkReadOnly();
+
handlers.set(e);
}
@@ -357,12 +355,12 @@ public class ProtocolHandlerChainImpl ex
* @see java.util.ListIterator#add(java.lang.Object)
*/
public void add(ProtocolHandler e) {
- if (readyOnly) {
- throw new UnsupportedOperationException("Ready-only");
- }
+ checkReadOnly();
handlers.add(e);
}
}
+
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org