Class ImmutableEncodedElement.Builder

  • Direct Known Subclasses:
    EncodedElement.Builder
    Enclosing class:
    ImmutableEncodedElement

    @NotThreadSafe
    public static class ImmutableEncodedElement.Builder
    extends java.lang.Object
    Builds instances of type EncodedElement. Initialize attributes and then invoke the build() method to create an immutable instance.

    Builder is not thread-safe and generally should not be stored in a field or collection, but instead used immediately to create instances.

    • Field Detail

      • INIT_BIT_TYPE_PARAMETERS

        private static final long INIT_BIT_TYPE_PARAMETERS
        See Also:
        Constant Field Values
      • OPT_BIT_STANDARD_NAMING

        private static final long OPT_BIT_STANDARD_NAMING
        See Also:
        Constant Field Values
      • initBits

        private long initBits
      • optBits

        private long optBits
      • name

        @Nullable
        private java.lang.String name
      • type

        @Nullable
        private Type type
      • naming

        @Nullable
        private Naming naming
      • params

        private final com.google.common.collect.ImmutableList.Builder<EncodedElement.Param> params
      • code

        private final com.google.common.collect.ImmutableList.Builder<Code.Term> code
      • thrown

        private final com.google.common.collect.ImmutableList.Builder<Type> thrown
      • tags

        private final com.google.common.collect.ImmutableSet.Builder<EncodedElement.Tag> tags
      • doc

        private final com.google.common.collect.ImmutableList.Builder<java.lang.String> doc
      • annotations

        private final com.google.common.collect.ImmutableList.Builder<java.lang.String> annotations
    • Constructor Detail

      • Builder

        public Builder()
        Creates a builder for EncodedElement instances.
         new EncodedElement.Builder()
            .name(String) // required name
            .type(org.immutables.value.processor.encode.Type) // required type
            .naming(org.immutables.generator.Naming) // required naming
            .addParams|addAllParams(org.immutables.value.processor.encode.EncodedElement.Param) // params elements
            .addCode|addAllCode(org.immutables.value.processor.encode.Code.Term) // code elements
            .addThrown|addAllThrown(org.immutables.value.processor.encode.Type) // thrown elements
            .addTags|addAllTags(org.immutables.value.processor.encode.EncodedElement.Tag) // tags elements
            .typeParameters(org.immutables.value.processor.encode.Type.Parameters) // required typeParameters
            .addTypeParams|addAllTypeParams(org.immutables.value.processor.encode.EncodedElement.TypeParam) // typeParams elements
            .addDoc|addAllDoc(String) // doc elements
            .addAnnotations|addAllAnnotations(String) // annotations elements
            .standardNaming(org.immutables.value.processor.encode.StandardNaming) // optional standardNaming
            .build();
         
    • Method Detail

      • name

        public final EncodedElement.Builder name​(java.lang.String name)
        Initializes the value for the name attribute.
        Parameters:
        name - The value for name
        Returns:
        this builder for use in a chained invocation
      • type

        public final EncodedElement.Builder type​(Type type)
        Initializes the value for the type attribute.
        Parameters:
        type - The value for type
        Returns:
        this builder for use in a chained invocation
      • naming

        public final EncodedElement.Builder naming​(Naming naming)
        Initializes the value for the naming attribute.
        Parameters:
        naming - The value for naming
        Returns:
        this builder for use in a chained invocation
      • addAllParams

        public final EncodedElement.Builder addAllParams​(java.lang.Iterable<? extends EncodedElement.Param> elements)
        Adds elements to params list.
        Parameters:
        elements - An iterable of params elements
        Returns:
        this builder for use in a chained invocation
      • addCode

        public final EncodedElement.Builder addCode​(Code.Term element)
        Adds one element to code list.
        Parameters:
        element - A code element
        Returns:
        this builder for use in a chained invocation
      • addCode

        public final EncodedElement.Builder addCode​(Code.Term... elements)
        Adds elements to code list.
        Parameters:
        elements - An array of code elements
        Returns:
        this builder for use in a chained invocation
      • addAllCode

        public final EncodedElement.Builder addAllCode​(java.lang.Iterable<? extends Code.Term> elements)
        Adds elements to code list.
        Parameters:
        elements - An iterable of code elements
        Returns:
        this builder for use in a chained invocation
      • addThrown

        public final EncodedElement.Builder addThrown​(Type element)
        Adds one element to thrown list.
        Parameters:
        element - A thrown element
        Returns:
        this builder for use in a chained invocation
      • addThrown

        public final EncodedElement.Builder addThrown​(Type... elements)
        Adds elements to thrown list.
        Parameters:
        elements - An array of thrown elements
        Returns:
        this builder for use in a chained invocation
      • addAllThrown

        public final EncodedElement.Builder addAllThrown​(java.lang.Iterable<? extends Type> elements)
        Adds elements to thrown list.
        Parameters:
        elements - An iterable of thrown elements
        Returns:
        this builder for use in a chained invocation
      • addTags

        public final EncodedElement.Builder addTags​(EncodedElement.Tag... elements)
        Adds elements to tags set.
        Parameters:
        elements - An array of tags elements
        Returns:
        this builder for use in a chained invocation
      • addAllTags

        public final EncodedElement.Builder addAllTags​(java.lang.Iterable<EncodedElement.Tag> elements)
        Adds elements to tags set.
        Parameters:
        elements - An iterable of tags elements
        Returns:
        this builder for use in a chained invocation
      • typeParameters

        public final EncodedElement.Builder typeParameters​(Type.Parameters typeParameters)
        Initializes the value for the typeParameters attribute.
        Parameters:
        typeParameters - The value for typeParameters
        Returns:
        this builder for use in a chained invocation
      • addAllTypeParams

        public final EncodedElement.Builder addAllTypeParams​(java.lang.Iterable<? extends EncodedElement.TypeParam> elements)
        Adds elements to typeParams list.
        Parameters:
        elements - An iterable of typeParams elements
        Returns:
        this builder for use in a chained invocation
      • addDoc

        public final EncodedElement.Builder addDoc​(java.lang.String element)
        Adds one element to doc list.
        Parameters:
        element - A doc element
        Returns:
        this builder for use in a chained invocation
      • addDoc

        public final EncodedElement.Builder addDoc​(java.lang.String... elements)
        Adds elements to doc list.
        Parameters:
        elements - An array of doc elements
        Returns:
        this builder for use in a chained invocation
      • addAllDoc

        public final EncodedElement.Builder addAllDoc​(java.lang.Iterable<java.lang.String> elements)
        Adds elements to doc list.
        Parameters:
        elements - An iterable of doc elements
        Returns:
        this builder for use in a chained invocation
      • addAnnotations

        public final EncodedElement.Builder addAnnotations​(java.lang.String element)
        Adds one element to annotations list.
        Parameters:
        element - A annotations element
        Returns:
        this builder for use in a chained invocation
      • addAnnotations

        public final EncodedElement.Builder addAnnotations​(java.lang.String... elements)
        Adds elements to annotations list.
        Parameters:
        elements - An array of annotations elements
        Returns:
        this builder for use in a chained invocation
      • addAllAnnotations

        public final EncodedElement.Builder addAllAnnotations​(java.lang.Iterable<java.lang.String> elements)
        Adds elements to annotations list.
        Parameters:
        elements - An iterable of annotations elements
        Returns:
        this builder for use in a chained invocation
      • standardNaming

        public final EncodedElement.Builder standardNaming​(StandardNaming standardNaming)
        Initializes the value for the standardNaming attribute.

        If not set, this attribute will have a default value as returned by the initializer of standardNaming.

        Parameters:
        standardNaming - The value for standardNaming
        Returns:
        this builder for use in a chained invocation
      • build

        public EncodedElement build()
        Builds a new EncodedElement.
        Returns:
        An immutable instance of EncodedElement
        Throws:
        java.lang.IllegalStateException - if any required attributes are missing
      • standardNamingIsSet

        private boolean standardNamingIsSet()
      • nameIsSet

        private boolean nameIsSet()
      • typeIsSet

        private boolean typeIsSet()
      • namingIsSet

        private boolean namingIsSet()
      • typeParametersIsSet

        private boolean typeParametersIsSet()
      • checkNotIsSet

        private static void checkNotIsSet​(boolean isSet,
                                          java.lang.String name)
      • checkRequiredAttributes

        private void checkRequiredAttributes()
      • formatRequiredAttributesMessage

        private java.lang.String formatRequiredAttributesMessage()