2 * Copyright (c) 2013 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.model.util;
10 import java.util.Collections;
11 import java.util.List;
13 import org.opendaylight.yangtools.yang.common.QName;
14 import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
15 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
16 import org.opendaylight.yangtools.yang.model.api.Status;
17 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
18 import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition;
20 import com.google.common.base.Preconditions;
23 * The <code>default</code> implementation of Identityref Type Definition
26 * @see IdentityrefTypeDefinition
28 public final class IdentityrefType implements IdentityrefTypeDefinition {
29 private static final QName NAME = BaseTypes.IDENTITYREF_QNAME;
30 private final SchemaPath path;
31 private static final String DESCRIPTION = "The identityref type is used to reference an existing identity.";
32 private static final String REFERENCE = "https://tools.ietf.org/html/rfc6020#section-9.10";
33 private final IdentitySchemaNode identity;
34 private static final String UNITS = "";
37 * Constructs new {@link IdentityrefTypeDefinition} definition.
43 public IdentityrefType(final IdentitySchemaNode identity, final SchemaPath schemaPath) {
44 this(schemaPath,identity);
47 private IdentityrefType(final SchemaPath path, final IdentitySchemaNode baseIdentity) {
48 this.path = Preconditions.checkNotNull(path, "Path must be specified");
49 this.identity = Preconditions.checkNotNull(baseIdentity,"baseIdentity must be specified.");
54 * Constructs new {@link IdentityrefTypeDefinition} definition.
56 * @param path Path to the definition.
57 * @param baseIdentity Base Identity, all derived identities are valid arguments for instance of this type.
58 * @return New identityref definition.
60 public static IdentityrefType create(final SchemaPath path, final IdentitySchemaNode baseIdentity) {
61 return new IdentityrefType(path, baseIdentity);
65 public String getUnits() {
70 public Object getDefaultValue() {
75 public QName getQName() {
80 public SchemaPath getPath() {
85 public String getDescription() {
90 public String getReference() {
95 public Status getStatus() {
96 return Status.CURRENT;
100 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
101 return Collections.emptyList();
105 public IdentitySchemaNode getIdentity() {
110 public IdentityrefTypeDefinition getBaseType() {
115 public String toString() {
116 return "identityref " + identity.getQName().getLocalName();