Package ghidra.app.util.bin.format.golang.structmapping

# Annotation Interface FieldMapping

@Retention(RUNTIME) @Target(FIELD) public @interface FieldMapping
Indicates that the tagged java field corresponds to a field in a Ghidra structure.

If the name of the java field does not match the Ghidra structure field name, the `fieldName()` property can be used to manually specify the Ghidra field name.

The type of the tagged java field can be a java primitive, or a `structure mapped` class.

Supported java primitive types:

- long, int, short, byte
- char

- ## Optional Element Summary

  Optional Elements
  Modifier and Type
  Optional Element
  Description
  `String[]`
  `fieldName`
  Overrides the field name that is matched in the structure.
  `int`
  `length`
  Allows override the length of the structure field
  `boolean`
  `optional`
  Marks this field as optional.
  `String`
  `presentWhen`
  Marks this field as only present in certain context configurations.
  `Class<? extends FieldReadFunction>`
  `readFunc`
  Optional function that will deserialize the tagged field.
  `String`
  `setter`
  Specifies the name of a setter method that will be used to assign the deserialized value to the java field.
  `Signedness`
  `signedness`
  Override the signedness of the underlying numeric field.

- ## Element Details

  - ### fieldName

    String[] fieldName
    Overrides the field name that is matched in the structure.

    Can be a single name, or a list of names that will be used to find the structure field. The name is case-insensitive.

    Returns:
      name, or list of names (case insensitive), of the structure field to map, or unset to use the java field's name
    Default:
      `{""}`

  - ### optional

    boolean optional
    Marks this field as optional.

    When marked optional, if a binding between the tagged java field and a structure field is not successfully found, this field definition will be skipped.

    Returns:
      boolean flag, if true this field is optional, if false or unset, the field is required
    Default:
      `false`

  - ### presentWhen

    String presentWhen
    Marks this field as only present in certain context configurations.

    The specified string is interpreted by the specific `DataTypeMapper` and its `context`.

    For example, a version number could be used to allow some optional fields to be skipped depending on the concrete `DataTypeMapper`'s information during structure mapping registration.

    Similar to `optional()`

    Returns:
      String
    Default:
      `""`

  - ### setter

    String setter
    Specifies the name of a setter method that will be used to assign the deserialized value to the java field.

    If unset, a "void setFieldname(field_type)" method will be searched for.

    If no setter method is present, the field's value will be directly assigned.

    Returns:
      optional name of a setter method
    Default:
      `""`

  - ### readFunc

    Class<? extends FieldReadFunction> readFunc
    Optional function that will deserialize the tagged field.
    Returns:
      `FieldReadFunction`
    Default:
      `ghidra.app.util.bin.format.golang.structmapping.FieldReadFunction.class`

  - ### length

    int length
    Allows override the length of the structure field
    Returns:
      length of the structure field, or unset to use the field's data type
    Default:
      `-1`

  - ### signedness

    Signedness signedness
    Override the signedness of the underlying numeric field.
    Returns:
      `Signedness` enum, or unset to use the data type's normal signedness
    Default:
      `Unspecified`