Java Reference
In-Depth Information
Objects.requireNonNull(line, "line");
if (line.isEmpty()) {
throw new IllegalArgumentException(
"line is empty for " + title + ", line number " + lineNumber);
}
this.line = line;
if (year < 1500 || year > 1699) {
throw new IllegalArgumentException("year is egregiously off: " + year);
}
this.year = year;
}
public String getTitle() {
return title;
}
public int getLineNumber() {
return lineNumber;
}
public String getLine() {
return line;
}
public int getYear() {
return year;
}
public List<String> getWords() {
return Arrays.asList(line.split("\\s+"));
}
}
### TextMapper.java
import java.util.*;
import java.util.function.*;
import java.util.regex.*;
/**
* A mapper that presumes a sequential execution through the anthology of text.
*/
public class TextMapper implements java.util.function.Function<String, Optional<TextLine>> {
private volatile String currentTitle;
private volatile int currentYear;
private volatile int currentOffset = 0;
private volatile boolean inSonnets = false;
Search WWH ::




Custom Search