2 * Copyright (c) 2014 Cisco Systems, Inc. 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.controller.sal.restconf.impl;
10 import java.util.ArrayList;
11 import java.util.Collections;
12 import java.util.List;
14 public final class IdentityValuesDTO {
16 private final List<IdentityValue> elementData = new ArrayList<>();
18 public IdentityValuesDTO(String namespace, String value, String prefix) {
19 elementData.add(new IdentityValue(namespace, value, prefix));
22 public IdentityValuesDTO() {
26 public void add(String namespace, String value, String prefix) {
27 elementData.add(new IdentityValue(namespace, value, prefix));
30 public void add(IdentityValue identityValue) {
31 elementData.add(identityValue);
35 public List<IdentityValue> getValuesWithNamespaces() {
36 return Collections.unmodifiableList(elementData);
40 public String toString() {
41 return elementData.toString();
44 public static final class IdentityValue {
46 private final String namespace;
47 private final String value;
48 private final String prefix;
49 private List<Predicate> predicates;
51 public IdentityValue(String namespace, String value, String prefix) {
52 this.namespace = namespace;
57 public String getNamespace() {
61 public String getValue() {
65 public String getPrefix() {
69 public List<Predicate> getPredicates() {
70 if (predicates == null) {
71 return Collections.emptyList();
73 return Collections.unmodifiableList(predicates);
76 public void setPredicates(List<Predicate> predicates) {
77 this.predicates = predicates;
81 public String toString() {
82 StringBuilder sb = new StringBuilder();
83 if (namespace != null) {
87 sb.append("(").append(prefix).append(")");
90 sb.append(" - ").append(value);
92 if (predicates != null && !predicates.isEmpty()) {
93 for (Predicate predicate : predicates) {
104 public static final class Predicate {
106 private final IdentityValue name;
107 private final String value;
109 public Predicate(IdentityValue name, String value) {
115 public IdentityValue getName() {
119 public String getValue() {
124 public String toString() {
125 StringBuilder sb = new StringBuilder();
127 sb.append(name.toString());
130 sb.append("=").append(value);
132 return sb.toString();
135 public boolean isLeafList() {
136 return name == null ? true : false;