BUG-4688: Rework SchemaContext module lookups
[yangtools.git] / yang / yang-model-api / src / main / java / org / opendaylight / yangtools / yang / model / api / ModuleIdentifier.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.yangtools.yang.model.api;
9
10 import java.util.Date;
11 import java.util.Optional;
12 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
13
14 /**
15  * Module identifier. This "identifier" is deprecated and is to be removed in 2.0.0.
16  * @author Robert Varga
17  *
18  * @deprecated Use {@link SourceIdentifier} instead.
19  */
20 @Deprecated
21 public interface ModuleIdentifier {
22     /**
23      * Returns the name of the module which is specified as argument of YANG
24      * {@link Module <b><font color="#FF0000">module</font></b>} keyword.
25      *
26      * @return string with the name of the module
27      */
28     String getName();
29
30     /**
31      * Returns the revision date for the module.
32      *
33      * @return date of the module revision which is specified as argument of
34      *         YANG {@link Module <b><font color="#339900">revison</font></b>}
35      *         keyword
36      */
37     // FIXME: BUG-4688: should return Optional<Revision>
38     Optional<Date> getRevision();
39
40     static int compareRevisions(final Optional<Date> first, final Optional<Date> second) {
41         if (!first.isPresent()) {
42             return second.isPresent() ? -1 : 0;
43         }
44         return second.isPresent() ? first.get().compareTo(second.get()) : 1;
45     }
46 }