Annotation Interface BeanIgnore


Excludes a class, field, method, or constructor from bean introspection.

The bean-modeling sibling of @MarshalledIgnore: where @MarshalledIgnore (in juneau-marshall) controls whether the marshaller skips a type entirely at the wire-format layer, this annotation describes whether something participates in bean detection. It lives in juneau-commons so the bean-modeling layer can describe non-bean types and excluded bean members without depending on the marshalling layer.

Behavior depends on the target:

  • TYPE (class) — marks the class as not a bean. The marshaller falls through to its other type-detection logic (object swaps, @BeanType-style hints, @Marshalled(as=STRING), etc.) instead of treating the class as a bean.
  • FIELD — excludes the field from bean property discovery. Use ignoreAccessors() to also suppress matching JavaBean accessors.
  • METHOD — excludes the getter/setter from bean property discovery.
  • CONSTRUCTOR — excludes the constructor from constructor detection.
Java Records:

Ignoring individual record components is not supported during parsing. Because records are immutable, all components must be provided to the canonical constructor. Applying this annotation to a record component's accessor method or field will exclude it from serialization output, but the parser will be unable to instantiate the record if the component value is missing from the input.

See Also:
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Optional description for the exposed API.
    boolean
    When true and this annotation is on a field, JavaBean accessors (getX/setX, isX) for the same logical property are also excluded from bean metadata.
  • Element Details

    • description

      Optional description for the exposed API.
      Returns:
      The annotation value.
      Since:
      9.2.0
      Default:
      {}
    • ignoreAccessors

      When true and this annotation is on a field, JavaBean accessors (getX/setX, isX) for the same logical property are also excluded from bean metadata.

      Default is false: @BeanIgnore on a field only excludes the field from field-based discovery; accessors can still expose the property (for example when bean field visibility is set to NONE). Set to true to omit the property from serialization and parsing while keeping accessors for other frameworks.

      Returns:
      The annotation value.
      Default:
      false