Class ImmutableLink

  • All Implemented Interfaces:
    Link

    @ParametersAreNonnullByDefault
    @Generated("org.immutables.processor.ProxyProcessor")
    @Immutable
    @CheckReturnValue
    public final class ImmutableLink
    extends Object
    implements Link
    Immutable implementation of Link.

    Use the builder to create immutable instances: ImmutableLink.builder().

    • Method Detail

      • url

        public URI url()
        Link value.
        Specified by:
        url in interface Link
        Returns:
        url
      • rel

        public Optional<String> rel()
        The relation type of a link is conveyed in the "rel" parameter's value. The "rel" parameter MUST NOT appear more than once in a given link-value; occurrences after the first MUST be ignored by parsers.
        Specified by:
        rel in interface Link
        Returns:
        relation type
      • rev

        public Optional<String> rev()
        The "rev" parameter has been used in the past to indicate that the semantics of the relationship are in the reverse direction. That is, a link from A to B with REL="X" expresses the same relationship as a link from B to A with REV="X". "rev" is deprecated by this specification because it often confuses authors and readers; in most cases, using a separate relation type is preferable.
        Specified by:
        rev in interface Link
        Returns:
        relation type
      • type

        public Optional<String> type()
        The "type" parameter, when present, is a hint indicating what the media type of the result of dereferencing the link should be. Note that this is only a hint; for example, it does not override the Content-Type header of a HTTP response obtained by actually following the link. There MUST NOT be more than one type parameter in a link- value.
        Specified by:
        type in interface Link
        Returns:
        type
      • media

        public Optional<String> media()
        The "media" parameter, when present, is used to indicate intended destination medium or media for style information (see [W3C.REC-html401-19991224], Section 6.13). Note that this may be updated by [W3C.CR-css3-mediaqueries-20090915]). Its value MUST be quoted if it contains a semicolon (";") or comma (","), and there MUST NOT be more than one "media" parameter in a link-value.
        Specified by:
        media in interface Link
        Returns:
        media
      • title

        public Optional<String> title()
        The "title" parameter, when present, is used to label the destination of a link such that it can be used as a human-readable identifier (e.g., a menu entry) in the language indicated by the Content- Language header (if present). The "title" parameter MUST NOT appear more than once in a given link-value; occurrences after the first MUST be ignored by parsers.
        Specified by:
        title in interface Link
        Returns:
        title
      • anchor

        public Optional<String> anchor()
        When present, the anchor parameter overrides this with another URI, such as a fragment of this resource, or a third resource (i.e., when the anchor value is an absolute URI).
        Specified by:
        anchor in interface Link
        Returns:
        anchor
      • withUrl

        public final ImmutableLink withUrl​(URI value)
        Copy the current immutable object by setting a value for the url attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
        Parameters:
        value - A new value for url
        Returns:
        A modified copy of the this object
      • withRel

        public final ImmutableLink withRel​(String value)
        Copy the current immutable object by setting a present value for the optional rel attribute.
        Parameters:
        value - The value for rel
        Returns:
        A modified copy of this object
      • withRel

        public final ImmutableLink withRel​(Optional<String> optional)
        Copy the current immutable object by setting an optional value for the rel attribute. An equality check is used on inner nullable value to prevent copying of the same value by returning this.
        Parameters:
        optional - A value for rel
        Returns:
        A modified copy of this object
      • withRev

        public final ImmutableLink withRev​(String value)
        Copy the current immutable object by setting a present value for the optional rev attribute.
        Parameters:
        value - The value for rev
        Returns:
        A modified copy of this object
      • withRev

        public final ImmutableLink withRev​(Optional<String> optional)
        Copy the current immutable object by setting an optional value for the rev attribute. An equality check is used on inner nullable value to prevent copying of the same value by returning this.
        Parameters:
        optional - A value for rev
        Returns:
        A modified copy of this object
      • withType

        public final ImmutableLink withType​(String value)
        Copy the current immutable object by setting a present value for the optional type attribute.
        Parameters:
        value - The value for type
        Returns:
        A modified copy of this object
      • withType

        public final ImmutableLink withType​(Optional<String> optional)
        Copy the current immutable object by setting an optional value for the type attribute. An equality check is used on inner nullable value to prevent copying of the same value by returning this.
        Parameters:
        optional - A value for type
        Returns:
        A modified copy of this object
      • withMedia

        public final ImmutableLink withMedia​(String value)
        Copy the current immutable object by setting a present value for the optional media attribute.
        Parameters:
        value - The value for media
        Returns:
        A modified copy of this object
      • withMedia

        public final ImmutableLink withMedia​(Optional<String> optional)
        Copy the current immutable object by setting an optional value for the media attribute. An equality check is used on inner nullable value to prevent copying of the same value by returning this.
        Parameters:
        optional - A value for media
        Returns:
        A modified copy of this object
      • withTitle

        public final ImmutableLink withTitle​(String value)
        Copy the current immutable object by setting a present value for the optional title attribute.
        Parameters:
        value - The value for title
        Returns:
        A modified copy of this object
      • withTitle

        public final ImmutableLink withTitle​(Optional<String> optional)
        Copy the current immutable object by setting an optional value for the title attribute. An equality check is used on inner nullable value to prevent copying of the same value by returning this.
        Parameters:
        optional - A value for title
        Returns:
        A modified copy of this object
      • withAnchor

        public final ImmutableLink withAnchor​(String value)
        Copy the current immutable object by setting a present value for the optional anchor attribute.
        Parameters:
        value - The value for anchor
        Returns:
        A modified copy of this object
      • withAnchor

        public final ImmutableLink withAnchor​(Optional<String> optional)
        Copy the current immutable object by setting an optional value for the anchor attribute. An equality check is used on inner nullable value to prevent copying of the same value by returning this.
        Parameters:
        optional - A value for anchor
        Returns:
        A modified copy of this object
      • equals

        public boolean equals​(@Nullable
                              Object another)
        This instance is equal to all instances of ImmutableLink that have equal attribute values.
        Overrides:
        equals in class Object
        Returns:
        true if this is equal to another instance
      • hashCode

        public int hashCode()
        Computes a hash code from attributes: url, rel, rev, type, media, title, anchor.
        Overrides:
        hashCode in class Object
        Returns:
        hashCode value
      • toString

        public String toString()
        Prints the immutable value Link with attribute values.
        Overrides:
        toString in class Object
        Returns:
        A string representation of the value
      • copyOf

        public static ImmutableLink copyOf​(Link instance)
        Creates an immutable copy of a Link value. Uses accessors to get values to initialize the new immutable instance. If an instance is already immutable, it is returned as is.
        Parameters:
        instance - The instance to copy
        Returns:
        A copied immutable Link instance
      • builder

        public static ImmutableLink.Builder builder()
        Creates a builder for ImmutableLink.
         ImmutableLink.builder()
            .url(java.net.URI) // required url
            .rel(String) // optional rel
            .rev(String) // optional rev
            .type(String) // optional type
            .media(String) // optional media
            .title(String) // optional title
            .anchor(String) // optional anchor
            .build();
         
        Returns:
        A new ImmutableLink builder