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
    • ofYaml

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

      public static Entry<JsonNode> ofYaml(Revision revision, String path, String content) throws JsonProcessingException
      Returns a newly-created Entry of a YAML file.
      Parameters:
      revision - the revision of the YAML file
      path - the path of the YAML file
      content - the content of the YAML file
      Throws:
      JsonProcessingException - if the content is not a valid YAML
    • 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
      type - the type of the Entry
      content - the content of the Entry
    • of

      public static <T> Entry<T> of(Revision revision, String path, EntryType type, @Nullable T content, @Nullable Revision templateRevision)
      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
      type - the type of the Entry
      content - the content of the Entry
      templateRevision - the revision of the variables that were used to render the template and generate this Entry
    • revision

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

      public @Nullable Revision templateRevision()
      Returns the revision of the template variables that were used to render the template and generate this Entry.

      null if this Entry was not generated from a template using project or repository level variables.

    • withTemplateRevision

      public Entry<T> withTemplateRevision(Revision templateRevision)
      Sets the revision of the template variables that were used to render the template and generate this Entry.

      This value is set only when the Entry was generated from a template using project or repository level variables.

    • 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>
    • rawContent

      public @Nullable String rawContent()
      Returns the raw content if available.
    • 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>
    • contentAsJson

      public JsonNode contentAsJson() throws JsonParseException
      Description copied from interface: ContentHolder
      Returns the JSON representation of the specified content.
      Specified by:
      contentAsJson in interface ContentHolder<T>
      Returns:
      the JsonNode parsed from the content
      Throws:
      JsonParseException - if failed to parse the content as JSON
    • 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