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.yangtools.yang.data.codec.gson.helpers;
10 import com.google.common.annotations.Beta;
12 import java.util.ArrayList;
13 import java.util.Collections;
14 import java.util.List;
17 * This class is implementation-internal and subject to change. Please do not use it.
20 public final class IdentityValuesDTO {
22 private final List<IdentityValue> elementData = new ArrayList<>();
23 private final String originValue;
25 public IdentityValuesDTO(final String namespace, final String value, final String prefix, final String originValue) {
26 elementData.add(new IdentityValue(namespace, value, prefix));
27 this.originValue = originValue;
30 public IdentityValuesDTO(final String originValue) {
31 this.originValue = originValue;
34 public IdentityValuesDTO() {
38 public void add(final String namespace, final String value, final String prefix) {
39 elementData.add(new IdentityValue(namespace, value, prefix));
42 public void add(final IdentityValue identityValue) {
43 elementData.add(identityValue);
46 public List<IdentityValue> getValuesWithNamespaces() {
47 return Collections.unmodifiableList(elementData);
51 public String toString() {
52 return elementData.toString();
55 public String getOriginValue() {
59 public static final class IdentityValue {
61 private final String namespace;
62 private final String value;
63 private final String prefix;
64 private List<Predicate> predicates;
66 public IdentityValue(final String namespace, final String value, final String prefix) {
67 this.namespace = namespace;
72 public String getNamespace() {
76 public String getValue() {
80 public String getPrefix() {
84 public List<Predicate> getPredicates() {
85 if (predicates == null) {
86 return Collections.emptyList();
88 return Collections.unmodifiableList(predicates);
91 public void setPredicates(final List<Predicate> predicates) {
92 this.predicates = predicates;
96 public String toString() {
97 StringBuilder sb = new StringBuilder();
98 if (namespace != null) {
101 if (prefix != null) {
102 sb.append("(").append(prefix).append(")");
105 sb.append(" - ").append(value);
107 if (predicates != null && !predicates.isEmpty()) {
108 for (Predicate predicate : predicates) {
110 predicate.toString();
114 return sb.toString();
119 public static final class Predicate {
121 private final IdentityValue name;
122 private final String value;
124 public Predicate(final IdentityValue name, final String value) {
130 public IdentityValue getName() {
134 public String getValue() {
139 public String toString() {
140 StringBuilder sb = new StringBuilder();
142 sb.append(name.toString());
145 sb.append("=").append(value);
147 return sb.toString();
150 public boolean isLeafList() {
151 return name == null ? true : false;