2 * Copyright (c) 2018 Inocybe Technologies 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.netconf.sal.rest.doc.impl;
10 import static java.util.Objects.requireNonNull;
12 import java.util.Optional;
13 import org.opendaylight.mdsal.dom.api.DOMSchemaService;
16 * Base class for an RFC 8040 implementation.
18 * @author Thomas Pantelis
20 public abstract class BaseYangSwaggerGeneratorRFC8040 extends BaseYangSwaggerGenerator {
21 private final String basePath;
23 protected BaseYangSwaggerGeneratorRFC8040(final Optional<DOMSchemaService> schemaService) {
24 this(schemaService, "rests");
27 protected BaseYangSwaggerGeneratorRFC8040(final Optional<DOMSchemaService> schemaService, final String basePath) {
29 this.basePath = requireNonNull(basePath);
33 public String getResourcePath(final String resourceType, final String context) {
34 if (isData(resourceType)) {
35 return "/" + basePath + "/data" + context;
37 return "/" + basePath + "/operations" + context;
41 public String getResourcePathPart(final String resourceType) {
42 if (isData(resourceType)) {
48 private static boolean isData(final String dataStore) {
49 return "config".contains(dataStore) || "operational".contains(dataStore);
53 protected ListPathBuilder newListPathBuilder() {
54 return new ListPathBuilder() {
55 private String prefix = "=";
58 public String nextParamIdentifier(final String key) {
59 final String str = prefix + "{" + key + "}";
67 protected void appendPathKeyValue(final StringBuilder builder, final Object value) {
68 builder.deleteCharAt(builder.length() - 1).append("=").append(value).append('/');