All Downloads are FREE. Search and download functionalities are using the official Maven repository.

nl.vpro.domain.api.page.AssociationSearchList Maven / Gradle / Ivy

Go to download

Contains the objects used by the Frontend API, like forms and result objects

There is a newer version: 8.3.3
Show newest version
package nl.vpro.domain.api.page;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.function.Predicate;

import org.checkerframework.checker.nullness.qual.NonNull;
import javax.validation.Valid;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

import nl.vpro.domain.page.Association;
import nl.vpro.jackson2.IterableJson;

/**
 * @author Michiel Meeuwissen
 * @since 4.3
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "pageAssociationSearchListType")
@JsonSerialize(using = IterableJson.Serializer.class)
@JsonDeserialize(using = AssociationSearchList.Deserializer.class)
public class AssociationSearchList implements Predicate, Iterable {


    @Valid
    @XmlElement(name = "search")
    protected List associationSearches = new ArrayList<>();

    public AssociationSearchList() {
    }


    public AssociationSearchList(AssociationSearch... relationSearch) {
        this(Arrays.asList(relationSearch));
    }

    public AssociationSearchList(List relationSearches) {
        this.associationSearches.addAll(relationSearches);
    }


    public List asList() {
        return associationSearches;
    }

    public int size() {
        return asList().size();
    }
    @NonNull
    @Override
    public Iterator iterator() {
        return associationSearches.iterator();

    }

    @Override
    public boolean test(Association association) {
        for (AssociationSearch search : this) {
            if (search.test(association)) {
                return true;
            }
        }
        return false;
    }

    public static class Deserializer extends IterableJson.Deserializer {

        public Deserializer() {
            super(AssociationSearchList::new, AssociationSearch.class);
        }
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy