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

nl.vpro.domain.api.page.AssociationSearch 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 javax.validation.Valid;
import javax.xml.bind.annotation.*;

import nl.vpro.domain.api.*;
import nl.vpro.domain.page.Association;
import nl.vpro.domain.page.LinkType;

/**
 * @author Michiel Meeuwissen
 * @since 4.3
 */
@XmlType(name = "associationSearchType")
@XmlAccessorType(XmlAccessType.FIELD)
public class AssociationSearch extends AbstractSearch  {

    public static AssociationSearch of(LinkType type) {
        return of(type, Match.MUST);
    }

    public static AssociationSearch of(LinkType type, Match match) {
        AssociationSearch search = new AssociationSearch();
        search.setMatch(match);
        search.urls = null;
        search.types = TextMatcherList.must(TextMatcher.must(type.name(), StandardMatchType.TEXT));
        return search;
    }


    @Valid
    private TextMatcherList urls;

    @Valid
    private TextMatcherList types;


    public TextMatcherList getUrls() {
        return urls;
    }

    public void setUrls(TextMatcherList url) {
        this.urls = urls;
    }

    public TextMatcherList getTypes() {
        return types;
    }

    public void setTypes(TextMatcherList type) {
        this.types = type;
    }

    @Override
    public boolean test(Association association) {
        if (association == null) {
            return  false;
        }
        if (urls != null) {
            if (!Matchers.listPredicate(urls).test(association.getPageRef())) {
                return false;
            }
        }
        if (types != null) {
            LinkType aType = association.getType();
            return Matchers.listPredicate(types).test(aType == null ? null : aType.name());
        }
        return false;

    }

    @Override
    public boolean hasSearches() {
        return atLeastOneHasSearches(types, urls);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy