• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*******************************************************************************
2  * Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  *    Evgeny Mandrikov - initial API and implementation
10  *    Kyle Lieber - implementation of CheckMojo
11  *    Marc Hoffmann - redesign using report APIs
12  *
13  *******************************************************************************/
14 package org.jacoco.maven;
15 
16 import java.util.List;
17 
18 import org.codehaus.plexus.util.StringUtils;
19 import org.jacoco.core.analysis.ICoverageNode.ElementType;
20 import org.jacoco.report.check.Limit;
21 import org.jacoco.report.check.Rule;
22 
23 /**
24  * Wrapper for {@link Rule} objects to allow Maven style includes/excludes lists
25  *
26  */
27 public class RuleConfiguration {
28 
29 	final Rule rule;
30 
31 	/**
32 	 * Create a new configuration instance.
33 	 */
RuleConfiguration()34 	public RuleConfiguration() {
35 		rule = new Rule();
36 	}
37 
38 	/**
39 	 * @param element
40 	 *            element type this rule applies to
41 	 * TODO: use ElementType directly once Maven 3 is required.
42 	 */
setElement(final String element)43 	public void setElement(final String element) {
44 		rule.setElement(ElementType.valueOf(element));
45 	}
46 
47 	/**
48 	 * @param includes
49 	 *            includes patterns
50 	 */
setIncludes(final List<String> includes)51 	public void setIncludes(final List<String> includes) {
52 		rule.setIncludes(StringUtils.join(includes.iterator(), ":"));
53 	}
54 
55 	/**
56 	 *
57 	 * @param excludes
58 	 *            excludes patterns
59 	 */
setExcludes(final List<String> excludes)60 	public void setExcludes(final List<String> excludes) {
61 		rule.setExcludes(StringUtils.join(excludes.iterator(), ":"));
62 	}
63 
64 	/**
65 	 * @param limits
66 	 *            list of {@link Limit}s configured for this rule
67 	 */
setLimits(final List<Limit> limits)68 	public void setLimits(final List<Limit> limits) {
69 		rule.setLimits(limits);
70 	}
71 
72 }
73