Record Class WikiLinkTarget

java.lang.Object
java.lang.Record
com.lucaskjaerozhang.wikitext_parser.ast.link.WikiLinkTarget
Record Components:
wholeLink - What the user actually typed for the link.
wiki - A wiki for cross wiki linking.
language - A link to the article in a different language.
article - The article that's being linked to
section - A section of the page we're linking to.
All Implemented Interfaces:
WikiTextElement

public record WikiLinkTarget(String wholeLink, Optional<String> wiki, Optional<String> language, String article, Optional<String> section, boolean isCategory) extends Record implements WikiTextElement
Wiki links look like [[wiki:language:article#section|display]], and the first half before the pipe is the target.
  • Constructor Details

    • WikiLinkTarget

      public WikiLinkTarget(String wholeLink, Optional<String> wiki, Optional<String> language, String article, Optional<String> section, boolean isCategory)
      Creates an instance of a WikiLinkTarget record class.
      Parameters:
      wholeLink - the value for the wholeLink record component
      wiki - the value for the wiki record component
      language - the value for the language record component
      article - the value for the article record component
      section - the value for the section record component
      isCategory - the value for the isCategory record component
  • Method Details

    • from

      public static WikiLinkTarget from(String wholeLink, List<WikiLinkNamespaceComponent> namespaceComponents, String article, Optional<String> section)
      Creates a wikilink target
      Parameters:
      wholeLink - The whole text for the link. This is used for un-named links.
      namespaceComponents - The namespace components that locate the article to link.
      article - The article name we're linking to, with no namespace components.
      section - An optional section to link to within the article.
      Returns:
      A WikiLinkTarget node
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • wholeLink

      public String wholeLink()
      Returns the value of the wholeLink record component.
      Returns:
      the value of the wholeLink record component
    • wiki

      public Optional<String> wiki()
      Returns the value of the wiki record component.
      Returns:
      the value of the wiki record component
    • language

      public Optional<String> language()
      Returns the value of the language record component.
      Returns:
      the value of the language record component
    • article

      public String article()
      Returns the value of the article record component.
      Returns:
      the value of the article record component
    • section

      public Optional<String> section()
      Returns the value of the section record component.
      Returns:
      the value of the section record component
    • isCategory

      public boolean isCategory()
      Returns the value of the isCategory record component.
      Returns:
      the value of the isCategory record component