import com.google.common.base.Optional;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
-import com.google.common.collect.Collections2;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.ImmutableSet;
@Override
public Collection<Sone> getLocalSones() {
synchronized (sones) {
- return Collections2.filter(sones.values(), new Predicate<Sone>() {
+ return FluentIterable.from(sones.values()).filter(new Predicate<Sone>() {
@Override
public boolean apply(Sone sone) {
return sone.isLocal();
}
- });
+ }).toSet();
}
}
@Override
public Collection<Sone> getRemoteSones() {
synchronized (sones) {
- return Collections2.filter(sones.values(), new Predicate<Sone>() {
+ return FluentIterable.from(sones.values()).filter(new Predicate<Sone>() {
@Override
public boolean apply(Sone sone) {
return !sone.isLocal();
}
- });
+ }).toSet();
}
}
return null;
}
synchronized (sones) {
- final Sone sone = getRemoteSone(identity.getId(), true).setIdentity(identity);
+ final Sone sone = getRemoteSone(identity.getId(), true);
+ if (sone.isLocal()) {
+ return sone;
+ }
+ sone.setIdentity(identity);
boolean newSone = sone.getRequestUri() == null;
sone.setRequestUri(SoneUri.create(identity.getRequestUri()));
sone.setLatestEdition(Numbers.safeParseLong(identity.getProperty("Sone.LatestEdition"), (long) 0));