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