Bump versions to 14.0.0-SNAPSHOT
[mdsal.git] / binding / mdsal-binding-dom-codec / src / main / java / org / opendaylight / mdsal / binding / dom / codec / impl / PropertyInfo.java
1 /*
2  * Copyright (c) 2022 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.mdsal.binding.dom.codec.impl;
9
10 import static java.util.Objects.requireNonNull;
11
12 import java.lang.reflect.Method;
13 import org.eclipse.jdt.annotation.NonNull;
14
15 /**
16  * Information about a property. It includes its getter method and, optionally, its nonnull method.
17  */
18 abstract sealed class PropertyInfo {
19     /**
20      * This property has only a getFoo() method.
21      */
22     static final class Getter extends PropertyInfo {
23         Getter(final Method getterMethod) {
24             super(getterMethod);
25         }
26     }
27
28     /**
29      * This property has a getFoo() method and a non-default nonnullFoo() method.
30      */
31     static final class GetterAndNonnull extends PropertyInfo {
32         private final @NonNull Method nonnullMethod;
33
34         GetterAndNonnull(final Method getterMethod, final Method nonnullMethod) {
35             super(getterMethod);
36             this.nonnullMethod = requireNonNull(nonnullMethod);
37         }
38
39         @NonNull Method nonnullMethod() {
40             return nonnullMethod;
41         }
42     }
43
44     private final @NonNull Method getterMethod;
45
46     private PropertyInfo(final Method getterMethod) {
47         this.getterMethod = requireNonNull(getterMethod);
48     }
49
50     final @NonNull Method getterMethod() {
51         return getterMethod;
52     }
53 }