Migrate entity ownership to JDT annotations
[mdsal.git] / entityownership / mdsal-eos-dom-api / src / main / java / org / opendaylight / mdsal / eos / dom / api / DOMEntity.java
1 /*
2  * Copyright (c) 2015 Brocade Communications Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.mdsal.eos.dom.api;
9
10 import com.google.common.annotations.Beta;
11 import com.google.common.base.Preconditions;
12 import org.eclipse.jdt.annotation.NonNull;
13 import org.opendaylight.mdsal.eos.common.api.GenericEntity;
14 import org.opendaylight.yangtools.yang.common.QName;
15 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
16
17 /**
18  * Binding version of {@link GenericEntity}.
19  *
20  * @author Thomas Pantelis
21  */
22 @Beta
23 public class DOMEntity extends GenericEntity<YangInstanceIdentifier> {
24     private static final long serialVersionUID = 1L;
25
26     static final QName ENTITY = QName.create(
27             "urn:opendaylight:params:xml:ns:yang:mdsal:core:general-entity", "2015-09-30", "entity").intern();
28     static final QName ENTITY_NAME = QName.create(ENTITY, "name").intern();
29
30     /** Constructs an instance.
31      *
32      * @param type the entity type
33      * @param id the entity id.
34      */
35     public DOMEntity(final @NonNull String type, final @NonNull YangInstanceIdentifier id) {
36         super(type, id);
37     }
38
39     /**
40      * Construct an Entity with an with a name. The general-entity schema is used to construct the
41      * YangInstanceIdentifier.
42      *
43      * @param type the type of the entity
44      * @param entityName the name of the entity used to construct a general-entity YangInstanceIdentifier
45      */
46     public DOMEntity(final @NonNull String type, final @NonNull String entityName) {
47         super(type, YangInstanceIdentifier.builder().node(ENTITY).nodeWithKey(ENTITY, ENTITY_NAME,
48                 Preconditions.checkNotNull(entityName, "entityName should not be null")).build());
49     }
50 }