# Class: Builder

## ProtoBuf. Builder

Provides the functionality to build protocol messages.

#### new Builder(optionsopt)

  Constructs a new Builder.

  ##### Parameters:

  Name | Type | Attributes | Description
  --- | --- | --- | ---
  `options` | Object.<string, *> | <optional> | Options

  Source:
    - ProtoBuf.js, line 4229

### Classes

Message
Service

### Members

#### files :Array.<string>

  Imported files.

  ##### Type:

  - Array.<string>
  Source:
    - ProtoBuf.js, line 4264

#### (nullable) importRoot :string

  Import root override.

  ##### Type:

  - string
  Source:
    - ProtoBuf.js, line 4271

#### ns :ProtoBuf.Reflect.Namespace

  Namespace.

  ##### Type:

  - ProtoBuf.Reflect.Namespace
  Source:
    - ProtoBuf.js, line 4236

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

  Options.

  ##### Type:

  - Object.<string, *>
  Source:
    - ProtoBuf.js, line 4278

#### ptr :ProtoBuf.Reflect.T

  Namespace pointer.

  ##### Type:

  - ProtoBuf.Reflect.T
  Source:
    - ProtoBuf.js, line 4243

#### resolved :boolean

  Resolved flag.

  ##### Type:

  - boolean
  Source:
    - ProtoBuf.js, line 4250

#### result :Object.<string, (ProtoBuf.Builder.Message|Object)>|null

  The current building result.

  ##### Type:

  - Object.<string, (ProtoBuf.Builder.Message|Object)> | null
  Source:
    - ProtoBuf.js, line 4257

### Methods

#### (static) isEnum(defnon-null) → {boolean}

  Tests if a definition most likely describes an enum.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `def` | Object |

  Source:
    - ProtoBuf.js, line 4324

  ##### Returns:

  Type
    boolean

#### (static) isExtend(defnon-null) → {boolean}

  Tests if a definition most likely describes an extended message

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `def` | Object |

  Source:
    - ProtoBuf.js, line 4353

  ##### Returns:

  Type
    boolean

#### (static) isMessage(defnon-null) → {boolean}

  Tests if a definition most likely describes a message.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `def` | Object |

  Source:
    - ProtoBuf.js, line 4295

  ##### Returns:

  Type
    boolean

#### (static) isMessageField(defnon-null) → {boolean}

  Tests if a definition most likely describes a message field.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `def` | Object |

  Source:
    - ProtoBuf.js, line 4311

  ##### Returns:

  Type
    boolean

#### (static) isService(defnon-null) → {boolean}

  Tests if a definition most likely describes a service.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `def` | Object |

  Source:
    - ProtoBuf.js, line 4340

  ##### Returns:

  Type
    boolean

#### "import"](json, filenameopt) → (non-null) {ProtoBuf.Builder}

  Imports another definition into this builder.

  ##### Parameters:

  Name | Type | Attributes | Description
  --- | --- | --- | ---
  `json` | Object.<string, *> |  | Parsed import
  `filename` | string | Object | <optional> | Imported file name

  Source:
    - ProtoBuf.js, line 4567

  ##### Throws:

  If the definition or file cannot be imported
  Type
    Error

  ##### Returns:

  this

  Type
    ProtoBuf.Builder

#### build(pathopt) → {ProtoBuf.Builder.Message|!Object.<string, *>}

  Builds the protocol. This will first try to resolve all definitions and, if this has been successful, return the built package.

  ##### Parameters:

  Name | Type | Attributes | Description
  --- | --- | --- | ---
  `path` | string | Array.<string> | <optional> | Specifies what to return. If omitted, the entire namespace will be returned.

  Source:
    - ProtoBuf.js, line 4763

  ##### Throws:

  If a type could not be resolved
  Type
    Error

  ##### Returns:

  Type
    ProtoBuf.Builder.Message | !Object.<string, *>

#### create(defsnon-null) → (non-null) {ProtoBuf.Builder}

  Creates the specified definitions at the current pointer position.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `defs` | Array.<Object> | Messages, enums or services to create

  Source:
    - ProtoBuf.js, line 4397

  ##### Throws:

  If a message definition is invalid
  Type
    Error

  ##### Returns:

  this

  Type
    ProtoBuf.Builder

#### define(namespace) → (non-null) {ProtoBuf.Builder}

  Defines a namespace on top of the current pointer position and places the pointer on it.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `namespace` | string |

  Source:
    - ProtoBuf.js, line 4378

  ##### Returns:

  this

  Type
    ProtoBuf.Builder

#### lookup(pathopt, excludeNonNamespaceopt) → (nullable) {ProtoBuf.Reflect.T}

  Similar to ProtoBuf.Builder#build, but looks up the internal reflection descriptor.

  ##### Parameters:

  Name | Type | Attributes | Description
  --- | --- | --- | ---
  `path` | string | <optional> | Specifies what to return. If omitted, the entire namespace wiil be returned.
  `excludeNonNamespace` | boolean | <optional> | Excludes non-namespace types like fields, defaults to `false`

  Source:
    - ProtoBuf.js, line 4791

  ##### Returns:

  Reflection descriptor or `null` if not found

  Type
    ProtoBuf.Reflect.T

#### reset() → (non-null) {ProtoBuf.Builder}

  Resets the pointer to the root namespace.

  Source:
    - ProtoBuf.js, line 4367

  ##### Returns:

  this

  Type
    ProtoBuf.Builder

#### resolveAll() → (non-null) {ProtoBuf.Builder}

  Resolves all namespace objects.

  Source:
    - ProtoBuf.js, line 4689

  ##### Throws:

  If a type cannot be resolved
  Type
    Error

  ##### Returns:

  this

  Type
    ProtoBuf.Builder

#### toString() → {string}

  Returns a string representation of this object.

  Source:
    - ProtoBuf.js, line 4800

  ##### Returns:

  String representation as of "Builder"

  Type
    string