2 * Copyright (c) 2023 PANTHEON.tech s.r.o and others. All rights reserved.
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
8 package org.opendaylight.restconf.openapi.model;
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;
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;
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);
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);
41 final var putOperation = put();
42 if (putOperation != null) {
43 putOperation.generate(generator);
45 final var patchOperation = patch();
46 if (patchOperation != null) {
47 patchOperation.generate(generator);
49 final var deleteOperation = delete();
50 if (deleteOperation != null) {
51 deleteOperation.generate(generator);
53 final var getOperation = get();
54 if (getOperation != null) {
55 getOperation.generate(generator);
57 generator.writeEndObject();
60 @Nullable OperationEntity post() {
64 @Nullable OperationEntity put() {
68 @Nullable OperationEntity patch() {
72 @Nullable OperationEntity get() {
76 @Nullable OperationEntity delete() {