@Test void ofText() throws Exception { final Entry<String> e = Entry.ofText(new Revision(1), "/a.txt", "foo"); assertThat(e.revision()).isEqualTo(new Revision(1)); assertThat(e.hasContent()).isTrue(); e.ifHasContent(content -> assertThat(content).isEqualTo("foo")); assertThat(e.content()).isEqualTo("foo"); assertThat(e.contentAsText()).isEqualTo("foo"); assertThat(e.contentAsPrettyText()).isEqualTo("foo"); assertThatThrownBy(e::contentAsJson).isInstanceOf(JsonParseException.class); assertThatThrownBy(() -> e.contentAsJson(JsonNode.class)).isInstanceOf(JsonParseException.class); assertThat(Entry.ofText(new Revision(1), "/a.txt", "null").contentAsJson()) .isEqualTo(Jackson.nullNode); assertThat(Entry.ofText(new Revision(1), "/a.txt", "null").contentAsJson(JsonNode.class)) .isEqualTo(Jackson.nullNode); final Entry<String> e2 = Entry.ofText(new Revision(1), "/a.txt", "foo"); assertThat(e).isEqualTo(e2); assertThat(e.hashCode()).isEqualTo(e2.hashCode()); assertThat(e).isNotEqualTo(Entry.ofText(new Revision(2), "/a.txt", "foo")); assertThat(e).isNotEqualTo(Entry.ofText(new Revision(1), "/b.txt", "foo")); assertThat(e).isNotEqualTo(Entry.ofText(new Revision(1), "/a.txt", "bar")); final Entry<JsonNode> e3 = Entry.ofJson(new Revision(1), "/a.json", "{ \"foo\": \"bar\" }"); assertThat(e).isNotEqualTo(e3); assertThat(e.hashCode()).isNotEqualTo(e3.hashCode()); final Entry<Void> e4 = Entry.ofDirectory(new Revision(1), "/foo"); assertThat(e).isNotEqualTo(e4); assertThat(e.hashCode()).isNotEqualTo(e4.hashCode()); }
public static Entry<String> ofText(Revision revision, String path, String content) { return new Entry<>(revision, path, EntryType.TEXT, content); }
Entry implements ContentHolder<T> { public static Entry<String> ofText(Revision revision, String path, String content) { return new Entry<>(revision, path, EntryType.TEXT, content); } }
Entry implements ContentHolder<T> { public static Entry<String> ofText(Revision revision, String path, String content) { return new Entry<>(revision, path, EntryType.TEXT, content); } private  Entry(Revision revision, String path, EntryType type, @Nullable T content); }
Entry implements ContentHolder<T> { public static Entry<String> ofText(Revision revision, String path, String content) { return new Entry<>(revision, path, EntryType.TEXT, content); } private  Entry(Revision revision, String path, EntryType type, @Nullable T content); static Entry<Void> ofDirectory(Revision revision, String path); static Entry<JsonNode> ofJson(Revision revision, String path, JsonNode content); static Entry<JsonNode> ofJson(Revision revision, String path, String content); static Entry<String> ofText(Revision revision, String path, String content); static Entry<T> of(Revision revision, String path, EntryType type, @Nullable T content); Revision revision(); String path(); boolean hasContent(); void ifHasContent(Consumer<? super T> consumer); @Override EntryType type(); @Override T content(); @Override String contentAsText(); @Override String contentAsPrettyText(); @Override int hashCode(); @Override boolean equals(Object o); @Override String toString(); }
Entry implements ContentHolder<T> { public static Entry<String> ofText(Revision revision, String path, String content) { return new Entry<>(revision, path, EntryType.TEXT, content); } private  Entry(Revision revision, String path, EntryType type, @Nullable T content); static Entry<Void> ofDirectory(Revision revision, String path); static Entry<JsonNode> ofJson(Revision revision, String path, JsonNode content); static Entry<JsonNode> ofJson(Revision revision, String path, String content); static Entry<String> ofText(Revision revision, String path, String content); static Entry<T> of(Revision revision, String path, EntryType type, @Nullable T content); Revision revision(); String path(); boolean hasContent(); void ifHasContent(Consumer<? super T> consumer); @Override EntryType type(); @Override T content(); @Override String contentAsText(); @Override String contentAsPrettyText(); @Override int hashCode(); @Override boolean equals(Object o); @Override String toString();  }