Class: MapField

MapField

Reflected map field.

new MapField(name, id, keyType, type, options, comment)

Constructs a new map field instance.

Name Type Description
name string

Unique name within its namespace

id number

Unique id within its namespace

keyType string

Key type

type string

Value type

options Object.<string, *> optional

Declared options

comment string optional

Comment associated with this field

Extends

Members

bytes { boolean }

Whether this field's value is a buffer.

comment { string | null }

Comment for this field.

declaringField { Field | null }

Sister-field within the declaring namespace if an extended field.

defaultValue { * }

The field's default value on prototypes.

extend { string | undefined }

Extended type if different from parent.

extensionField { Field | null }

Sister-field within the extended type if a declaring extension field.

filename { string | null }

Defining file name.

fullName readonly{ string }

Full name including leading dot.

id { number }

Unique field id.

keyType { string }

Key type.

long { boolean }

Whether this field's value should be treated as a long.

map { boolean }

Whether this field is a map or not.

message { Type | null }

Message this field belongs to.

name { string }

Unique name within its namespace.

options { Object<string, *> | undefined }

Options.

parent { Namespace | null }

Parent namespace.

parsedOptions { Object<string, *>[] | undefined }

Parsed Options.

partOf { OneOf | null }

OneOf this field belongs to, if any,

repeated { boolean }

Whether this field is repeated.

resolved { boolean }

Whether already resolved or not.

resolvedKeyType { ReflectionObject | null }

Resolved key type if not a basic type.

resolvedType { Type | Enum | null }

Resolved type if not a basic type.

root readonly{ Root }

Reference to the root namespace.

type { string }

Field type.

typeDefault { * }

The field type's default value.

Methods

inherited getOption(name){ * }

Gets an option value.

Name Type Description
name string

Option name

Returns:
Type Description
* Option value or undefined if not set

inherited onAdd(parent){ undefined }

Called when this object is added to a parent.

Name Type Description
parent ReflectionObject

Parent added to

Returns:
Type Description
undefined

inherited onRemove(parent){ undefined }

Called when this object is removed from a parent.

Name Type Description
parent ReflectionObject

Parent removed from

Returns:
Type Description
undefined

inherited resolve(){ Field }

Resolves this field's type references.

Throws:
Type Description
Error

If any reference cannot be resolved

Returns:
Type Description
Field this

inherited setOptions(options, ifNotSet){ ReflectionObject }

Sets multiple options.

Name Type Description
options Object.<string, *>

Options to set

ifNotSet boolean optional

Sets an option only if it isn't currently set

Returns:
Type Description
ReflectionObject this

inherited setParsedOption(name, value, propName){ ReflectionObject }

Sets a parsed option.

Name Type Description
name string

parsed Option name

value *

Option value

propName string

dot '.' delimited full path of property within the option to set. if undefined\empty, will add a new option with that value

Returns:
Type Description
ReflectionObject this

toJSON(toJSONOptions){ IMapField }

Converts this map field to a map field descriptor.

Name Type Description
toJSONOptions IToJSONOptions optional

JSON conversion options

Returns:
Type Description
IMapField Map field descriptor

inherited toString(){ string }

Converts this instance to its string representation.

Returns:
Type Description
string Class name[, space, full name]

MapField.d(fieldId, fieldKeyType, fieldValueType){ FieldDecorator }

Map field decorator (TypeScript).

Name Type Description
fieldId number

Field id

fieldKeyType "int32" | "uint32" | "sint32" | "fixed32" | "sfixed32" | "int64" | "uint64" | "sint64" | "fixed64" | "sfixed64" | "bool" | "string"

Field key type

fieldValueType "double" | "float" | "int32" | "uint32" | "sint32" | "fixed32" | "sfixed32" | "int64" | "uint64" | "sint64" | "fixed64" | "sfixed64" | "bool" | "string" | "bytes" | Object | Constructor.<{}>

Field value type

Deprecated
  • Legacy TypeScript decorator support. Will be removed in a future release.
Returns:
Type Description
FieldDecorator Decorator function

MapField.fromJSON(name, json){ MapField }

Constructs a map field from a map field descriptor.

Name Type Description
name string

Field name

json IMapField

Map field descriptor

Throws:
Type Description
TypeError

If arguments are invalid

Returns:
Type Description
MapField Created map field