Skip to content

Commit

Permalink
Require Java 8. Replace Guava FluentIterables with streams.
Browse files Browse the repository at this point in the history
  • Loading branch information
jlinn committed Jul 8, 2020
1 parent 40a0cfe commit cd537a2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 20 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch-analysis-url</artifactId>
<version>2.3.4.4</version>
<version>2.3.4.5</version>
<packaging>jar</packaging>
<description>Elasticsearch URL token filter plugin</description>

Expand Down Expand Up @@ -132,8 +132,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.elasticsearch.index.analysis;

import com.google.common.base.Function;
import com.google.common.collect.FluentIterable;
import org.apache.lucene.analysis.TokenStream;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.inject.assistedinject.Assisted;
Expand All @@ -10,7 +8,9 @@
import org.elasticsearch.index.analysis.url.URLTokenFilter;
import org.elasticsearch.index.settings.IndexSettingsService;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
* Joe Linn
Expand All @@ -31,13 +31,9 @@ public class URLTokenFilterFactory extends AbstractTokenFilterFactory {
public URLTokenFilterFactory(Index index, IndexSettingsService indexSettings, @Assisted String name, @Assisted Settings settings) {
super(index, indexSettings.indexSettings(), name, settings);

this.parts = FluentIterable.of(settings.getAsArray("part", new String[]{"whole"}))
.transform(new Function<String, URLPart>() {
@Override
public URLPart apply(String input) {
return URLPart.fromString(input);
}
}).toList();
this.parts = Arrays.stream(settings.getAsArray("part", new String[]{"whole"}))
.map(URLPart::fromString)
.collect(Collectors.toList());

this.urlDecode = settings.getAsBoolean("url_decode", false);
this.tokenizeHost = settings.getAsBoolean("tokenize_host", true);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.elasticsearch.index.analysis;

import com.google.common.base.Function;
import com.google.common.collect.FluentIterable;
import org.apache.lucene.analysis.Tokenizer;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.inject.assistedinject.Assisted;
Expand All @@ -10,7 +8,9 @@
import org.elasticsearch.index.analysis.url.URLTokenizer;
import org.elasticsearch.index.settings.IndexSettingsService;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
* Joe Linn
Expand All @@ -33,12 +33,9 @@ public URLTokenizerFactory(Index index, IndexSettingsService indexSettings, @Ass

String[] parts = settings.getAsArray("part");
if (parts != null && parts.length > 0) {
this.parts = FluentIterable.of(parts).transform(new Function<String, URLPart>() {
@Override
public URLPart apply(String input) {
return URLPart.fromString(input);
}
}).toList();
this.parts = Arrays.stream(parts)
.map(URLPart::fromString)
.collect(Collectors.toList());
}
this.urlDecode = settings.getAsBoolean("url_decode", false);
this.tokenizeHost = settings.getAsBoolean("tokenize_host", true);
Expand Down

0 comments on commit cd537a2

Please sign in to comment.