2 * Copyright (c) 2010-2021 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.deutschebahn.internal;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.openhab.binding.deutschebahn.internal.timetable.dto.Event;
18 import org.openhab.binding.deutschebahn.internal.timetable.dto.TimetableStop;
19 import org.openhab.core.types.State;
20 import org.openhab.core.types.UnDefType;
23 * Selection that returns the value of an {@link EventAttribute}. The required {@link Event} is
24 * selected with the given {@link EventType}.
26 * @author Sönke Küper - Initial contribution
29 public final class EventAttributeSelection implements AttributeSelection {
31 private final EventType eventType;
32 private final EventAttribute<?, ?> eventAttribute;
35 * Creates an new {@link EventAttributeSelection}.
37 public EventAttributeSelection(EventType eventType, EventAttribute<?, ?> eventAttribute) {
38 this.eventType = eventType;
39 this.eventAttribute = eventAttribute;
44 public State getState(TimetableStop stop) {
45 final Event event = eventType.getEvent(stop);
47 return UnDefType.UNDEF;
49 return this.eventAttribute.getState(event);