isEmpty checks for collections added

pull/139/head
Nikita 10 years ago
parent fee63b39bc
commit faf4b9f175

@ -116,7 +116,7 @@ public class RedissonList<V> extends RedissonExpirable implements RList<V> {
@Override
public boolean containsAll(Collection<?> c) {
if (isEmpty()) {
if (isEmpty() || c.isEmpty()) {
return false;
}
@ -144,6 +144,9 @@ public class RedissonList<V> extends RedissonExpirable implements RList<V> {
@Override
public boolean addAll(final Collection<? extends V> c) {
if (c.isEmpty()) {
return false;
}
connectionManager.write(getName(), new ResultOperation<Long, Object>() {
@Override
protected Future<Long> execute(RedisAsyncConnection<Object, Object> async) {
@ -156,6 +159,9 @@ public class RedissonList<V> extends RedissonExpirable implements RList<V> {
@Override
public boolean addAll(final int index, final Collection<? extends V> coll) {
checkPosition(index);
if (coll.isEmpty()) {
return false;
}
if (index < size()) {
return connectionManager.write(getName(), new SyncOperation<Object, Boolean>() {
@Override
@ -191,6 +197,10 @@ public class RedissonList<V> extends RedissonExpirable implements RList<V> {
@Override
public boolean removeAll(final Collection<?> c) {
if (c.isEmpty()) {
return false;
}
return connectionManager.write(getName(), new SyncOperation<Object, Boolean>() {
@Override
public Boolean execute(RedisConnection<Object, Object> conn) {
@ -209,6 +219,10 @@ public class RedissonList<V> extends RedissonExpirable implements RList<V> {
@Override
public boolean retainAll(Collection<?> c) {
if (c.isEmpty()) {
return false;
}
boolean changed = false;
for (Iterator<V> iterator = iterator(); iterator.hasNext();) {
V object = iterator.next();

@ -204,6 +204,10 @@ public class RedissonSet<V> extends RedissonExpirable implements RSet<V> {
@Override
public boolean addAll(final Collection<? extends V> c) {
if (c.isEmpty()) {
return false;
}
Long res = connectionManager.write(getName(), new ResultOperation<Long, Object>() {
@Override
public Future<Long> execute(RedisAsyncConnection<Object, Object> async) {
@ -215,6 +219,10 @@ public class RedissonSet<V> extends RedissonExpirable implements RSet<V> {
@Override
public boolean retainAll(Collection<?> c) {
if (c.isEmpty()) {
return false;
}
boolean changed = false;
for (Object object : this) {
if (!c.contains(object)) {
@ -227,6 +235,10 @@ public class RedissonSet<V> extends RedissonExpirable implements RSet<V> {
@Override
public boolean removeAll(final Collection<?> c) {
if (c.isEmpty()) {
return false;
}
Long res = connectionManager.write(getName(), new ResultOperation<Long, Object>() {
@Override
public Future<Long> execute(RedisAsyncConnection<Object, Object> async) {

Loading…
Cancel
Save