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

nl.vpro.domain.api.DurationRangeFacets Maven / Gradle / Ivy

Go to download

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

The newest version!
/*
 * Copyright (C) 2013 Licensed under the Apache License, Version 2.0
 * VPRO The Netherlands
 */
package nl.vpro.domain.api;

import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import jakarta.xml.bind.annotation.*;

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

import nl.vpro.domain.api.jackson.DurationRangeFacetsToJson;

/**
 * @author Roelof Jan Koekoek
 * @since 2.0
 */
@XmlType(name = "durationRangeFacetsType", propOrder = {
    "ranges"})
@XmlAccessorType(XmlAccessType.FIELD)
@JsonSerialize(using = DurationRangeFacetsToJson.Serializer.class)
@JsonDeserialize(using = DurationRangeFacetsToJson.Deserializer.class)
public class DurationRangeFacets extends AbstractFacet implements Facet {

    @XmlElements({
        @XmlElement(name = "interval", type = DurationRangeInterval.class),
        @XmlElement(name = "range", type = DurationRangeFacetItem.class)
    })
    @JsonIgnore
    private List> ranges;

    public DurationRangeFacets() {
    }

    @SafeVarargs
    public DurationRangeFacets(RangeFacet... ranges) {
        if(ranges != null && ranges.length > 0) {
            this.ranges = Arrays.asList(ranges);
        }
    }

    public List> getRanges() {
        return ranges;
    }

    public void setRanges(List> ranges) {
        this.ranges = ranges;
    }

    @SafeVarargs
    public final void addRanges(RangeFacet... ranges) {
        if(this.ranges == null) {
            this.ranges = new ArrayList<>(ranges.length);
        }

        Collections.addAll(this.ranges, ranges);
    }

    @Override
    public T getFilter() {
        return this.filter;
    }

    @Override
    public void setFilter(T filter) {
        this.filter = filter;
    }

    @Override
    public String toString() {
        return "DurationRangeFacets{" +
            "ranges=" + ranges +
            ", filter=" + filter +
            '}';
    }
}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy