All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.basho.riak.client.cap.DefaultResolver Maven / Gradle / Ivy

There is a newer version: 2.1.1
Show newest version
package com.basho.riak.client.cap;

import java.util.Collection;

/**
 * A conflict resolver that doesn't resolve conflict. If it is presented with a
 * collection of siblings with more than one entry it throws an {@link UnresolvedConflictException}.
 * 
 * @author russell
 * 
 * @see UnresolvedConflictException
 */
public final class DefaultResolver implements ConflictResolver {

    /**
     * Detects conflict but does not resolve it.
     * @return null or the single value in the collection
     * @throws UnresolvedConflictException if siblings as > 1 entry.
     */
    public T resolve(Collection siblings) {
        if (siblings.size() > 1) {
            throw new UnresolvedConflictException("Siblings found", siblings);
        } else if (siblings.size() == 1) {
            return siblings.iterator().next();
        } else {
            return null;
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy