Example usage for com.google.common.collect Iterators forArray

List of usage examples for com.google.common.collect Iterators forArray

Introduction

In this page you can find the example usage for com.google.common.collect Iterators forArray.

Prototype

public static <T> UnmodifiableIterator<T> forArray(final T... array) 

Source Link

Document

Returns an iterator containing the elements of array in order.

Usage

From source file:org.elasticsearch.index.analysis.GermanAnalyzerProvider.java

@Inject
public GermanAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, @Assisted String name,
        @Assisted Settings settings) {/*from  www  .j  ava 2  s  .com*/
    super(index, indexSettings, name);
    String[] stopWords = settings.getAsArray("stopwords");
    if (stopWords.length > 0) {
        this.stopWords = ImmutableSet.copyOf(Iterators.forArray(stopWords));
    } else {
        this.stopWords = GermanAnalyzer.getDefaultStopSet();
    }

    String[] stemExclusion = settings.getAsArray("stem_exclusion");
    if (stemExclusion.length > 0) {
        this.stemExclusion = ImmutableSet.copyOf(Iterators.forArray(stemExclusion));
    } else {
        this.stemExclusion = ImmutableSet.of();
    }
    analyzer = new GermanAnalyzer(Version.LUCENE_CURRENT, this.stopWords, this.stemExclusion);
}

From source file:org.projectbuendia.client.FakeTypedCursor.java

@Override
public Iterator<T> iterator() {
    return Iterators.forArray(mObjects);
}

From source file:org.elasticsearch.index.analysis.BrazilianAnalyzerProvider.java

@Inject
public BrazilianAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, @Assisted String name,
        @Assisted Settings settings) {//from   w w  w. j a  va2s . c o  m
    super(index, indexSettings, name);
    String[] stopWords = settings.getAsArray("stopwords");
    if (stopWords.length > 0) {
        this.stopWords = ImmutableSet.copyOf(Iterators.forArray(stopWords));
    } else {
        this.stopWords = BrazilianAnalyzer.getDefaultStopSet();
    }

    String[] stemExclusion = settings.getAsArray("stem_exclusion");
    if (stemExclusion.length > 0) {
        this.stemExclusion = ImmutableSet.copyOf(Iterators.forArray(stemExclusion));
    } else {
        this.stemExclusion = ImmutableSet.of();
    }
    analyzer = new BrazilianAnalyzer(Version.LUCENE_CURRENT, this.stopWords, this.stemExclusion);
}

From source file:org.elasticsearch.index.analysis.StopTokenFilterFactory.java

@Inject
public StopTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name,
        @Assisted Settings settings) {//from   w  ww.  j a v  a2s  .  c o m
    super(index, indexSettings, name);
    String[] stopWords = settings.getAsArray("stopwords");
    if (stopWords.length > 0) {
        this.stopWords = ImmutableSet.copyOf(Iterators.forArray(stopWords));
    } else {
        this.stopWords = ImmutableSet.copyOf((Iterable<? extends String>) StopAnalyzer.ENGLISH_STOP_WORDS_SET);
    }
    this.enablePositionIncrements = settings.getAsBoolean("enable_position_increments", true);
    this.ignoreCase = settings.getAsBoolean("ignore_case", false);
}

From source file:org.elasticsearch.index.analysis.StandardAnalyzerProvider.java

@Inject
public StandardAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, @Assisted String name,
        @Assisted Settings settings) {/*from  ww  w  . j a va2  s  . com*/
    super(index, indexSettings, name);
    String[] stopWords = settings.getAsArray("stopwords");
    if (stopWords.length > 0) {
        this.stopWords = ImmutableSet.copyOf(Iterators.forArray(stopWords));
    } else {
        this.stopWords = ImmutableSet.copyOf((Iterable<? extends String>) StopAnalyzer.ENGLISH_STOP_WORDS_SET);
    }
    maxTokenLength = settings.getAsInt("max_token_length", StandardAnalyzer.DEFAULT_MAX_TOKEN_LENGTH);
    standardAnalyzer = new StandardAnalyzer(Version.LUCENE_CURRENT, this.stopWords);
    standardAnalyzer.setMaxTokenLength(maxTokenLength);
}

From source file:de.kussm.direction.Direction.java

@Override
public Iterator<Direction> iterator() {
    return Iterators.forArray(this);
}

From source file:co.cask.cdap.internal.app.runtime.messaging.AbstractMessagePublisher.java

@Override
public final void publish(String namespace, String topic, byte[]... payloads)
        throws IOException, TopicNotFoundException {
    publish(namespace, topic, Iterators.forArray(payloads));
}

From source file:co.cask.cdap.messaging.client.StoreRequestBuilder.java

/**
 * Adds a list of byte arrays as the payloads of the request.
 *//*from  www .j a  v a 2  s .co  m*/
public StoreRequestBuilder addPayloads(byte[]... payloads) {
    return addPayloads(Iterators.forArray(payloads));
}

From source file:com.samskivert.depot.MultiKeySet.java

public Iterator<Key<T>> iterator() {
    return Iterators.transform(Iterators.forArray(_keys), new Function<Comparable<?>[], Key<T>>() {
        public Key<T> apply(Comparable<?>[] key) {
            return new Key<T>(_pClass, key);
        }//from  w w w  .j av  a  2s. c o m
    });
}

From source file:org.asoem.greyfish.utils.base.Callbacks.java

/**
 * The created Callback iterates over the given values and returns them. If the last element is reached, its value
 * returned for all consecutive calls.//from ww w.j  av a  2 s. co m
 *
 * @param values the values to iterate over
 * @param <T>    the type of the values
 * @return the given values in order.
 */
public static <T> Callback<Object, T> iterate(final T... values) {
    return new IteratingCallback<T>(Iterators.forArray(values));
}