public final class SoyProtoValueImpl extends SoyAbstractValue implements SoyProtoValue, SoyLegacyObjectMap, SoyRecord
TODO(b/70906867): This implements SoyMap/SoyRecord for backwards compatibility. When Soy initially added support for protos we implemented these interfaces to support using protos in legacy untyped templates. This made it easier for teams to start passing protos to their templates but has turned out to be a bad idea because it means your templates work differently in javascript vs java. So now we continue to support these usecases but issue warnings when it occurs. In the long run we will switch to either throwing exception or always returning null from these methods.
| Modifier and Type | Class and Description |
|---|---|
static class |
SoyProtoValueImpl.Builder
Provides an interface for constructing a SoyProtoValueImpl.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
coerceToBoolean()
Coerces this value into a boolean.
|
String |
coerceToString()
Coerces this value into a string.
|
static SoyProtoValueImpl |
create(com.google.protobuf.Message proto) |
boolean |
equals(Object other)
Compares this value against another for equality in the sense of the '==' operator of Soy.
|
SoyValue |
getField(String name)
Deprecated.
|
SoyValueProvider |
getFieldProvider(String name)
Deprecated.
|
SoyValue |
getItem(SoyValue key)
Deprecated.
|
int |
getItemCnt()
Deprecated.
|
Collection<SoyValue> |
getItemKeys()
Deprecated.
|
SoyValueProvider |
getItemProvider(SoyValue key)
Deprecated.
|
com.google.protobuf.Message |
getProto()
Returns the underlying message.
|
SoyValue |
getProtoField(String name)
Gets a value for the field for the underlying proto object.
|
boolean |
hasField(String name)
Deprecated.
|
int |
hashCode() |
boolean |
hasItem(SoyValue key)
Deprecated.
|
void |
render(LoggingAdvisingAppendable appendable)
Renders this value to the given appendable.
|
void |
setAccessLocationKey(Object location) |
String |
toString()
Returns a string that indicates the type of proto held, to assist in debugging Soy type errors.
|
booleanValue, floatValue, integerValue, longValue, numberValue, render, renderAndResolve, resolve, status, stringValueclone, finalize, getClass, notify, notifyAll, wait, wait, waitbooleanValue, floatValue, integerValue, longValue, numberValue, render, stringValuerenderAndResolve, resolve, statuspublic static SoyProtoValueImpl create(com.google.protobuf.Message proto)
public com.google.protobuf.Message getProto()
getProto in interface SoyProtoValuepublic SoyValue getProtoField(String name)
SoyProtoValuegetProtoField in interface SoyProtoValuename - The proto field name.public void setAccessLocationKey(Object location)
@Deprecated public boolean hasField(String name)
SoyRecord@Deprecated public SoyValue getField(String name)
SoyRecord@Deprecated public SoyValueProvider getFieldProvider(String name)
SoyRecordgetFieldProvider in interface SoyRecordname - The field name to get.@Deprecated public int getItemCnt()
SoyLegacyObjectMapgetItemCnt in interface SoyLegacyObjectMap@Deprecated public Collection<SoyValue> getItemKeys()
SoyLegacyObjectMapImportant: Iteration order is undefined.
getItemKeys in interface SoyLegacyObjectMap@Deprecated public boolean hasItem(SoyValue key)
SoyLegacyObjectMaphasItem in interface SoyLegacyObjectMapkey - The item key to check.@Deprecated public SoyValue getItem(SoyValue key)
SoyLegacyObjectMapgetItem in interface SoyLegacyObjectMapkey - The item key to get.@Deprecated public SoyValueProvider getItemProvider(SoyValue key)
SoyLegacyObjectMapgetItemProvider in interface SoyLegacyObjectMapkey - The item key to get.public boolean equals(Object other)
SoyValueequals in interface SoyValueequals in class SoyAbstractValueother - The other value to compare against.public boolean coerceToBoolean()
SoyValuecoerceToBoolean in interface SoyValuepublic String coerceToString()
SoyValuecoerceToString in interface SoyValuepublic void render(LoggingAdvisingAppendable appendable) throws IOException
SoyValueThis should behave identically to appendable.append(coerceToString()) but is
provided separately to allow more incremental approaches.
render in interface SoyValueappendable - The appendable to render to.IOExceptionpublic String toString()