Data-Mediator入門系列2-2

LightSun發表於2017-12-07

學習路徑

陣列,列表,SparseArray的屬性。

  • 就以之前的 模型 Student來舉例說明.
//age是陣列屬性
//name是list屬性
//id 是SparseArray屬性
@Fields( {
      @Field(propName = "age" , type = int.class, complexType = COMPLEX_ARRAY),
      @Field(propName = "name" , type = String.class, complexType = COMPLEX_LIST),
      @Field(propName = "id" , type = long.class, complexType = COMPLEX_SPARSE_ARRAY),
})
public interface Student{}
複製程式碼
  • 生成的模型程式碼:
@Fields( {
      @Field(propName = "age" , type = int.class, complexType = COMPLEX_ARRAY),
      @Field(propName = "name" , type = String.class, complexType = COMPLEX_LIST),
      @Field(propName = "id" , type = long.class, complexType = COMPLEX_SPARSE_ARRAY),
})
public interface Student extends Serializable, Parcelable, DataPools.Poolable {

    Property PROP_age = SharedProperties.get(int.class.getName(), "age", 1);
    Property PROP_name = SharedProperties.get(String.class.getName(), "name", 2);
    Property PROP_id = SharedProperties.get(long.class.getName(), "id", 3);

    Student setAge(int[] age1);

    int[] getAge();

    Student setName(List<String> name1);

    List<String> getName();

    ListPropertyEditor<? extends Student, String> beginNameEditor();

    Student setId(SparseArray<Long> id1);

    SparseArray<Long> getId();

    SparseArrayPropertyEditor<? extends Student, Long> beginIdEditor();
}
複製程式碼

下一章

Data-Mediator入門系列3

想要體驗最新的特性 ?

請到github/data-mediator體驗。 如果覺得不錯,請star支援下專案哈。

歡迎大家star, fork,contribute ,提issue. 它會越來越棒。

Thanks for reading !

技術源於分享!