1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one *
3 * or more contributor license agreements. See the NOTICE file *
4 * distributed with this work for additional information *
5 * regarding copyright ownership. The ASF licenses this file *
6 * to you under the Apache License, Version 2.0 (the *
7 * "License"); you may not use this file except in compliance *
8 * with the License. You may obtain a copy of the License at *
9 * *
10 * http://www.apache.org/licenses/LICENSE-2.0 *
11 * *
12 * Unless required by applicable law or agreed to in writing, *
13 * software distributed under the License is distributed on an *
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
15 * KIND, either express or implied. See the License for the *
16 * specific language governing permissions and limitations *
17 * under the License. *
18 */
19 package org.apache.rat.analysis;
20
21 import org.apache.rat.license.ILicense;
22 import org.apache.rat.license.ILicenseFamily;
23 import org.apache.rat.license.ILicenseFamilyBuilder;
24
25 import java.util.Objects;
26
27 /**
28 * An ILicense implementation that represents an unknown license.
29 * <p>
30 * The UnknownLicense is used during processing to report that a document
31 * license can not be determined.
32 * </p>
33 */
34 public final class UnknownLicense implements ILicense {
35
36 /**
37 * The single instance of this class.
38 */
39 public static final UnknownLicense INSTANCE = new UnknownLicense();
40
41 private final ILicenseFamily family;
42
43 /**
44 * Do not allow other constructions.
45 */
46 private UnknownLicense() {
47 family = new ILicenseFamilyBuilder().setLicenseFamilyCategory(ILicenseFamily.UNKNOWN_CATEGORY)
48 .setLicenseFamilyName("Unknown license").build();
49 }
50
51 @Override
52 public String getId() {
53 return ILicenseFamily.UNKNOWN_CATEGORY;
54 }
55
56 @Override
57 public void reset() {
58 // do nothing
59 }
60
61 @Override
62 public boolean matches(final IHeaders headers) {
63 return false;
64 }
65
66 @Override
67 public boolean equals(Object o) {
68 return super.equals(o);
69 }
70
71 @Override
72 public int hashCode() {
73 return Objects.hashCode(ILicenseFamily.UNKNOWN_CATEGORY);
74 }
75
76 @Override
77 public ILicenseFamily getLicenseFamily() {
78 return family;
79 }
80
81 @Override
82 public String getNote() {
83 return null;
84 }
85
86 @Override
87 public String getName() {
88 return family.getFamilyName();
89 }
90
91 @Override
92 public IHeaderMatcher getMatcher() {
93 return null;
94 }
95 }