The Talon Manual

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
java
java
@Generated(value="com.neeve.adm.AdmGenerator", date="Fri Jan 23 02:03:22 PST 2015")
public interface IMyMessage extends extends IRogNode, IRogMessage {


    final public void setChildField(final Child2 val);
    final public Child2 getChildField();
 
    final public void lendChildField(final Child2 val);
    final public Child2 takeChildField();}
Unset Fields Getters

When a field has not been set on a type the following table indicates what the getXXX() accessor will return:

Type
Unset Field Return Value
hasXXX
Notes
Java PrimitiveDefault value for java primitive type(tick)For numeric values 0, for boolean false, for char ''.
String, Date,null(tick) 
Enumnull(tick) 
Entitynull(tick) 
ArrayEmpty Array

(error)

Depends on code gen configuration property generateArrayGetterEmptyIfNull

For java primitive types the hasXXX() method can be called to distinguish between whether the value was explicitly set or is just returning the default value.

For arrays it is not possible to distinguish between an empty array or the array not being set. This allows ADM code to operate with protobuf encoding under the covers which is not able to distinguish between an empty or unset array. For this reason ADM generated code does not generate a hasXXX method for arrays. Setting the code generation property generateArrayGetterEmptyIfNull controls whether an empty or null array is returned when there are no values encoded in the underlying message or entity. 

Default Getters

The ADM Model supports the ability to generate 'default getters' which accept a default value to return when the field being accessed is not set. This can be enabled by passing the generateDefaultGetters=true directive to the AdmCodeGenerator.Default getter accessors will be created for any field type that has a corresponding hasXXX getter to accept a default value to return when the field is not set. While supported, usage of this setting is not recommended: the preferred mechanism is for applications to call hasXXX() directly instead. 

...