Allow YANG PATCH to communicate ETag/Last-Modified
[netconf.git] / restconf / restconf-nb / src / main / java / org / opendaylight / restconf / server / api / OperationsGetResultHelper.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.server.api;
9
10 import org.opendaylight.yangtools.yang.common.QName;
11 import org.opendaylight.yangtools.yang.common.QNameModule;
12 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
13
14 /**
15  * Workaround for problems with invoking interface-private static methods in inner record classes. We deal with:
16  * <ul>
17  *   <li>Eclipse tries to import static such references, hence we need to prefix each use, and when we do</li>
18  *   <li>SpotBugs ends up reporting UPM_UNCALLED_PRIVATE_METHOD</li>
19  * </ul>
20  */
21 final class OperationsGetResultHelper {
22     private OperationsGetResultHelper() {
23         // Hidden on purpose
24     }
25
26     static StringBuilder appendJSON(final StringBuilder sb, final String prefix, final QName rpc) {
27         return sb.append('"').append(prefix).append(':').append(rpc.getLocalName()).append("\" : [null]");
28     }
29
30     static StringBuilder appendXML(final StringBuilder sb, final QName rpc) {
31         return sb.append('<').append(rpc.getLocalName()).append(' ').append("xmlns=\"").append(rpc.getNamespace())
32             .append("\"/>");
33     }
34
35     static String jsonPrefix(final EffectiveModelContext modelContext, final QNameModule namespace) {
36         return modelContext.findModuleStatement(namespace).orElseThrow().argument().getLocalName();
37     }
38 }