View Javadoc
1   package org.apache.maven.index.creator;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0    
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.util.ArrayList;
23  import java.util.Collections;
24  import java.util.List;
25  
26  import org.apache.maven.index.context.IndexCreator;
27  import org.slf4j.Logger;
28  import org.slf4j.LoggerFactory;
29  
30  /**
31   * An abstract base class for {@link IndexCreator} implementations.
32   * 
33   * @author Jason van Zyl
34   */
35  public abstract class AbstractIndexCreator
36      implements IndexCreator
37  {
38  
39      private final Logger logger = LoggerFactory.getLogger( getClass() );
40  
41      protected Logger getLogger()
42      {
43          return logger;
44      }
45  
46      private final String id;
47  
48      private final List<String> creatorDependencies;
49  
50      protected AbstractIndexCreator( final String id )
51      {
52          this( id, null );
53      }
54  
55      protected AbstractIndexCreator( final String id, final List<String> creatorDependencies )
56      {
57          this.id = id;
58  
59          final ArrayList<String> deps = new ArrayList<String>();
60  
61          if ( creatorDependencies != null && !creatorDependencies.isEmpty() )
62          {
63              deps.addAll( creatorDependencies );
64          }
65  
66          this.creatorDependencies = Collections.unmodifiableList( deps );
67      }
68  
69      public String getId()
70      {
71          return id;
72      }
73  
74      public List<String> getCreatorDependencies()
75      {
76          return creatorDependencies;
77      }
78  
79      public static String bos( boolean b )
80      {
81          return b ? "1" : "0";
82      }
83  
84      public static boolean sob( String b )
85      {
86          return b.equals( "1" );
87      }
88  }