Class ImmutableTrees.Unit

  • All Implemented Interfaces:
    Trees.Unit
    Enclosing class:
    ImmutableTrees

    @Immutable
    public static final class ImmutableTrees.Unit
    extends java.lang.Object
    implements Trees.Unit
    Immutable implementation of Trees.Unit.

    Use the builder to create immutable instances: ImmutableTrees.Unit.builder().

    • Field Detail

      • parts

        private final com.google.common.collect.ImmutableList<Trees.UnitPart> parts
    • Constructor Detail

      • Unit

        private Unit​(com.google.common.collect.ImmutableList<Trees.UnitPart> parts)
    • Method Detail

      • parts

        public com.google.common.collect.ImmutableList<Trees.UnitPart> parts()
        Specified by:
        parts in interface Trees.Unit
        Returns:
        The value of the parts attribute
      • withParts

        public final ImmutableTrees.Unit withParts​(Trees.UnitPart... elements)
        Copy the current immutable object with elements that replace the content of parts.
        Parameters:
        elements - The elements to set
        Returns:
        A modified copy of this object
      • withParts

        public final ImmutableTrees.Unit withParts​(java.lang.Iterable<? extends Trees.UnitPart> elements)
        Copy the current immutable object with elements that replace the content of parts. A shallow reference equality check is used to prevent copying of the same value by returning this.
        Parameters:
        elements - An iterable of parts elements to set
        Returns:
        A modified copy of this object
      • equals

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

        public int hashCode()
        Computes a hash code from attributes: parts.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        hashCode value
      • toString

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

        public static ImmutableTrees.Unit copyOf​(Trees.Unit instance)
        Creates an immutable copy of a Trees.Unit 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 Unit instance
      • builder

        public static ImmutableTrees.Unit.Builder builder()
        Creates a builder for Unit.
         ImmutableTrees.Unit.builder()
            .addParts|addAllParts(org.immutables.generator.processor.Trees.UnitPart) // parts elements
            .build();
         
        Returns:
        A new Unit builder