2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.ahawastecollection.internal;
15 import java.util.Collections;
16 import java.util.Date;
17 import java.util.List;
19 import org.eclipse.jdt.annotation.NonNullByDefault;
22 * Contains the next collection dates for a given waste type.
24 * @author Sönke Küper - Initial contribution
27 final class CollectionDate {
30 * Type of waste that is collected.
32 public enum WasteType {
51 * Parses the {@link WasteType} from the given Value from the Web-page.
53 public static WasteType parseValue(String value) {
61 case "Leichtverpackungen":
62 return LIGHT_PACKAGES;
64 throw new IllegalArgumentException("Unknown waste type: " + value);
69 private final WasteType type;
70 private final List<Date> dates;
73 * Creates a new {@link CollectionDate}.
75 public CollectionDate(final WasteType type, final List<Date> dates) {
78 Collections.sort(this.dates);
82 * Returns the (non empty list) of next collection dates, for the given {@link WasteType}, ordered ascending.
84 public List<Date> getDates() {
89 * Returns the {@link WasteType} that is collected at the given times.
91 public WasteType getType() {
96 public String toString() {
97 return String.format("waste type: %s, collection dates: %s", this.type, this.dates);