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

ljacqu / wordeval / 14603510580

22 Apr 2025 07:59PM UTC coverage: 60.152% (+0.3%) from 59.867%
14603510580

push

github

ljacqu
Hunspell: Parse needaffix class and continuation classes

344 of 676 branches covered (50.89%)

67 of 93 new or added lines in 5 files covered. (72.04%)

1 existing line in 1 file now uncovered.

951 of 1581 relevant lines covered (60.15%)

3.37 hits per line

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

81.82
/src/main/java/ch/jalu/wordeval/dictionary/hunspell/AffixClass.java
1
package ch.jalu.wordeval.dictionary.hunspell;
2

3
import ch.jalu.wordeval.dictionary.hunspell.condition.AffixCondition;
4
import lombok.AllArgsConstructor;
5
import lombok.Getter;
6
import lombok.NoArgsConstructor;
7
import lombok.RequiredArgsConstructor;
8
import lombok.Setter;
9
import org.apache.commons.lang3.StringUtils;
10

11
import java.util.ArrayList;
12
import java.util.List;
13

14
/**
15
 * A Hunspell affix class has one or multiple rules for adding a prefix or suffix to a word.
16
 */
17
@Getter
18
@Setter
19
@NoArgsConstructor
20
@AllArgsConstructor
21
public class AffixClass {
22

23
  private AffixType type;
24
  private String flag;
25
  private boolean crossProduct;
26
  private final List<AffixRule> rules = new ArrayList<>();
27

28
  @Getter
29
  @RequiredArgsConstructor
30
  public abstract static class AffixRule {
31

32
    protected final String strip;
33
    private final List<String> continuationClasses;
34
    private final AffixCondition condition;
35

36
    public boolean matches(String word) {
37
      return condition.matches(word);
5✔
38
    }
39

40
    public abstract String applyRule(String word);
41

42
    public abstract AffixType getType();
43

44
  }
45

46
  @Getter
47
  public static class SuffixRule extends AffixRule {
48

49
    private final String suffix;
50

51
    public SuffixRule(String strip, String suffix, List<String> continuationClasses, AffixCondition condition) {
52
      super(strip, continuationClasses, condition);
5✔
53
      this.suffix = suffix;
3✔
54
    }
1✔
55

56
    @Override
57
    public String applyRule(String word) {
58
      return StringUtils.removeEnd(word, strip) + suffix;
8✔
59
    }
60

61
    @Override
62
    public AffixType getType() {
NEW
63
      return AffixType.SFX;
×
64
    }
65
  }
66

67
  @Getter
68
  public static class PrefixRule extends AffixRule {
69

70
    private final String prefix;
71

72
    public PrefixRule(String strip, String prefix, List<String> continuationClasses, AffixCondition condition) {
73
      super(strip, continuationClasses, condition);
5✔
74
      this.prefix = prefix;
3✔
75
    }
1✔
76

77
    @Override
78
    public String applyRule(String word) {
79
      return prefix + StringUtils.removeStart(word, strip);
8✔
80
    }
81

82
    @Override
83
    public AffixType getType() {
NEW
84
      return AffixType.PFX;
×
85
    }
86
  }
87
}
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

© 2026 Coveralls, Inc