Annotation Type BeanDefinition


  • @Retention(RUNTIME)
    @Target(TYPE)
    public @interface BeanDefinition
    Annotation defining a bean for code generation.

    This annotation must be used on classes that should be treated as beans.

    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      java.lang.String builderName
      The name of the manual builder class.
      java.lang.String builderScope
      The scope of the builder class.
      boolean cacheHashCode
      Whether to generate code to cache the hash code.
      java.lang.String cloneStyle
      The configuration for generating clone methods.
      java.lang.String constructorScope
      The scope of the generated constructor.
      java.lang.String factoryName
      The name of the factory method.
      java.lang.String hierarchy
      Information about the bean hierarchy.
      java.lang.String metaScope
      The scope of the meta-bean class.
      java.lang.String style
      The style of bean generation.
    • Element Detail

      • style

        java.lang.String style
        The style of bean generation.

        By default, this follows 'smart' rules. Set to 'minimal' to generate a minimal amount of code. Set to 'full' to generate the full code. Set to 'light' to generate a light immutable bean using reflection internally.

        Returns:
        the style, defaulted to 'smart'
        Default:
        "smart"
      • constructorScope

        java.lang.String constructorScope
        The scope of the generated constructor.

        Only applicable to immutable beans. By default, this follows 'smart' rules, which generate a private constructor when needed by the builder. Set to 'private' to generate a private constructor. Set to 'package' to generate a package-scoped constructor. Set to 'protected' to generate a protected constructor. Set to 'public' to generate a public constructor. Set to 'public@ConstructorProperties' to generate a public constructor.

        Returns:
        the constructor scope, defaulted to 'smart'
        Default:
        "smart"
      • metaScope

        java.lang.String metaScope
        The scope of the meta-bean class.

        By default, this follows 'smart' rules, which generate a public meta-bean. Set to 'private' to generate a private meta-bean. Set to 'package' to generate a package-scoped meta-bean. Set to 'public' to generate a public meta-bean.

        Returns:
        the meta scope, defaulted to 'smart'
        Default:
        "smart"
      • builderScope

        java.lang.String builderScope
        The scope of the builder class.

        By default, this follows 'smart' rules, which generate a public builder for immutable beans and no builder for mutable beans. Set to 'private' to generate a private builder. Set to 'package' to generate a package-scoped builder. Set to 'public' to generate a public builder.

        Returns:
        the builder scope, defaulted to 'smart'
        Default:
        "smart"
      • builderName

        java.lang.String builderName
        The name of the manual builder class.

        This is used when there is a desire to manually write the builder. By default, this is not set, and a builder is generated based on the scope. Set to 'FooBuilder' to generate code that expects a manually written builder named FooBuilder (which may be an inner class or a top-level class).

        Returns:
        the builder scope, defaulted to ''
        Default:
        ""
      • factoryName

        java.lang.String factoryName
        The name of the factory method.

        By default, this is an empty string and no factory is generated. Set to 'of' to generate a factory method named 'of'.

        Returns:
        the factory name, defaulted to ''
        Default:
        ""
      • hierarchy

        java.lang.String hierarchy
        Information about the bean hierarchy.

        This is needed to add information that cannot be derived. Set to 'immutable' for a subclass of an immutable bean.

        Returns:
        the hierarchy, defaulted to ''
        Default:
        ""
      • cloneStyle

        java.lang.String cloneStyle
        The configuration for generating clone methods.

        This flag controls generation of the clone method. The default is 'smart'.

        The valid values are:

        • 'omit' - omit the clone method
        • 'smart' - process intelligently, generating it for mutable and not generating for immutable
        • 'generate' - generate the clone method
        Returns:
        the clone style, defaulted to 'smart'
        Default:
        "smart"
      • cacheHashCode

        boolean cacheHashCode
        Whether to generate code to cache the hash code.

        Setting this to true will cause the hash code to be cached using the racy single check idiom. The setting only applies to immutable beans.

        Returns:
        true if the hash code is to be cached
        Default:
        false