View Javadoc
1   /*
2    * Licensed to The Apereo Foundation under one or more contributor license
3    * agreements. See the NOTICE file distributed with this work for additional
4    * information regarding copyright ownership.
5    *
6    *
7    * The Apereo Foundation licenses this file to you under the Educational
8    * Community License, Version 2.0 (the "License"); you may not use this file
9    * except in compliance with the License. You may obtain a copy of the License
10   * at:
11   *
12   *   http://opensource.org/licenses/ecl2.txt
13   *
14   * Unless required by applicable law or agreed to in writing, software
15   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
17   * License for the specific language governing permissions and limitations under
18   * the License.
19   *
20   */
21  package org.opencastproject.external.common;
22  
23  /** The existing External API versions */
24  public enum ApiVersion {
25  
26    VERSION_1_0_0(1, 0, 0),
27    VERSION_1_1_0(1, 1, 0),
28    VERSION_1_2_0(1, 2, 0),
29    VERSION_1_3_0(1, 3, 0),
30    VERSION_1_4_0(1, 4, 0),
31    VERSION_1_5_0(1, 5, 0),
32    VERSION_1_6_0(1, 6, 0),
33    VERSION_1_7_0(1, 7, 0),
34    VERSION_1_8_0(1, 8, 0),
35    VERSION_1_9_0(1, 9, 0),
36    VERSION_1_10_0(1, 10, 0),
37    VERSION_1_11_0(1, 11, 0);
38  
39  
40    /** The most recent version of the External API */
41    public static final ApiVersion CURRENT_VERSION = VERSION_1_11_0;
42  
43    private int major;
44    private int minor;
45    private int patch;
46  
47    private String versionString;
48  
49    ApiVersion(int major, int minor, int patch) {
50      this.major = major;
51      this.minor = minor;
52      this.patch = patch;
53      versionString = "v" + major + "." + minor + "." + patch;
54    }
55  
56    public boolean isSmallerThan(ApiVersion other) {
57      if (this.major < other.major) return true;
58      if (this.major > other.major) return false;
59      if (this.minor < other.minor) return true;
60      if (this.minor > other.minor) return false;
61      return this.patch < other.patch;
62    }
63  
64    public String toExternalForm() {
65      return versionString;
66    }
67  
68    @Override
69    public String toString() {
70      return toExternalForm();
71    }
72  
73  }