1 package org.cacert.gigi.dbObjects;
3 import org.cacert.gigi.database.DBEnum;
4 import org.cacert.gigi.database.GigiResultSet;
5 import org.cacert.gigi.dbObjects.wrappers.DataContainer;
8 public class NamePart {
10 public enum NamePartType implements DBEnum {
11 FIRST_NAME, LAST_NAME, SINGLE_NAME, SUFFIX;
13 public String getDBName() {
14 return name().toLowerCase().replace("_", "-");
18 private NamePartType type;
22 public NamePart(NamePartType type, String value) {
23 if (type == null || value == null || value.trim().isEmpty() || !value.trim().equals(value)) {
24 throw new IllegalArgumentException();
30 public NamePart(GigiResultSet rs1) {
31 value = rs1.getString("value");
32 type = NamePartType.valueOf(rs1.getString("type").replace("-", "_").toUpperCase());
35 public NamePartType getType() {
39 public String getValue() {
44 public String toString() {
49 public int hashCode() {
52 result = prime * result + ((type == null) ? 0 : type.hashCode());
53 result = prime * result + ((value == null) ? 0 : value.hashCode());
58 public boolean equals(Object obj) {
65 if (getClass() != obj.getClass()) {
68 NamePart other = (NamePart) obj;
69 if (type != other.type) {
73 if (other.value != null) {
76 } else if ( !value.equals(other.value)) {