Bump versions to 4.0.0-SNAPSHOT
[netconf.git] / restconf / restconf-nb-bierman02 / src / main / java / org / opendaylight / yang / gen / v1 / urn / ietf / params / xml / ns / yang / ietf / restconf / rev131019 / restconf / restconf / modules / RevisionBuilder.java
1 /*
2  * Copyright (c) 2014 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.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.rev131019.restconf.restconf.modules;
9
10 import java.util.regex.Pattern;
11
12 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.rev131019.RevisionIdentifier;
13 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.rev131019.restconf.restconf.modules.Module.Revision;
14
15 /**
16 **/
17 public class RevisionBuilder {
18
19     /**
20      * Defines the pattern for revisions. NOTE: This pattern will likely be
21      * updated in future versions of the ietf and should be adjusted accordingly
22      */
23     private static final Pattern REVISION_PATTERN = Pattern.compile("\\d{4}-\\d{2}-\\d{2}");
24
25     public static Revision getDefaultInstance(String defaultValue) {
26
27         if (defaultValue != null) {
28             if (REVISION_PATTERN.matcher(defaultValue).matches()) {
29                 RevisionIdentifier id = new RevisionIdentifier(defaultValue);
30                 return new Revision(id);
31             }
32             if (defaultValue.isEmpty()) {
33                 return new Revision(defaultValue);
34             }
35         }
36
37         throw new IllegalArgumentException("Cannot create Revision from " + defaultValue
38                 + ". Default value does not match pattern " + REVISION_PATTERN.pattern()
39                 + " or empty string.");
40     }
41
42 }