# Class: ExtensionField

## ProtoBuf .Reflect .Message. ExtensionField

#### new ExtensionField(buildernon-null, messagenon-null, rule, type, name, id, optionsopt)

  Constructs a new Message ExtensionField.

  ##### Parameters:

  Name | Type | Attributes | Description
  --- | --- | --- | ---
  `builder` | ProtoBuf.Builder |  | Builder reference
  `message` | ProtoBuf.Reflect.Message |  | Message reference
  `rule` | string |  | Rule, one of requried, optional, repeated
  `type` | string |  | Data type, e.g. int32
  `name` | string |  | Field name
  `id` | number |  | Unique field id
  `options` | Object.<string, *> | <optional> | Options

  Source:
    - ProtoBuf.js, line 3161

### Extends

- ProtoBuf.Reflect.Message.Field

### Members

#### (non-null) builder :ProtoBuf.Builder

  Builder reference.

  ##### Type:

  - ProtoBuf.Builder
  Inherited From:
    - ProtoBuf.Reflect.T#builder
  Source:
    - ProtoBuf.js, line 1352

#### className

  Inherited From:
    - ProtoBuf.Reflect.Message.Field#className
  Source:
    - ProtoBuf.js, line 2511

#### defaultValue :*

  Default value.

  ##### Type:

  - *
  Inherited From:
    - ProtoBuf.Reflect.Message.Field#defaultValue
  Source:
    - ProtoBuf.js, line 2561

#### (non-null) extension :ProtoBuf.Reflect.Extension

  Extension reference.

  ##### Type:

  - ProtoBuf.Reflect.Extension
  Source:
    - ProtoBuf.js, line 3169

#### id :number

  Unique message field id.

  ##### Type:

  - number
  Inherited From:
    - ProtoBuf.Reflect.Message.Field#id
  Source:
    - ProtoBuf.js, line 2546

#### name :string

  Object name in namespace.

  ##### Type:

  - string
  Inherited From:
    - ProtoBuf.Reflect.T#name
  Source:
    - ProtoBuf.js, line 1366

#### (nullable) oneof :ProtoBuf.Reflect.Message.OneOf

  Enclosing OneOf.

  ##### Type:

  - ProtoBuf.Reflect.Message.OneOf
  Inherited From:
    - ProtoBuf.Reflect.Message.Field#oneof
  Source:
    - ProtoBuf.js, line 2568

#### (non-null) options :Object.<string, *>

  Message field options.

  ##### Type:

  - Object.<string, *>
  Inherited From:
    - ProtoBuf.Reflect.Message.Field#options
  Source:
    - ProtoBuf.js, line 2554

#### originalName :string

  Original field name.

  ##### Type:

  - string
  Inherited From:
    - ProtoBuf.Reflect.Message.Field#originalName
  Source:
    - ProtoBuf.js, line 2575

#### (nullable) parent :ProtoBuf.Reflect.T

  Parent object.

  ##### Type:

  - ProtoBuf.Reflect.T
  Inherited From:
    - ProtoBuf.Reflect.T#parent
  Source:
    - ProtoBuf.js, line 1359

#### repeated :boolean

  Message field repeated flag.

  ##### Type:

  - boolean
  Inherited From:
    - ProtoBuf.Reflect.Message.Field#repeated
  Source:
    - ProtoBuf.js, line 2525

#### required :boolean

  Message field required flag.

  ##### Type:

  - boolean
  Inherited From:
    - ProtoBuf.Reflect.Message.Field#required
  Source:
    - ProtoBuf.js, line 2518

#### resolvedType :ProtoBuf.Reflect.T|null

  Resolved type reference inside the global namespace.

  ##### Type:

  - ProtoBuf.Reflect.T | null
  Inherited From:
    - ProtoBuf.Reflect.Message.Field#resolvedType
  Source:
    - ProtoBuf.js, line 2539

#### type :string|Object

  Message field type. Type reference string if unresolved, protobuf type if resolved.

  ##### Type:

  - string | Object
  Inherited From:
    - ProtoBuf.Reflect.Message.Field#type
  Source:
    - ProtoBuf.js, line 2532

