View Javadoc
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.license;
20  
21  import java.util.Arrays;
22  
23  import org.apache.rat.configuration.builders.AbstractBuilder;
24  import org.apache.rat.configuration.builders.AnyBuilder;
25  import org.apache.rat.configuration.builders.TextBuilder;
26  import org.apache.rat.license.ILicense;
27  
28  
29  /**
30   * @since Rat 0.8
31   * @deprecated Use new configuration options
32   */
33  @Deprecated // Since 0.16
34  public class SimplePatternBasedLicense  extends BaseLicense {
35      private String[] patterns;
36  
37  
38      public SimplePatternBasedLicense() {
39          
40      }
41  
42      
43      public String[] getPatterns() {
44          return patterns;
45      }
46  
47      public void setPatterns(String[] pPatterns) {
48          patterns = pPatterns;
49      }
50  
51      private AbstractBuilder getMatcher() {
52          if (patterns.length == 1) {
53              return new TextBuilder().setText(patterns[0]);
54          } else {
55              AnyBuilder any = new AnyBuilder();
56              Arrays.stream(patterns).map(s -> new TextBuilder().setText(s)).forEach(b-> any.add(b));
57              return any;
58          }
59      }
60  
61      @Override
62      public ILicense.Builder getLicense() {
63          return ILicense.builder()
64          .setLicenseFamilyCategory(getLicenseFamilyCategory())
65          .setName(getLicenseFamilyName())
66          .setMatcher( getMatcher() )
67          .setNotes(getNotes());
68      }
69  }