9afebedc1bea9db0e68ff2bffec388df21e948f1
[netconf.git] / restconf / sal-rest-docgen / src / main / java / org / opendaylight / netconf / sal / rest / doc / impl / BaseYangSwaggerGeneratorDraft02.java
1 /*
2  * Copyright (c) 2018 Inocybe Technologies 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.netconf.sal.rest.doc.impl;
9
10 import java.util.Optional;
11 import org.opendaylight.mdsal.dom.api.DOMSchemaService;
12
13 /**
14  * Base class for a bierman draft02 implementation.
15  *
16  * @author Thomas Pantelis
17  */
18 public abstract class BaseYangSwaggerGeneratorDraft02 extends BaseYangSwaggerGenerator {
19
20     protected static final String DEFAULT_BASE_PATH = "restconf";
21     private final String basePath;
22
23     protected BaseYangSwaggerGeneratorDraft02(final Optional<DOMSchemaService> schemaService) {
24         super(schemaService);
25         this.basePath = DEFAULT_BASE_PATH;
26     }
27
28     protected BaseYangSwaggerGeneratorDraft02(final Optional<DOMSchemaService> schemaService, final String basePath) {
29         super(schemaService);
30         this.basePath = basePath;
31     }
32
33     @Override
34     public String getDataStorePath(final String dataStore, final String context) {
35         return "/" + basePath + "/" + dataStore + context;
36     }
37
38     @Override
39     public String getContent(final String dataStore) {
40         return "";
41     }
42
43     @Override
44     protected ListPathBuilder newListPathBuilder() {
45         return key -> "/{" + key + "}";
46     }
47
48     @Override
49     protected void appendPathKeyValue(StringBuilder builder, Object value) {
50         builder.append(value).append('/');
51     }
52 }