Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
EnforcerRule |
|
| 1.0;1 |
1 | package org.apache.maven.enforcer.rule.api; | |
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 | /** | |
23 | * Interface to be implemented by any rules executed by the enforcer. | |
24 | * | |
25 | * @author <a href="mailto:brianf@apache.org">Brian Fox</a> | |
26 | * @version $Id: EnforcerRule.java 987781 2010-08-21 16:23:40Z dennisl $ | |
27 | */ | |
28 | public interface EnforcerRule | |
29 | { | |
30 | ||
31 | /** | |
32 | * This is the interface into the rule. This method should throw an exception | |
33 | * containing a reason message if the rule fails the check. The plugin will | |
34 | * then decide based on the fail flag if it should stop or just log the | |
35 | * message as a warning. | |
36 | * | |
37 | * @param helper The helper provides access to the log, MavenSession and has | |
38 | * helpers to get common components. It is also able to lookup components | |
39 | * by class name. | |
40 | * | |
41 | * @throws EnforcerRuleException the enforcer rule exception | |
42 | */ | |
43 | void execute( EnforcerRuleHelper helper ) | |
44 | throws EnforcerRuleException; | |
45 | ||
46 | /** | |
47 | * This method tells the enforcer if the rule results may be cached. If the result is true, | |
48 | * the results will be remembered for future executions in the same build (ie children). Subsequent | |
49 | * iterations of the rule will be queried to see if they are also cacheable. This will allow the rule to be | |
50 | * uncached further down the tree if needed. | |
51 | * | |
52 | * @return <code>true</code> if rule is cacheable | |
53 | */ | |
54 | boolean isCacheable(); | |
55 | ||
56 | /** | |
57 | * Checks if cached result is valid. | |
58 | * | |
59 | * @param cachedRule the last cached instance of the rule. This is to be used by the rule to | |
60 | * potentially determine if the results are still valid (ie if the configuration has been overridden) | |
61 | * | |
62 | * @return <code>true</code> if the stored results are valid for the same id. | |
63 | */ | |
64 | boolean isResultValid( EnforcerRule cachedRule ); | |
65 | ||
66 | /** | |
67 | * If the rule is to be cached, this id is used as part of the key. This can allow rules to take parameters | |
68 | * that allow multiple results of the same rule to be cached. | |
69 | * | |
70 | * @return id to be used by the enforcer to determine uniqueness of cache results. The ids only need to be unique | |
71 | * within a given rule implementation as the full key will be [classname]-[id] | |
72 | */ | |
73 | String getCacheId(); | |
74 | ||
75 | } |