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

edu.isi.nlp.files.AbstractKeyValueSource Maven / Gradle / Ivy

The newest version!
package edu.isi.nlp.files;

import com.google.common.base.Optional;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableSet;
import java.io.IOException;
import javax.annotation.Nonnull;

/**
 * Provides an implementation of {@link KeyValueSource#getRequired(Object)} for convenience.
 *
 * 

See {@link KeyValueSource} for general documentation of the key-value classes. * * @author Constantine Lignos, Ryan Gabbard */ public abstract class AbstractKeyValueSource implements KeyValueSource { @Override @Nonnull public V getRequired(final K key) throws IOException { final Optional value = get(key); if (value.isPresent()) { return value.get(); } else { throw new NoSuchKeyException("No such key: " + key.toString()); } } @Override @Nonnull public ImmutableSet keySet() throws IOException { return FluentIterable.from(keys()).toSet(); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy