com.davfx.string.BeforeStringInput Maven / Gradle / Ivy
The newest version!
package com.davfx.string;
final class BeforeStringInput implements StringInput {
private final StringInput separator;
private final StringInput wrappee;
public BeforeStringInput(StringInput separator, StringInput wrappee) {
this.separator = separator;
this.wrappee = wrappee;
}
@Override
public String get(T h) {
String s = wrappee.get(h);
if (s == null) {
return null;
}
String sep = separator.get(h);
if (sep == null) {
return null;
}
int k = s.indexOf(sep);
if (k < 0) {
return null;
}
return s.substring(0, k);
}
}