diff options
| author | Benjamin J. Culkin <bjculkin@mix.wvu.edu> | 2017-09-15 15:21:34 -0300 |
|---|---|---|
| committer | Benjamin J. Culkin <bjculkin@mix.wvu.edu> | 2017-09-15 15:21:34 -0300 |
| commit | 46cb1f6c030991d314d0ef1fafa53e53ef3e03c9 (patch) | |
| tree | 35944ecbd4c7e4af3aecc30520dfa76f636cbdb6 /src/main/java/bjc/inflexion/nouns/CategoricalNounInflection.java | |
| parent | eb78499c6f5c991d6abaca766ae0831e411c74af (diff) | |
Format
Diffstat (limited to 'src/main/java/bjc/inflexion/nouns/CategoricalNounInflection.java')
| -rw-r--r-- | src/main/java/bjc/inflexion/nouns/CategoricalNounInflection.java | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/src/main/java/bjc/inflexion/nouns/CategoricalNounInflection.java b/src/main/java/bjc/inflexion/nouns/CategoricalNounInflection.java index 1989596..2651cc5 100644 --- a/src/main/java/bjc/inflexion/nouns/CategoricalNounInflection.java +++ b/src/main/java/bjc/inflexion/nouns/CategoricalNounInflection.java @@ -23,13 +23,14 @@ package bjc.inflexion.nouns; * */ public class CategoricalNounInflection implements NounInflection { - private static final String TOSTRING_FMT = "CategoricalNounInflection [singular=%s, modernPlural=%s," - + " classicalPlural=%s]"; + private static final String TOSTRING_FMT = + "CategoricalNounInflection [singular=%s, modernPlural=%s," + + " classicalPlural=%s]"; private final InflectionAffix singular; - private final InflectionAffix modernPlural; - private final InflectionAffix classicalPlural; + private final InflectionAffix modernPlural; + private final InflectionAffix classicalPlural; /** * Create a new categorical inflection. @@ -43,8 +44,9 @@ public class CategoricalNounInflection implements NounInflection { * @param classiclPlural * The affix for the classical plural. */ - public CategoricalNounInflection(final InflectionAffix singlar, final InflectionAffix modrnPlural, - final InflectionAffix classiclPlural) { + public CategoricalNounInflection(final InflectionAffix singlar, + final InflectionAffix modrnPlural, + final InflectionAffix classiclPlural) { if (singlar == null) throw new NullPointerException("Singular form must not be null"); else if (modrnPlural == null && classiclPlural == null) @@ -73,7 +75,8 @@ public class CategoricalNounInflection implements NounInflection { else if (matchesPlural(noun)) return false; else { - final String msg = String.format("Noun '%s' doesn't belong to this inflection", noun, this); + final String msg = String.format("Noun '%s' doesn't belong to this inflection", noun, + this); throw new InflectionException(msg); } @@ -86,7 +89,8 @@ public class CategoricalNounInflection implements NounInflection { else if (matchesPlural(noun)) return true; else { - final String msg = String.format("Noun '%s' doesn't belong to this inflection", noun, this); + final String msg = String.format("Noun '%s' doesn't belong to this inflection", noun, + this); throw new InflectionException(msg); } @@ -101,7 +105,8 @@ public class CategoricalNounInflection implements NounInflection { else if (classicalPlural != null && classicalPlural.hasAffix(plural)) return singular.affix(classicalPlural.deaffix(plural)); else { - final String msg = String.format("Noun '%s' doesn't belong to this inflection", plural, this); + final String msg = String.format("Noun '%s' doesn't belong to this inflection", plural, + this); throw new InflectionException(msg); } @@ -116,7 +121,8 @@ public class CategoricalNounInflection implements NounInflection { } else if (matchesPlural(singlar)) return singlar; else { - final String msg = String.format("Noun '%s' doesn't belong to this inflection", singlar, this); + final String msg = String.format("Noun '%s' doesn't belong to this inflection", singlar, + this); throw new InflectionException(msg); } @@ -147,7 +153,9 @@ public class CategoricalNounInflection implements NounInflection { @Override public boolean equals(final Object obj) { if (this == obj) return true; + if (obj == null) return false; + if (!(obj instanceof CategoricalNounInflection)) return false; final CategoricalNounInflection other = (CategoricalNounInflection) obj; @@ -168,6 +176,7 @@ public class CategoricalNounInflection implements NounInflection { if (modernPlural == null) return pluralizeClassical(singlar); String actSinglar = singlar; + if (isPlural(singlar)) { actSinglar = singularize(singlar); } @@ -180,6 +189,7 @@ public class CategoricalNounInflection implements NounInflection { if (classicalPlural == null) return pluralizeModern(singlar); String actSinglar = singlar; + if (isPlural(singlar)) { actSinglar = singularize(singlar); } |
