Android 为realm.io设计动态查询生成器的最佳方法是什么?
我正在为我的Android应用程序设计一个“高级过滤器”功能,我可以根据参数类型选择多个查询参数,有时是并集,有时是交集,但总是在一个对象类型上(带有一些嵌套对象)。 有谁知道设计这样一个查询生成器的优雅而通用的方法吗 我的对象如下所示: 公共类DBDocument扩展了RealmObject{Android 为realm.io设计动态查询生成器的最佳方法是什么?,android,realm,Android,Realm,我正在为我的Android应用程序设计一个“高级过滤器”功能,我可以根据参数类型选择多个查询参数,有时是并集,有时是交集,但总是在一个对象类型上(带有一些嵌套对象)。 有谁知道设计这样一个查询生成器的优雅而通用的方法吗 我的对象如下所示: 公共类DBDocument扩展了RealmObject{ @PrimaryKey private int _id; private String updatedAt; private String name; private String subject; p
@PrimaryKey
private int _id;
private String updatedAt;
private String name;
private String subject;
private int type;
private int senderId;
private String dateSent;
private int paymentStatus;
private String paymentDue;
private double invoiceAmount;
private String currency;
private String acknowledged;
private String fetched;
private String exported;
private int recipient;
private int addressId;
private String printed;
private boolean important;
private boolean hidden;
private int printMode;
private int printRule;
private RealmList<DBTag> tag = new RealmList<>();
private RealmList<DBComment> comment = new RealmList<>();
private RealmList<DBEvent> event = new RealmList<>();
@PrimaryKey
私人内部id;
私有字符串更新数据;
私有字符串名称;
私有字符串主题;
私有int型;
私有int senderId;
私有字符串已发送;
私人内部支付状态;
私人字符串付款到期;
私人双重发票金额;
私人字符串货币;
私有字符串已确认;
获取私有字符串;
私人字符串输出;
私人int接受者;
私有int地址id;
私人字符串打印;
私有布尔重要;
私有布尔隐藏;
私有int打印模式;
私有整数打印规则;
私有RealmList标记=新RealmList();
private RealmList comment=new RealmList();
私有RealmList事件=新建RealmList();
。。。
}您希望它的通用性如何?类的内省在Java中是相当昂贵的,所以一个完整的泛型生成器可能会非常慢。我不确定这是否会有帮助,但是Android的领域浏览器()可以给你一些启发;和query.endGroup();定义每个搜索区域并使用query.equalTo()链接它们(用于交叉点)。