如何过滤 pojo class 并从中创建新的 pojo class

How to filter pojo class and make new pojo class from them

我有一个 POJO class .ContactPOJO.class

 @PrimaryKey(autoGenerate = true)
    private  int id;
    private  String contact_id;
    private  String contact_name;
    private  String contact_number;
    private  boolean is_selected;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getContact_id() {
        return contact_id;
    }

    public void setContact_id(String contact_id) {
        this.contact_id = contact_id;
    }


    public boolean isIs_selected() {
        return is_selected;
    }

    public void setIs_selected(boolean is_selected) {
        this.is_selected = is_selected;
    }

    public String getContact_name() {
        return contact_name;
    }

    public void setContact_name(String contact_name) {
        this.contact_name = contact_name;
    }

    public String getContact_number() {
        return contact_number;
    }

    public void setContact_number(String contact_number) {
        this.contact_number = contact_number;
    }

现在我必须创建新的 POJO class,但仅限于 ContactPOJO 中 is_selected 布尔值为 true 的那个。我不知道该怎么做。任何帮助都会 appreciate.Thanks 提前

编辑: 我有 List<ContactPOJO> list_contact 。其中包含来自 phone 的所有联系人。现在有些会被选中,有些不会。它的选择与否将存储在 is_selected 变量中。现在我必须制作新列表。让我们说 List<newContactPOJO> 。但它将仅包含旧值的 is_selected 真实值。

List<ContactPOJO> list_contact;
List<ContactPOJO> list_selected_contact = new ArrayList();
for (ContactPOJO pojo : list_contact){
    pojo.setIs_selected(true);
    list_selected_contact.add(pojo);
}

==> 现在你有了一个包含所有选定对象的新列表