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

nl.vpro.domain.media.search.LocalDateRange Maven / Gradle / Ivy

Go to download

The basic domain classes for 'media', the core of POMS. Also, the 'update' XML bindings for it. It also contains some closely related domain classes like the enum to contain NICAM kijkwijzer settings.

There is a newer version: 8.3.1
Show newest version
/*
 * Copyright (C) 2010 Licensed under the Apache License, Version 2.0
 * VPRO The Netherlands
 */
package nl.vpro.domain.media.search;

import lombok.*;

import java.time.LocalDate;
import java.time.chrono.ChronoLocalDate;

import jakarta.xml.bind.annotation.*;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "localdateRangeType", propOrder = {
        "start",
        "stop"
        })
@ToString
@Data
@AllArgsConstructor
@Builder(builderClassName = "Builder")
public class LocalDateRange implements Range {

    @XmlElement
    private RangeValue start;

    @XmlElement
    private RangeValue stop;

    public LocalDateRange() {
    }

    public LocalDateRange(LocalDate start, LocalDate stop) {
        this.start = Value.of(start);
        this.stop = Value.exclusive(stop);
    }

    public LocalDateRange(LocalDate start) {
        this.start = Value.of(start);
        this.stop = Value.of(start);
    }


    @Data
    @EqualsAndHashCode(callSuper = true)
    @XmlType(name = "localDateRangeValueType")
    public static class Value extends Range.RangeValue {

        @XmlValue
        @XmlSchemaType(name = "dateTime")
        LocalDate value;

        public Value() {

        }
        public Value(String value) {
            this.value = LocalDate.parse(value);
        }


        @lombok.Builder
        public Value(Boolean inclusive, LocalDate value) {
            super(inclusive);
            this.value = value;
        }
        public static Value of(LocalDate instant) {
            if (instant == null) {
                return null;
            }
            return builder().value(instant).build();
        }

        public static Value exclusive(LocalDate instant) {
            if (instant == null) {
                return null;
            }
            return builder().value(instant).inclusive(false).build();
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy