public final class Wire extends Object
| Modifier and Type | Method and Description |
|---|---|
static <T> T |
get(T value,
T defaultValue)
Returns
value if it is not null; defaultValue otherwise. |
public static <T> T get(T value,
T defaultValue)
value if it is not null; defaultValue otherwise.
This is used to conveniently return a default value when a value is null.
For example,
MyProto myProto = ... MyField field = Wire.get(myProto.f, MyProto.f_default);will attempt to retrieve the value of the field 'f' defined by MyProto. If the field is null (i.e., unset),
get will return its
second argument, which in this case is the default value for the field
'f'.Copyright © 2013–2017 Square, Inc.. All rights reserved.