com.optimaize.langdetect.text.TextObjectFactoryBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of language-detector Show documentation
Show all versions of language-detector Show documentation
Language Detection Library for Java.
The newest version!
package com.optimaize.langdetect.text;
import java.util.ArrayList;
import java.util.List;
/**
* Builder for {@link com.optimaize.langdetect.text.TextObjectFactory}.
*
* @author Fabian Kessler
*/
public class TextObjectFactoryBuilder {
private int maxTextLength = 0;
private final List textFilters = new ArrayList<>();
/**
* @param maxTextLength 0 for no limit (that's the default).
*/
public TextObjectFactoryBuilder maxTextLength(int maxTextLength) {
this.maxTextLength = maxTextLength;
return this;
}
/**
* Adds the given TextFilter to be run on {@link TextObject#append} methods.
*
* Note that the order of filters. may be important. They are executed in the same order as they
* are passed in here.
*/
public TextObjectFactoryBuilder withTextFilter(TextFilter textFilter) {
textFilters.add(textFilter);
return this;
}
public TextObjectFactory build() {
return new TextObjectFactory(
new MultiTextFilter(textFilters),
maxTextLength
);
}
}