Reduce exception guard
[netconf.git] / restconf / restconf-nb / src / main / java / org / opendaylight / restconf / nb / rfc8040 / AbstractReplayParam.java
1 /*
2  * Copyright (c) 2021 PANTHEON.tech, s.r.o. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.restconf.nb.rfc8040;
9
10 import static java.util.Objects.requireNonNull;
11
12 import com.google.common.annotations.Beta;
13 import com.google.common.base.MoreObjects;
14 import java.net.URI;
15 import org.eclipse.jdt.annotation.NonNull;
16 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
17
18 /**
19  * Abstract base class for StartTimeParameter and StopTimeParameter.
20  */
21 @Beta
22 // FIXME: sealed when we have JDK17+
23 public abstract class AbstractReplayParam<T extends AbstractReplayParam<T>> implements RestconfQueryParam<T> {
24     private static final @NonNull URI CAPABILITY = URI.create("urn:ietf:params:restconf:capability:replay:1.0");
25
26     private final @NonNull DateAndTime value;
27
28     AbstractReplayParam(final DateAndTime value) {
29         this.value = requireNonNull(value);
30     }
31
32     public final @NonNull DateAndTime value() {
33         return value;
34     }
35
36     @Override
37     public final String paramValue() {
38         return value.getValue();
39     }
40
41     @Override
42     public final String toString() {
43         return MoreObjects.toStringHelper(this).add("value", paramValue()).toString();
44     }
45
46     public static final @NonNull URI capabilityUri() {
47         return CAPABILITY;
48     }
49 }