X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-rest-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Frestconf%2Fimpl%2FIdentityValuesDTO.java;h=4e797d905739a6b894d2c6a9179b2219af621943;hp=6924fb620f17d21d9734fc4ade3faf1bf9977c67;hb=73c9fecf86aad02761df47fe0cc943af4ea1f2bc;hpb=c541f7868e6e2d654b8080b5426bb12a39bddf11 diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/IdentityValuesDTO.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/IdentityValuesDTO.java index 6924fb620f..4e797d9057 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/IdentityValuesDTO.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/IdentityValuesDTO.java @@ -1,3 +1,10 @@ +/* + * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ package org.opendaylight.controller.sal.restconf.impl; import java.util.ArrayList; @@ -7,24 +14,48 @@ import java.util.List; public final class IdentityValuesDTO { private final List elementData = new ArrayList<>(); + private final String originValue; - public IdentityValuesDTO(String namespace, String value, String prefix) { + public IdentityValuesDTO(String namespace, String value, String prefix, String originValue) { elementData.add(new IdentityValue(namespace, value, prefix)); + this.originValue = originValue; + } + + public IdentityValuesDTO(String originValue) { + this.originValue = originValue; + } + + public IdentityValuesDTO() { + originValue = null; } public void add(String namespace, String value, String prefix) { elementData.add(new IdentityValue(namespace, value, prefix)); } + public void add(IdentityValue identityValue) { + elementData.add(identityValue); + } + public List getValuesWithNamespaces() { return Collections.unmodifiableList(elementData); } + @Override + public String toString() { + return elementData.toString(); + } + + public String getOriginValue() { + return originValue; + } + public static final class IdentityValue { - private String namespace; - private String value; - private String prefix; + private final String namespace; + private final String value; + private final String prefix; + private List predicates; public IdentityValue(String namespace, String value, String prefix) { this.namespace = namespace; @@ -36,24 +67,82 @@ public final class IdentityValuesDTO { return namespace; } - public void setNamespace(String namespace) { - this.namespace = namespace; - } - public String getValue() { return value; } - public void setValue(String value) { + public String getPrefix() { + return prefix; + } + + public List getPredicates() { + if (predicates == null) { + return Collections.emptyList(); + } + return Collections.unmodifiableList(predicates); + } + + public void setPredicates(List predicates) { + this.predicates = predicates; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + if (namespace != null) { + sb.append(namespace); + } + if (prefix != null) { + sb.append("(").append(prefix).append(")"); + } + if (value != null) { + sb.append(" - ").append(value); + } + if (predicates != null && !predicates.isEmpty()) { + for (Predicate predicate : predicates) { + sb.append("["); + predicate.toString(); + sb.append("]"); + } + } + return sb.toString(); + } + + } + + public static final class Predicate { + + private final IdentityValue name; + private final String value; + + public Predicate(IdentityValue name, String value) { + super(); + this.name = name; this.value = value; } - public String getPrefix() { - return prefix; + public IdentityValue getName() { + return name; } - public void setPrefix(String prefix) { - this.prefix = prefix; + public String getValue() { + return value; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + if (name != null) { + sb.append(name.toString()); + } + if (value != null) { + sb.append("=").append(value); + } + return sb.toString(); + } + + public boolean isLeafList() { + return name == null ? true : false; } }