class Inflection implements Comparable<Inflection> {

    private static final Pattern MFN = Pattern.compile("[mfn]");

    final String gender;
    final String _case;
    final String animTag;
  
    Inflection(String gender, String _case, String animTag) {
      this.gender = gender;
      this._case = _case;
      this.animTag = animTag;
    }
  
    @Override
    public int hashCode() {
      final int prime = 31;
      int result = 1;
      result = prime * result + ((_case == null) ? 0 : _case.hashCode());
//      result = prime * result + ((animTag == null) ? 0 : animTag.hashCode());
      result = prime * result + ((gender == null) ? 0 : gender.hashCode());
      return result;
    }
  
    @Override
    public boolean equals(Object obj) {
      if (this == obj)
        return true;
      if (obj == null)
        return false;
      if (getClass() != obj.getClass())
        return false;
  
      Inflection other = (Inflection) obj;
      return genderEquals(gender, other.gender)
          && _case.equals(other._case)
          && (animTag == null || other.animTag == null 
          || ! animMatters() || ! other.isAnimalSensitive() || animTag.equals(other.animTag));
    }
  
    private boolean genderEquals(String gender1, String gender2) {<FILL_FUNCTION_BODY>}

    public boolean equalsIgnoreGender(Inflection other) {
      return //gender.equals(other.gender)
          _case.equals(other._case)
          && (animTag == null || other.animTag == null 
          || ! animMatters() || animTag.equals(other.animTag));
    }
  
    boolean animMatters() {
      return animTag != null && ! "unanim".equals(animTag) && _case.equals("v_zna") && isAnimalSensitive();
    }
  
    private boolean isAnimalSensitive() {
      return "mp".contains(gender);
    }
  
    @Override
    public String toString() {
      return ":" + gender + ":" + _case
          + (animMatters() ? "_"+animTag : "");
    }

    @Override
    public int compareTo(Inflection o) {
      if( GEN_ORDER.get(gender) == null ) System.err.println ("unknown gender for " + gender + " for " + o);
      
      int compared = GEN_ORDER.get(gender).compareTo(GEN_ORDER.get(o.gender));
      if( compared != 0 )
        return compared;
      
      compared = VIDM_ORDER.get(_case).compareTo(VIDM_ORDER.get(o._case));
      return compared;
    }
  
  }

      if( gender1.equals(gender2) )
        return true;
      
      if( gender1.equals("s") && MFN.matcher(gender2).matches()
          || gender2.equals("s") && MFN.matcher(gender1).matches())
        return true;

      return false;
    
<no_super_class>