new Field(message, rule, type, name, id, options)
Constructs a new Message Field.
Parameters:
Name | Type | Argument | Description |
---|---|---|---|
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 |
Extends
Members
-
id :number
-
Unique message field id.
-
options :Object.<string,*>
-
Message field options.
-
originalName :string
-
Original field name.
-
parent :ProtoBuf.Reflect.T|null
-
Parent object.
- Inherited From:
-
repeated :boolean
-
Message field repeated flag.
-
required :boolean
-
Message field required flag.
-
resolvedType :ProtoBuf.Reflect.T|null
-
Resolved type reference inside the global namespace.
-
type
-
Message field type. Type reference string if unresolved, protobuf type if resolved.
Methods
-
build()
-
Builds this type.
- Inherited From:
Throws:
If this type cannot be built directly- Type
- Error
-
decode(wireType, buffer, skipRepeated) → {*}
-
Decode the field value from the specified buffer.
Parameters:
Name Type Argument 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.
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
* Field value
buffer
ByteBuffer ByteBuffer to encode to
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
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:
Returns:
Fully qualified name as of ".PATH.TO.THIS"
- Type
- string
-
toString(includeClass)
-
Returns a string representation of this Reflect object (its fully qualified name).
Parameters:
Name Type Argument Description includeClass
boolean <optional>
Set to true to include the class name. Defaults to false.
- Inherited From:
Returns:
String representation
-
verifyValue(value, skipRepeated) → {*}
-
Checks if the given value can be set for this field.
Parameters:
Name Type Argument Description value
* Value to check
skipRepeated
boolean <optional>
Whether to skip the repeated value check or not. Defaults to false.
Throws:
If the value cannot be set for this field- Type
- Error
Returns:
Verified, maybe adjusted, value
- Type
- *