small code improvements

This commit is contained in:
Benjamin Diedrichsen 2014-06-26 08:59:52 +02:00
parent 7c0c0b6f82
commit ed901a8501
6 changed files with 177 additions and 179 deletions

View File

@ -28,18 +28,16 @@ public abstract class AbstractConcurrentSet<T> implements IConcurrentSet<T> {
protected abstract Entry<T> createEntry(T value, Entry<T> next);
@Override
public IConcurrentSet<T> add(T element) {
if (element == null) return this;
public void add(T element) {
if (element == null) return;
Lock writeLock = lock.writeLock();
writeLock.lock();
if (element == null || entries.containsKey(element)) {
writeLock.unlock();
return this;
} else {
insert(element);
writeLock.unlock();
}
return this;
}
@Override
@ -69,7 +67,7 @@ public abstract class AbstractConcurrentSet<T> implements IConcurrentSet<T> {
}
@Override
public IConcurrentSet<T> addAll(Iterable<T> elements) {
public void addAll(Iterable<T> elements) {
Lock writeLock = lock.writeLock();
try {
writeLock.lock();
@ -81,7 +79,6 @@ public abstract class AbstractConcurrentSet<T> implements IConcurrentSet<T> {
} finally {
writeLock.unlock();
}
return this;
}
@Override

View File

@ -8,13 +8,13 @@ package net.engio.mbassy.common;
*/
public interface IConcurrentSet<T> extends Iterable<T> {
IConcurrentSet<T> add(T element);
void add(T element);
boolean contains(T element);
int size();
IConcurrentSet<T> addAll(Iterable<T> elements);
void addAll(Iterable<T> elements);
boolean remove(T element);
}

View File

@ -56,7 +56,7 @@ public class MessageHandler {
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(HandlerMethod, handler);
// add EL filter if a condition is present
if(handlerConfig.condition() != null){
if(handlerConfig.condition().length() > 0){
if (!ElFilter.isELAvailable()) {
throw new IllegalStateException("A handler uses an EL filter but no EL implementation is available.");
}

View File

@ -22,7 +22,8 @@ import org.junit.runners.Suite;
DeadMessageTest.class,
SynchronizedHandlerTest.class,
SubscriptionManagerTest.class,
AsyncFIFOBusTest.class
AsyncFIFOBusTest.class,
ConditionalHandlers.class
})
public class AllTests {
}

View File

@ -17,7 +17,7 @@ import java.util.Set;
* Some unit tests for the "condition" filter.
****************************************************************************/
public class ConditionTest extends MessageBusTest {
public class ConditionalHandlers extends MessageBusTest {
public static class TestEvent {

View File

@ -30,7 +30,7 @@ public class ListenerFactory {
return this;
}
public ListenerFactory create(int numberOfInstances, Class[] classes){
public ListenerFactory create(int numberOfInstances, Class ...classes){
for(Class clazz : classes)
create(numberOfInstances,clazz);
return this;