• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

git-commit-id / git-commit-id-maven-plugin / #219

04 Dec 2023 07:24PM CUT coverage: 71.134%. Remained the same
#219

push

web-flow
Merge pull request #676 from git-commit-id/dependabot/maven/org.apache.maven.plugins-maven-javadoc-plugin-3.6.3

Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.6.2 to 3.6.3

276 of 388 relevant lines covered (71.13%)

0.71 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

50.0
/src/main/java/pl/project13/maven/git/TransformationRule.java
1
/*
2
 * This file is part of git-commit-id-maven-plugin by Konrad 'ktoso' Malawski <konrad.malawski@java.pl>
3
 *
4
 * git-commit-id-maven-plugin is free software: you can redistribute it and/or modify
5
 * it under the terms of the GNU Lesser General Public License as published by
6
 * the Free Software Foundation, either version 3 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * git-commit-id-maven-plugin 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
12
 * GNU General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Lesser General Public License
15
 * along with git-commit-id-maven-plugin.  If not, see <http://www.gnu.org/licenses/>.
16
 */
17

18
package pl.project13.maven.git;
19

20
import org.apache.maven.plugins.annotations.Parameter;
21

22
/**
23
 * This class represents a specific transformation logic the user wants to perform.
24
 *
25
 * Each {@code transformationRule} consist of
26
 * two required fields {@code apply} and {@code action}.
27
 * The {@code apply}-tag controls when the rule should
28
 * be applied and can be set to {@code BEFORE} to have the rule being applied before or it can be
29
 * set to {@code AFTER} to have the rule being applied after the replacement.
30
 * The {@code action}-tag determines the string conversion rule that should be applied.
31
 *
32
 * Refer to https://github.com/git-commit-id/git-commit-id-maven-plugin/issues/317 for a use-case.
33
 */
34
public class TransformationRule {
35
  /**
36
   * Determines when the transformation should be taken place.
37
   * Currently supported is
38
   *   - BEFORE_REGEX
39
   *   - AFTER_REGEX
40
   */
41
  @Parameter(required = true)
42
  private String apply;
43

44
  private ApplyEnum applyRule;
45

46
  protected enum ApplyEnum {
1✔
47
    /**
48
     * have the rule being applied before the replacement
49
     */
50
    BEFORE,
1✔
51
    /**
52
     * have the rule being applied after the replacement
53
     */
54
    AFTER,
1✔
55
    ;
56
  }
57

58
  /**
59
   * Determines the action that should be performed as transformation.
60
   * Currently supported is
61
   *   - LOWER_CASE
62
   *   - UPPER_CASE
63
   */
64
  @Parameter(required = true)
65
  private String action;
66

67
  private ActionEnum actionRule;
68

69
  protected enum ActionEnum {
1✔
70
    LOWER_CASE {
1✔
71
      @Override
72
      protected String perform(String input) {
73
        if (input != null) {
1✔
74
          return input.toLowerCase();
1✔
75
        }
76
        return input;
×
77
      }
78
    },
79
    UPPER_CASE {
1✔
80
      @Override
81
      protected String perform(String input) {
82
        if (input != null) {
1✔
83
          return input.toUpperCase();
1✔
84
        }
85
        return null;
×
86
      }
87
    },
88
    ;
89
    protected abstract String perform(String input);
90
  }
91

92
  public TransformationRule() {
×
93
  }
×
94

95
  public TransformationRule(String apply, String action) {
96
    this(ApplyEnum.valueOf(apply), ActionEnum.valueOf(action));
×
97
    this.apply = apply;
×
98
    this.action = action;
×
99
  }
×
100

101
  protected TransformationRule(ApplyEnum applyRule, ActionEnum actionRule) {
1✔
102
    this.applyRule = applyRule;
1✔
103
    this.actionRule = actionRule;
1✔
104
  }
1✔
105

106
  public String getApply() {
107
    return apply;
×
108
  }
109

110
  public void setApply(String apply) {
111
    this.applyRule = ApplyEnum.valueOf(apply);
×
112
    this.apply = apply;
×
113
  }
×
114

115
  public ApplyEnum getApplyRule() {
116
    if (applyRule == null) {
1✔
117
      throw new IllegalStateException("The parameter 'apply' for TransformationRule is missing or invalid");
×
118
    }
119
    return applyRule;
1✔
120
  }
121

122
  public String getAction() {
123
    return action;
×
124
  }
125

126
  public void setAction(String action) {
127
    this.actionRule = ActionEnum.valueOf(action);
×
128
    this.action = action;
×
129
  }
×
130

131
  public ActionEnum getActionRule() {
132
    if (actionRule == null) {
1✔
133
      throw new IllegalStateException("The parameter 'action' for TransformationRule is missing or invalid");
×
134
    }
135
    return actionRule;
1✔
136
  }
137
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc