Class Entry<T>

java.lang.Object
com.linecorp.centraldogma.common.Entry<T>
Type Parameters:
T - the content type. JsonNode if JSON. String if text.
All Implemented Interfaces:
ContentHolder<T>

public final class Entry<T> extends Object implements ContentHolder<T>
A file or a directory in a repository.
  • Method Details

    • ofDirectory

      public static Entry<Void> ofDirectory(Revision revision, String path)
      Returns a newly-created Entry of a directory.
      Parameters:
      revision - the revision of the directory
      path - the path of the directory
    • ofJson

      public static Entry<JsonNode> ofJson(Revision revision, String path, JsonNode content)
      Returns a newly-created Entry of a JSON file.
      Parameters:
      revision - the revision of the JSON file
      path - the path of the JSON file
      content - the content of the JSON file
    • ofJson

      public static Entry<JsonNode> ofJson(Revision revision, String path, String content) throws JsonParseException
      Returns a newly-created Entry of a JSON file.
      Parameters:
      revision - the revision of the JSON file
      path - the path of the JSON file
      content - the content of the JSON file
      Throws:
      JsonParseException - if the content is not a valid JSON
    • ofText

      public static Entry<String> ofText(Revision revision, String path, String content)
      Returns a newly-created Entry of a text file.
      Parameters:
      revision - the revision of the text file
      path - the path of the text file
      content - the content of the text file
    • of

      public static <T> Entry<T> of(Revision revision, String path, EntryType type, @Nullable T content)
      Returns a newly-created Entry.
      Type Parameters:
      T - the content type. JsonNode if JSON. String if text.
      Parameters:
      revision - the revision of the Entry
      path - the path of the Entry
      content - the content of the Entry
      type - the type of the Entry
    • revision

      public Revision revision()
      Returns the revision of this Entry.
    • path

      public String path()
      Returns the path of this Entry.
    • hasContent

      public boolean hasContent()
      Returns if this Entry has content, which is always true if it's not a directory.
    • ifHasContent

      public void ifHasContent(Consumer<? super T> consumer)
      If this Entry has content, invoke the specified Consumer with the content.
    • type

      public EntryType type()
      Description copied from interface: ContentHolder
      Returns the EntryType of the content.
      Specified by:
      type in interface ContentHolder<T>
    • content

      public T content()
      Description copied from interface: ContentHolder
      Returns the content.
      Specified by:
      content in interface ContentHolder<T>
    • contentAsText

      public String contentAsText()
      Description copied from interface: ContentHolder
      Returns the textual representation of the specified content.
      Specified by:
      contentAsText in interface ContentHolder<T>
    • contentAsPrettyText

      public String contentAsPrettyText()
      Description copied from interface: ContentHolder
      Returns the prettified textual representation of the specified content. Only a TreeNode is prettified currently.
      Specified by:
      contentAsPrettyText in interface ContentHolder<T>
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object