Fix occasional NPEs in Connection manager
[controller.git] / opendaylight / md-sal / sal-dom-demo / src / main / java / org / opendaylight / controller / sal / demo / DemoUtils.java
1 /*
2  * Copyright (c) 2013 Cisco 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.controller.sal.demo;
9
10 import java.net.URI;
11 import java.net.URISyntaxException;
12 import java.util.Date;
13
14 import org.opendaylight.controller.yang.common.QName;
15 import org.opendaylight.controller.yang.data.api.Node;
16 import org.opendaylight.controller.yang.data.util.Nodes;
17
18
19 public class DemoUtils {
20
21     public static final URI namespace = uri("urn:cisco:prototype:sal:demo");
22     public static final Date revision = new Date();
23
24     public static final QName alertNotification = qName("alert");
25     public static final QName changeNotification = qName("change");
26
27     public static final QName contentNodeName = qName("content");
28
29     public static URI uri(String str) {
30         try {
31             return new URI(str);
32         } catch (URISyntaxException e) {
33             throw new IllegalArgumentException(e);
34         }
35     }
36
37     public static QName qName(String str) {
38         return new QName(namespace, revision, str);
39     }
40
41     public static Node<?> contentNode(String content) {
42         return Nodes.leafNode(contentNodeName, content);
43     }
44 }