View Javadoc
1   /*
2    * (C) Copyright 2013-2014 Nuxeo SA (http://nuxeo.com/) and contributors.
3    *
4    * All rights reserved. This program and the accompanying materials
5    * are made available under the terms of the GNU Lesser General Public License
6    * (LGPL) version 2.1 which accompanies this distribution, and is available at
7    * http://www.gnu.org/licenses/lgpl-2.1.html
8    *
9    * This library is distributed in the hope that it will be useful,
10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12   * Lesser General Public License for more details.
13   *
14   * Contributors:
15   *     Julien Carsique
16   *
17   */
18  
19  package org.nuxeo.build.maven.filter;
20  
21  import org.apache.tools.ant.Project;
22  import org.nuxeo.build.ant.AntClient;
23  import org.nuxeo.build.maven.AntBuildMojo;
24  
25  /**
26   * @since 2.0
27   */
28  public abstract class AbstractFilter implements Filter {
29  
30      /**
31       * For debug purpose: log the fact that the current filter has accepted or
32       * refused the given 'id'
33       *
34       * @return return the same value as the given condition
35       */
36      protected boolean result(boolean condition, String id) {
37          if (AntBuildMojo.getInstance().getLog().isDebugEnabled()) {
38              AntClient.getInstance().log(
39                      "Filtering - " + toString()
40                              + (condition ? " accepted " : " refused ") + id,
41                      Project.MSG_DEBUG);
42          }
43          return condition;
44      }
45  
46  }