Data-Mediator入门系列2-2

404 阅读1分钟

学习路径

数组,列表,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 !

技术源于分享!