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.StopAnalyzerProvider.java

@Inject
public StopAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, @Assisted String name,
        @Assisted Settings settings) {/*from  w  ww. java  2s  . 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.stopAnalyzer = new StopAnalyzer(Version.LUCENE_CURRENT, this.stopWords);
}

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

@Inject
public GreekAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, @Assisted String name,
        @Assisted Settings settings) {//from w w w  . j  av a 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 = GreekAnalyzer.getDefaultStopSet();
    }

    analyzer = new GreekAnalyzer(Version.LUCENE_CURRENT, this.stopWords);
}

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

@Inject
public CzechAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, @Assisted String name,
        @Assisted Settings settings) {//  w  w w . j  ava  2s .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 = CzechAnalyzer.getDefaultStopSet();
    }

    analyzer = new CzechAnalyzer(Version.LUCENE_CURRENT, this.stopWords);
}

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

@Inject
public RussianAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, @Assisted String name,
        @Assisted Settings settings) {/*w w  w .j a v  a 2  s.  c o  m*/
    super(index, indexSettings, name);
    String[] stopWords = settings.getAsArray("stopwords");
    if (stopWords.length > 0) {
        analyzer = new RussianAnalyzer(Version.LUCENE_CURRENT,
                ImmutableSet.copyOf(Iterators.forArray(stopWords)));
    } else {
        analyzer = new RussianAnalyzer(Version.LUCENE_CURRENT);
    }
}

From source file:net.sourceforge.cilib.problem.StandardMOFitness.java

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

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

@Inject
public PersianAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, @Assisted String name,
        @Assisted Settings settings) {/*from   w  w w.j a v  a  2 s .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 = PersianAnalyzer.getDefaultStopSet();
    }

    analyzer = new PersianAnalyzer(Version.LUCENE_CURRENT, this.stopWords);
}

From source file:ec.nbdemetra.ui.awt.ActionMaps.java

@Nonnull
private static Set<Object> asKeySet(final @Nonnull ActionMap actionMap, final boolean includeParentKeys) {
    return new AbstractSet<Object>() {
        @Override//from   w w  w.  j  av  a2 s.c  o  m
        public Iterator<Object> iterator() {
            Object[] keys = includeParentKeys ? actionMap.allKeys() : actionMap.keys();
            return keys != null ? Iterators.forArray(keys) : Iterators.<Object>emptyIterator();
        }

        @Override
        public int size() {
            int result = actionMap.size();
            if (includeParentKeys) {
                ActionMap cursor = actionMap;
                while ((cursor = cursor.getParent()) != null) {
                    result += cursor.size();
                }
            }
            return result;
        }
    };
}

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

@Inject
public ArabicAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, @Assisted String name,
        @Assisted Settings settings) {/*from ww w .  jav a2s. com*/
    super(index, indexSettings, name);
    String[] stopWords = settings.getAsArray("stopwords");
    if (stopWords.length > 0) {
        this.stopWords = ImmutableSet.copyOf(Iterators.forArray(stopWords));
    } else {
        this.stopWords = ArabicAnalyzer.getDefaultStopSet();
    }
    arabicAnalyzer = new ArabicAnalyzer(Version.LUCENE_CURRENT, this.stopWords);
}

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

@Inject
public DutchAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, @Assisted String name,
        @Assisted Settings settings) {/*from   ww w . j a v a 2s  .  co  m*/
    super(index, indexSettings, name);
    String[] stopWords = settings.getAsArray("stopwords");
    if (stopWords.length > 0) {
        this.stopWords = ImmutableSet.copyOf(Iterators.forArray(stopWords));
    } else {
        this.stopWords = DutchAnalyzer.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 DutchAnalyzer(Version.LUCENE_CURRENT, this.stopWords, this.stemExclusion);
}

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

@Inject
public FrenchAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, @Assisted String name,
        @Assisted Settings settings) {//from www.  j ava2  s .  c  om
    super(index, indexSettings, name);
    String[] stopWords = settings.getAsArray("stopwords");
    if (stopWords.length > 0) {
        this.stopWords = ImmutableSet.copyOf(Iterators.forArray(stopWords));
    } else {
        this.stopWords = FrenchAnalyzer.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 FrenchAnalyzer(Version.LUCENE_CURRENT, this.stopWords, this.stemExclusion);
}