Annotation Interface CasualFieldElement


@Retention(RUNTIME) @Target({FIELD,METHOD,PARAMETER}) public @interface CasualFieldElement
Marks a field or, return value and parameter, for marshalling/unmarshalling with a specific name Note, the name is from fielded json so it has to exist there Usage:

 class X
 {
     {@literal @}CasualFieldElement(name = 'my-name')
     private String city;
 }
 
or

 class X
 {
     private String city;

     {@literal @}CasualFieldElement(name = 'my-name')
     public String getCity()
     {
         return city;
     }
     public void setCity({@literal @}CasualFieldElement(name = 'my-name') city)
     {
         this.city = city;
     }
 }
 
Instead of just a String, which is a fielded value, you could use a List of Strings ( or any other fielded type) With X defined as either one above you can do:

 class Y
 {
     {@literal @}CasualFieldElement(lengthName ="FLD_LONG1")
     List<X> theXs;
 }
 
or

 class Y
 {
     private List<X> theXs;

     {@literal @}CasualFieldElement(lengthName ="FLD_LONG1")
     public List<X> getTheXs()
     {
        return theXs;
     }

     public void setTheXs( {@literal @}CasualFieldElement(lengthName ="FLD_LONG1") List<X> theXs)
     {
        this.theXs = theXs;
     }
 }
 
You could also do:

 class Y
 {
     {@literal @}CasualFieldElement
     private X theX;
 }
 
or

 class Y
 {
     private X theX;

     {@literal @}CasualFieldElement
     public X getTheX()
     {
         return theX;
     }

     public setTheX( {@literal @}CasualFieldElement X theX)
     {
         this.theX = theX;
     }
 }
 
Notice that with wrapped POJOs you do not need to supply a name If they are in an array/list you do still do need to supply a lengthName Regarding lists: Interface type should be List<Type> and you can not make any assumptions of what the actual list type is after unmarshalling For arrays and lists you need to supply a lengthName that will be used for the number of items in the list/array.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    If the annotation annotates an array or a list The name should be a name from your fielded json
    Class<? extends CasualObjectMapper<? extends Object,? extends Object>>
    Default pass through mapper That is, if no other mapper is supplied - no mapping will take place
    A name from your fielded json Note that for int/Integer types you should use a name that maps to long as int/Integer are transported as longs
  • Element Details

    • name

      String name
      A name from your fielded json Note that for int/Integer types you should use a name that maps to long as int/Integer are transported as longs
      Returns:
      name.
      Default:
      ""
    • lengthName

      String lengthName
      If the annotation annotates an array or a list The name should be a name from your fielded json
      Returns:
      lengthName.
      Default:
      ""
    • mapper

      Class<? extends CasualObjectMapper<? extends Object,? extends Object>> mapper
      Default pass through mapper That is, if no other mapper is supplied - no mapping will take place
      Returns:
      mapper.
      Default:
      se.laz.casual.api.buffer.type.fielded.mapper.PassThroughMapper.class