new OneOf(name, fieldNames, options)
Constructs a new oneof instance.
Name | Type | Description |
---|---|---|
name |
string |
Oneof name |
fieldNames |
Array.<string> | Object.<string, *> |
optional
Field names |
options |
Object.<string, *> |
optional
Declared options |
Extends
Members
-
comment { string | null }
-
Comment text, if any.
-
fieldsArray readonly{ Field[] }
-
Fields that belong to this oneof as an array for iteration.
-
filename { string | null }
-
Defining file name.
-
fullName readonly{ string }
-
Full name including leading dot.
-
name { string }
-
Unique name within its namespace.
-
oneof { string[] }
-
Field names that belong to this oneof.
-
options { Object<string, *> | undefined }
-
Options.
-
parent { Namespace | null }
-
Parent namespace.
-
resolved { boolean }
-
Whether already resolved or not.
-
root readonly{ Root }
-
Reference to the root namespace.
Methods
-
OneOf.d(fieldNames){ OneOfDecorator }
-
OneOf decorator (TypeScript).
Name Type Description fieldNames
string repeatable Field names
Returns:
Type Description OneOfDecorator Decorator function -
OneOf.fromJSON(name, json){ OneOf }
-
Constructs a oneof from a oneof descriptor.
Name Type Description name
string Oneof name
json
IOneOf Oneof descriptor
Throws:
Type Description TypeError If arguments are invalid
Returns:
Type Description OneOf Created oneof -
add(field){ OneOf }
-
Adds a field to this oneof and removes it from its current parent, if any.
Name Type Description field
Field Field to add
Returns:
Type Description OneOf this
-
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 -
remove(field){ OneOf }
-
Removes a field from this oneof and puts it back to the oneof's parent.
Name Type Description field
Field Field to remove
Returns:
Type Description OneOf this
-
inherited resolve(){ ReflectionObject }
-
Resolves this objects type references.
Returns:
Type Description ReflectionObject this
-
inherited setOption(name, value, ifNotSet){ ReflectionObject }
-
Sets an option.
Name Type Description name
string Option name
value
* Option value
ifNotSet
boolean optional Sets the option only if it isn't currently set
Returns:
Type Description ReflectionObject 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
-
toJSON(){ IOneOf }
-
Converts this oneof to a oneof descriptor.
Returns:
Type Description IOneOf Oneof descriptor -
inherited toString(){ string }
-
Converts this instance to its string representation.
Returns:
Type Description string Class name[, space, full name]