package org.opendaylight.netconf.sal.rest.doc.mountpoints;
import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
private static final String DATASTORES_REVISION = "-";
private static final String DATASTORES_LABEL = "Datastores";
- private static final String RESTCONF_DRAFT = "18";
+ private static final AtomicReference<MountPointSwagger> SELF_REF = new AtomicReference<>();
private DOMMountPointService mountService;
private final Map<YangInstanceIdentifier, Long> instanceIdToLongId =
new TreeMap<>((o1, o2) -> o1.toString().compareToIgnoreCase(o2.toString()));
private final Map<Long, YangInstanceIdentifier> longIdToInstanceId = new HashMap<>();
+
private final Object lock = new Object();
private final AtomicLong idKey = new AtomicLong(0);
-
- private static final AtomicReference<MountPointSwagger> selfRef = new AtomicReference<>();
private SchemaService globalSchema;
- private static boolean newDraft;
public Map<String, Long> getInstanceIdentifiers() {
+ Preconditions.checkState(globalSchema != null);
final Map<String, Long> urlToId = new HashMap<>();
synchronized (this.lock) {
final SchemaContext context = this.globalSchema.getGlobalContext();
if (arg instanceof YangInstanceIdentifier.NodeIdentifierWithPredicates) {
final NodeIdentifierWithPredicates nodeId = (NodeIdentifierWithPredicates) arg;
for (final Entry<QName, Object> entry : nodeId.getKeyValues().entrySet()) {
- if (newDraft) {
+ if (isNewDraft()) {
builder.deleteCharAt(builder.length() - 1).append("=").append(entry.getValue()).append('/');
} else {
builder.append(entry.getValue()).append('/');
}
private String getYangMountUrl(final YangInstanceIdentifier key) {
+ Preconditions.checkState(globalSchema != null);
final String modName = findModuleName(key, this.globalSchema.getGlobalContext());
return generateUrlPrefixFromInstanceID(key, modName) + "yang-ext:mount";
}
return null;
}
+ Preconditions.checkState(mountService != null);
final Optional<DOMMountPoint> mountPoint = this.mountService.getMountPoint(id);
if (!mountPoint.isPresent()) {
return null;
}
public static MountPointSwagger getInstance() {
- MountPointSwagger swagger = selfRef.get();
+ MountPointSwagger swagger = SELF_REF.get();
if (swagger == null) {
- selfRef.compareAndSet(null, new MountPointSwagger());
- swagger = selfRef.get();
+ SELF_REF.compareAndSet(null, new MountPointSwagger());
+ swagger = SELF_REF.get();
}
- newDraft = false;
+
+ swagger.setDraft(false);
return swagger;
}
public static MountPointSwagger getInstanceDraft18() {
- MountPointSwagger swagger = selfRef.get();
+ MountPointSwagger swagger = SELF_REF.get();
if (swagger == null) {
- selfRef.compareAndSet(null, new MountPointSwagger());
- swagger = selfRef.get();
+ SELF_REF.compareAndSet(null, new MountPointSwagger());
+ swagger = SELF_REF.get();
}
- newDraft = true;
+
+ swagger.setDraft(true);
return swagger;
}
}