@Test public void endsWith() { npe(() -> new StringOption().endsWith("a")); npe(() -> new StringOption().endsWith(new StringOption("a"))); npe(() -> new StringOption("a").endsWith(new StringOption())); BiPredicate<String, String> tester = (string, prefix) -> { StringOption opt = new StringOption(string); boolean b0 = opt.endsWith(prefix); boolean b1 = opt.endsWith(new StringOption(prefix)); assertThat(b0, is(b1)); return b0; }; assertThat(tester.test("Hello", "Hello"), is(true)); assertThat(tester.test("Hello", ""), is(true)); assertThat(tester.test("Hello, world!", "a"), is(false)); assertThat(tester.test("Hello, world!", "Hello"), is(false)); assertThat(tester.test("Hello, world!", "world!"), is(true)); assertThat(tester.test("Hello", "Hello, world!"), is(false)); assertThat(tester.test("Hello, world!", "Hello!"), is(false)); assertThat(tester.test("Hello, world!", "world?"), is(false)); assertThat(tester.test("Hello, world!", "Hello, world?"), is(false)); }
public boolean endsWith(String suffix) { if (isNull() || suffix == null) { throw new NullPointerException(); } if (suffix.isEmpty()) { return true; } Text buffer = BUFFER_POOL.get(); buffer.set(suffix); return endsWith(entity, buffer); }
StringOption extends ValueOption<StringOption> { public boolean endsWith(String suffix) { if (isNull() || suffix == null) { throw new NullPointerException(); } if (suffix.isEmpty()) { return true; } Text buffer = BUFFER_POOL.get(); buffer.set(suffix); return endsWith(entity, buffer); } }
StringOption extends ValueOption<StringOption> { public boolean endsWith(String suffix) { if (isNull() || suffix == null) { throw new NullPointerException(); } if (suffix.isEmpty()) { return true; } Text buffer = BUFFER_POOL.get(); buffer.set(suffix); return endsWith(entity, buffer); } StringOption();  StringOption(String textOrNull); }
StringOption extends ValueOption<StringOption> { public boolean endsWith(String suffix) { if (isNull() || suffix == null) { throw new NullPointerException(); } if (suffix.isEmpty()) { return true; } Text buffer = BUFFER_POOL.get(); buffer.set(suffix); return endsWith(entity, buffer); } StringOption();  StringOption(String textOrNull); Text get(); String getAsString(); StringBuilder appendTo(StringBuilder buffer); boolean isEmpty(); Text or(Text alternate); String or(String alternate); void reset(); @Deprecated StringOption modify(Text newText); @Deprecated StringOption modify(String newText); @Deprecated StringOption modify(byte[] utf8, int offset, int length); @Override @Deprecated void copyFrom(StringOption optionOrNull); @Override int hashCode(); @Override boolean equals(Object obj); boolean has(String other); boolean has(Text other); boolean contains(String sub); boolean contains(StringOption sub); boolean startsWith(String prefix); boolean startsWith(StringOption prefix); boolean endsWith(String suffix); boolean endsWith(StringOption suffix); @Override int compareTo(WritableRawComparable o); @Override String toString(); @Override void write(DataOutput out); @SuppressWarnings("deprecation") @Override void readFields(DataInput in); @SuppressWarnings("deprecation") @Override int restore(byte[] bytes, int offset, int limit); @Override int getSizeInBytes(byte[] buf, int offset); @Override int compareInBytes(byte[] b1, int o1, byte[] b2, int o2); static int getBytesLength(byte[] bytes, int offset, int length); static int compareBytes(
            byte[] b1, int s1, int l1,
            byte[] b2, int s2, int l2); }
StringOption extends ValueOption<StringOption> { public boolean endsWith(String suffix) { if (isNull() || suffix == null) { throw new NullPointerException(); } if (suffix.isEmpty()) { return true; } Text buffer = BUFFER_POOL.get(); buffer.set(suffix); return endsWith(entity, buffer); } StringOption();  StringOption(String textOrNull); Text get(); String getAsString(); StringBuilder appendTo(StringBuilder buffer); boolean isEmpty(); Text or(Text alternate); String or(String alternate); void reset(); @Deprecated StringOption modify(Text newText); @Deprecated StringOption modify(String newText); @Deprecated StringOption modify(byte[] utf8, int offset, int length); @Override @Deprecated void copyFrom(StringOption optionOrNull); @Override int hashCode(); @Override boolean equals(Object obj); boolean has(String other); boolean has(Text other); boolean contains(String sub); boolean contains(StringOption sub); boolean startsWith(String prefix); boolean startsWith(StringOption prefix); boolean endsWith(String suffix); boolean endsWith(StringOption suffix); @Override int compareTo(WritableRawComparable o); @Override String toString(); @Override void write(DataOutput out); @SuppressWarnings("deprecation") @Override void readFields(DataInput in); @SuppressWarnings("deprecation") @Override int restore(byte[] bytes, int offset, int limit); @Override int getSizeInBytes(byte[] buf, int offset); @Override int compareInBytes(byte[] b1, int o1, byte[] b2, int o2); static int getBytesLength(byte[] bytes, int offset, int length); static int compareBytes(
            byte[] b1, int s1, int l1,
            byte[] b2, int s2, int l2);  }