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.license; 20 21 /** 22 * The definition of the license family. 23 */ 24 public interface ILicenseFamily extends Comparable<ILicenseFamily> { 25 /** 26 * @return the license family name. 27 */ 28 String getFamilyName(); 29 30 /** 31 * @return the license family category. 32 */ 33 String getFamilyCategory(); 34 35 /** 36 * @return A builder for an ILicenseFamily. 37 */ 38 static ILicenseFamily.Builder builder() { 39 return new ILicenseFamilyBuilder(); 40 } 41 42 /** 43 * Convert a potential category string into a category string of exactly 5 characters either by truncating 44 * the string or appending spaces as necessary. 45 * @param cat the string to convert. 46 * @return a string of exactly 5 characters. 47 */ 48 static String makeCategory(String cat) { 49 return cat == null ? " " : cat.concat(" ").substring(0, 5); 50 } 51 52 @Override 53 default int compareTo(ILicenseFamily other) { 54 return getFamilyCategory().compareTo(other.getFamilyCategory()); 55 } 56 57 /** 58 * The definition of an ILicenseFamily builder. 59 */ 60 interface Builder { 61 /** 62 * Sets the license family category. Will trim or extends the string with spaces to ensure that it is 63 * exactly 5 characters. 64 * @param licenseFamilyCategory the category string 65 * @return this builder for chaining. 66 */ 67 Builder setLicenseFamilyCategory(String licenseFamilyCategory); 68 69 /** 70 * Sets the license family name. 71 * @param licenseFamilyName the name string 72 * @return this builder for chaining. 73 */ 74 Builder setLicenseFamilyName(String licenseFamilyName); 75 76 /** 77 * Gets the category that this builder is building. 78 * @return the category that this builder is building. 79 */ 80 String getCategory(); 81 82 /** 83 * @return a new ILicenseFamily instance. 84 */ 85 ILicenseFamily build(); 86 } 87 }