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<>();
17 private final String originValue;
19 public IdentityValuesDTO(String namespace, String value, String prefix, String originValue) {
20 elementData.add(new IdentityValue(namespace, value, prefix));
21 this.originValue = originValue;
24 public IdentityValuesDTO(String originValue) {
25 this.originValue = originValue;
28 public IdentityValuesDTO() {
32 public void add(String namespace, String value, String prefix) {
33 elementData.add(new IdentityValue(namespace, value, prefix));
36 public void add(IdentityValue identityValue) {
37 elementData.add(identityValue);
40 public List<IdentityValue> getValuesWithNamespaces() {
41 return Collections.unmodifiableList(elementData);
45 public String toString() {
46 return elementData.toString();
49 public String getOriginValue() {
53 public static final class IdentityValue {
55 private final String namespace;
56 private final String value;
57 private final String prefix;
58 private List<Predicate> predicates;
60 public IdentityValue(String namespace, String value, String prefix) {
61 this.namespace = namespace;
66 public String getNamespace() {
70 public String getValue() {
74 public String getPrefix() {
78 public List<Predicate> getPredicates() {
79 if (predicates == null) {
80 return Collections.emptyList();
82 return Collections.unmodifiableList(predicates);
85 public void setPredicates(List<Predicate> predicates) {
86 this.predicates = predicates;
90 public String toString() {
91 StringBuilder sb = new StringBuilder();
92 if (namespace != null) {
96 sb.append("(").append(prefix).append(")");
99 sb.append(" - ").append(value);
101 if (predicates != null && !predicates.isEmpty()) {
102 for (Predicate predicate : predicates) {
104 predicate.toString();
108 return sb.toString();
113 public static final class Predicate {
115 private final IdentityValue name;
116 private final String value;
118 public Predicate(IdentityValue name, String value) {
124 public IdentityValue getName() {
128 public String getValue() {
133 public String toString() {
134 StringBuilder sb = new StringBuilder();
136 sb.append(name.toString());
139 sb.append("=").append(value);
141 return sb.toString();
144 public boolean isLeafList() {
145 return name == null ? true : false;