isis-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian K <harvestmoon...@gmail.com>
Subject Re: Simple composite key of ansi padded strings
Date Tue, 26 Jun 2018 04:00:46 GMT
Thanks Andi!  There were a few parts that I had to change.  For instance,
using targetClassName triggered a validation error when building in
SimpleApp.  The following is working:

public class CourtPrecinctPrimaryKey implements Serializable {

    public String courtCd;
    public String precinctCd;

    private static final String SEPARATOR = ",";

    public CourtPrecinctPrimaryKey() {
    }

    public CourtPrecinctPrimaryKey(String value) {
        StringTokenizer token = new StringTokenizer(value, SEPARATOR);
        this.courtCd = StringUtils.stripEnd(token.nextToken(),null);
        this.precinctCd = StringUtils.stripEnd(token.nextToken(),null);
    }

    @Override
    public String toString() {
        return ""
                + SEPARATOR + StringUtils.stripEnd(this.courtCd.trim(),
null)
                + SEPARATOR + StringUtils.stripEnd(this.precinctCd.trim(),
null);
    }

    @Override
    public int hashCode() {
        return StringUtils.stripEnd(this.courtCd, null).hashCode() ^
StringUtils.stripEnd(this.precinctCd, null).hashCode();
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == this) {
            return true;
        }
        if (!(obj instanceof CourtPrecinctPrimaryKey)) {
            return false;
        }
        CourtPrecinctPrimaryKey c = (CourtPrecinctPrimaryKey) obj;
        return courtCd.startsWith(c.courtCd) &&
precinctCd.startsWith(c.precinctCd);
    }

}

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message