Delete all always null returning methods
[netconf.git] / restconf / restconf-openapi / src / main / java / org / opendaylight / restconf / openapi / model / PathEntity.java
1 /*
2  * Copyright (c) 2023 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.openapi.model;
9
10 import com.fasterxml.jackson.core.JsonGenerator;
11 import java.io.IOException;
12 import java.util.Objects;
13 import org.eclipse.jdt.annotation.NonNull;
14 import org.eclipse.jdt.annotation.Nullable;
15
16 public final class PathEntity extends OpenApiEntity {
17     private final @NonNull String path;
18     private final @Nullable PostEntity post;
19     private final @Nullable PatchEntity patch;
20     private final @Nullable GetEntity get;
21     private final @Nullable PutEntity put;
22     private final @Nullable DeleteEntity delete;
23
24     public PathEntity(final String path, final PostEntity post, final PatchEntity patch,
25             final PutEntity put, final GetEntity get, final DeleteEntity delete) {
26         this.path = Objects.requireNonNull(path);
27         this.post = post;
28         this.patch = patch;
29         this.put = put;
30         this.delete = delete;
31         this.get = get;
32     }
33
34     @Override
35     public void generate(@NonNull JsonGenerator generator) throws IOException {
36         generator.writeObjectFieldStart(path);
37         final var postOperation = post();
38         if (postOperation != null) {
39             postOperation.generate(generator);
40         }
41         final var putOperation = put();
42         if (putOperation != null) {
43             putOperation.generate(generator);
44         }
45         final var patchOperation = patch();
46         if (patchOperation != null) {
47             patchOperation.generate(generator);
48         }
49         final var deleteOperation = delete();
50         if (deleteOperation != null) {
51             deleteOperation.generate(generator);
52         }
53         final var getOperation = get();
54         if (getOperation != null) {
55             getOperation.generate(generator);
56         }
57         generator.writeEndObject();
58     }
59
60     @Nullable OperationEntity post() {
61         return post;
62     }
63
64     @Nullable OperationEntity put() {
65         return put;
66     }
67
68     @Nullable OperationEntity patch() {
69         return patch;
70     }
71
72     @Nullable OperationEntity get() {
73         return get;
74     }
75
76     @Nullable OperationEntity delete() {
77         return delete;
78     }
79 }