Class PropertyBuilderClassifier.PropertyBuilder

  • Enclosing class:
    PropertyBuilderClassifier

    public static class PropertyBuilderClassifier.PropertyBuilder
    extends java.lang.Object
    Information about a property builder, referenced from the autovalue.vm template. A property called bar (defined by a method bar() or getBar()) can have a property builder called barBuilder(). For example, if bar() returns ImmutableSet<String> then barBuilder() might return ImmutableSet.Builder<String>.
    • Constructor Summary

      Constructors 
      Constructor Description
      PropertyBuilder​(javax.lang.model.element.ExecutableElement propertyBuilderMethod, java.lang.String builderType, javax.lang.model.type.TypeMirror builderTypeMirror, java.lang.String initializer, java.lang.String beforeInitDefault, java.lang.String initDefault, java.lang.String builtToBuilder, java.lang.String copyAll)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getAccess()  
      java.lang.String getBeforeInitDefault()
      An empty string, or a complete statement to be included before the expression returned by getInitDefault().
      java.lang.String getBuilderType()
      The type of the builder, for example ImmutableSet.Builder<String>.
      (package private) javax.lang.model.type.TypeMirror getBuilderTypeMirror()  
      java.lang.String getBuiltToBuilder()
      A method to convert the built type back into a builder.
      java.lang.String getCopyAll()
      The method to copy another collection into this builder.
      java.lang.String getInitDefault()
      An expression to return a default instance of the type that this builder builds.
      java.lang.String getInitializer()
      An initializer for the builder field, for example ImmutableSet.builder().
      java.lang.String getName()
      The name of the field to hold this builder.
      javax.lang.model.element.ExecutableElement getPropertyBuilderMethod()
      The property builder method, for example barBuilder().
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • propertyBuilderMethod

        private final javax.lang.model.element.ExecutableElement propertyBuilderMethod
      • name

        private final java.lang.String name
      • builderType

        private final java.lang.String builderType
      • builderTypeMirror

        private final javax.lang.model.type.TypeMirror builderTypeMirror
      • initializer

        private final java.lang.String initializer
      • beforeInitDefault

        private final java.lang.String beforeInitDefault
      • initDefault

        private final java.lang.String initDefault
      • builtToBuilder

        private final java.lang.String builtToBuilder
      • copyAll

        private final java.lang.String copyAll
    • Constructor Detail

      • PropertyBuilder

        PropertyBuilder​(javax.lang.model.element.ExecutableElement propertyBuilderMethod,
                        java.lang.String builderType,
                        javax.lang.model.type.TypeMirror builderTypeMirror,
                        java.lang.String initializer,
                        java.lang.String beforeInitDefault,
                        java.lang.String initDefault,
                        java.lang.String builtToBuilder,
                        java.lang.String copyAll)
    • Method Detail

      • getPropertyBuilderMethod

        public javax.lang.model.element.ExecutableElement getPropertyBuilderMethod()
        The property builder method, for example barBuilder().
      • getAccess

        public java.lang.String getAccess()
      • getName

        public java.lang.String getName()
        The name of the field to hold this builder.
      • getBuilderType

        public java.lang.String getBuilderType()
        The type of the builder, for example ImmutableSet.Builder<String>.
      • getBuilderTypeMirror

        javax.lang.model.type.TypeMirror getBuilderTypeMirror()
      • getInitializer

        public java.lang.String getInitializer()
        An initializer for the builder field, for example ImmutableSet.builder().
      • getBeforeInitDefault

        public java.lang.String getBeforeInitDefault()
        An empty string, or a complete statement to be included before the expression returned by getInitDefault().
      • getInitDefault

        public java.lang.String getInitDefault()
        An expression to return a default instance of the type that this builder builds. For example, if this is an ImmutableList<String> then the method ImmutableList.of() will correctly return an empty ImmutableList<String>, assuming the appropriate context for type inference. The expression here can assume that the statement from getBeforeInitDefault() has preceded it.
      • getBuiltToBuilder

        public java.lang.String getBuiltToBuilder()
        A method to convert the built type back into a builder. Unfortunately Guava collections don't have this (you can't say myImmutableMap.toBuilder()), but for other types such as @AutoValue types this is toBuilder().
      • getCopyAll

        public java.lang.String getCopyAll()
        The method to copy another collection into this builder. It is addAll for one-dimensional collections like ImmutableList and ImmutableSet, and it is putAll for two-dimensional collections like ImmutableMap and ImmutableTable.