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 java.util.Optional;
11 import org.opendaylight.mdsal.dom.api.DOMSchemaService;
14 * Base class for an RFC 8040 implementation.
16 * @author Thomas Pantelis
18 public abstract class BaseYangSwaggerGeneratorRFC8040 extends BaseYangSwaggerGenerator {
20 private static final String DEFAULT_BASE_PATH = "rests";
21 private static final String PATH_VERSION = "rfc8040";
22 private final String basePath;
24 protected BaseYangSwaggerGeneratorRFC8040(final Optional<DOMSchemaService> schemaService) {
26 this.basePath = DEFAULT_BASE_PATH;
29 protected BaseYangSwaggerGeneratorRFC8040(final Optional<DOMSchemaService> schemaService, final String basePath) {
31 this.basePath = basePath;
35 protected String getPathVersion() {
40 public String getResourcePath(final String resourceType, final String context) {
41 if (isData(resourceType)) {
42 return "/" + basePath + "/data" + context;
44 return "/" + basePath + "/operations" + context;
48 public String getResourcePathPart(final String resourceType) {
49 if (isData(resourceType)) {
55 private static boolean isData(final String dataStore) {
56 return "config".contains(dataStore) || "operational".contains(dataStore);
60 protected ListPathBuilder newListPathBuilder() {
61 return new ListPathBuilder() {
62 private String prefix = "=";
65 public String nextParamIdentifier(final String key) {
66 final String str = prefix + "{" + key + "}";
74 protected void appendPathKeyValue(final StringBuilder builder, final Object value) {
75 builder.deleteCharAt(builder.length() - 1).append("=").append(value).append('/');