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  
22  package org.opencastproject.kernel.bundleinfo;
23  
24  import static org.opencastproject.util.data.Option.none;
25  
26  import org.opencastproject.util.data.Option;
27  
28  public class BundleInfoImpl implements BundleInfo {
29    private final String host;
30    private final String bundleSymbolicName;
31    private final long bundleId;
32    private final String bundleVersion;
33    private final Option<String> buildNumber;
34    private final Option<String> dbSchemaVersion;
35    private final BundleVersion version;
36  
37    public BundleInfoImpl(String host, String bundleSymbolicName, long bundleId, String bundleVersion,
38            Option<String> buildNumber, Option<String> dbSchemaVersion) {
39      this.host = host;
40      this.bundleSymbolicName = bundleSymbolicName;
41      this.bundleId = bundleId;
42      this.bundleVersion = bundleVersion;
43      this.buildNumber = buildNumber;
44      this.dbSchemaVersion = dbSchemaVersion;
45      this.version = new BundleVersion(bundleVersion, buildNumber);
46    }
47  
48    public static BundleInfo bundleInfo(String host, String bundleSymbolicName, long bundleId, String bundleVersion,
49            Option<String> buildNumber) {
50      return new BundleInfoImpl(host, bundleSymbolicName, bundleId, bundleVersion, buildNumber, none(""));
51    }
52  
53    public static BundleInfo bundleInfo(String host, String bundleSymbolicName, long bundleId, String bundleVersion,
54            Option<String> buildNumber, Option<String> dbSchemaVersion) {
55      return new BundleInfoImpl(host, bundleSymbolicName, bundleId, bundleVersion, buildNumber, dbSchemaVersion);
56    }
57  
58    @Override
59    public String getHost() {
60      return host;
61    }
62  
63    @Override
64    public String getBundleSymbolicName() {
65      return bundleSymbolicName;
66    }
67  
68    @Override
69    public long getBundleId() {
70      return bundleId;
71    }
72  
73    @Override
74    public String getBundleVersion() {
75      return bundleVersion;
76    }
77  
78    @Override
79    public Option<String> getBuildNumber() {
80      return buildNumber;
81    }
82  
83    @Override
84    public BundleVersion getVersion() {
85      return version;
86    }
87  }