### Methods

#### build()

  Builds the field.

  Inherited From:
    - ProtoBuf.Reflect.Message.Field#build
  Source:
    - ProtoBuf.js, line 2605

#### calculate(value) → {number}

  Calculates the length of this field's value on the network level.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `value` | * | Field value

  Inherited From:
    - ProtoBuf.Reflect.Message.Field#calculate
  Source:
    - ProtoBuf.js, line 2945

  ##### Returns:

  Byte length

  Type
    number

#### calculateValue(value) → {number}

  Calculates the byte length of a value.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `value` | * | Field value

  Inherited From:
    - ProtoBuf.Reflect.Message.Field#calculateValue
  Source:
    - ProtoBuf.js, line 2984

  ##### Throws:

  If the value cannot be calculated
  Type
    Error

  ##### Returns:

  Byte length

  Type
    number

#### decode(wireType, buffer, skipRepeatedopt) → {*}

  Decode the field value from the specified buffer.

  ##### Parameters:

  Name | Type | Attributes | Description
  --- | --- | --- | ---
  `wireType` | number |  | Leading wire type
  `buffer` | ByteBuffer |  | ByteBuffer to decode from
  `skipRepeated` | boolean | <optional> | Whether to skip the repeated check or not. Defaults to false.

  Inherited From:
    - ProtoBuf.Reflect.Message.Field#decode
  Source:
    - ProtoBuf.js, line 3040

  ##### Throws:

  If the field cannot be decoded
  Type
    Error

  ##### Returns:

  Decoded value

  Type
    *

#### encode(value, buffer) → {ByteBuffer}

  Encodes the specified field value to the specified buffer.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `value` | * | Verified field value
  `buffer` | ByteBuffer | ByteBuffer to encode to

  Inherited From:
    - ProtoBuf.Reflect.Message.Field#encode
  Source:
    - ProtoBuf.js, line 2772

  ##### Throws:

  If the field cannot be encoded
  Type
    Error

  ##### Returns:

  The ByteBuffer for chaining

  Type
    ByteBuffer

#### encodeValue(value, buffer) → {ByteBuffer}

  Encodes a value to the specified buffer. Does not encode the key.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `value` | * | Field value
  `buffer` | ByteBuffer | ByteBuffer to encode to

  Inherited From:
    - ProtoBuf.Reflect.Message.Field#encodeValue
  Source:
    - ProtoBuf.js, line 2824

  ##### Throws:

  If the value cannot be encoded
  Type
    Error

  ##### Returns:

  The ByteBuffer for chaining

  Type
    ByteBuffer

#### fqn() → {string}

  Returns the fully qualified name of this object.

  Inherited From:
    - ProtoBuf.Reflect.T#fqn
  Source:
    - ProtoBuf.js, line 1387

  ##### Returns:

  Fully qualified name as of ".PATH.TO.THIS"

  Type
    string

#### toString(includeClassopt)

  Returns a string representation of this Reflect object (its fully qualified name).

  ##### Parameters:

  Name | Type | Attributes | Description
  --- | --- | --- | ---
  `includeClass` | boolean | <optional> | Set to true to include the class name. Defaults to false.

  Inherited From:
    - ProtoBuf.Reflect.T#toString
  Source:
    - ProtoBuf.js, line 1405

  ##### Returns:

  String representation

#### verifyValue(value, skipRepeatedopt) → {*}

  Checks if the given value can be set for this field.

  ##### Parameters:

  Name | Type | Attributes | Description
  --- | --- | --- | ---
  `value` | * |  | Value to check
  `skipRepeated` | boolean | <optional> | Whether to skip the repeated value check or not. Defaults to false.

  Inherited From:
    - ProtoBuf.Reflect.Message.Field#verifyValue
  Source:
    - ProtoBuf.js, line 2638

  ##### Throws:

  If the value cannot be set for this field
  Type
    Error

  ##### Returns:

  Verified, maybe adjusted, value

  Type
    *