1 package org.cacert.gigi.dbObjects;
3 import org.cacert.gigi.database.GigiResultSet;
4 import org.cacert.gigi.dbObjects.wrappers.DataContainer;
7 public class NamePart {
9 public enum NamePartType {
10 FIRST_NAME, LAST_NAME, SINGLE_NAME, SUFFIX;
12 public String getDbValue() {
13 return name().toLowerCase().replace("_", "-");
17 private NamePartType type;
21 public NamePart(NamePartType type, String value) {
22 if (type == null || value == null || value.trim().isEmpty() || !value.trim().equals(value)) {
23 throw new IllegalArgumentException();
29 public NamePart(GigiResultSet rs1) {
30 value = rs1.getString("value");
31 type = NamePartType.valueOf(rs1.getString("type").replace("-", "_").toUpperCase());
34 public NamePartType getType() {
38 public String getValue() {
43 public String toString() {
48 public int hashCode() {
51 result = prime * result + ((type == null) ? 0 : type.hashCode());
52 result = prime * result + ((value == null) ? 0 : value.hashCode());
57 public boolean equals(Object obj) {
64 if (getClass() != obj.getClass()) {
67 NamePart other = (NamePart) obj;
68 if (type != other.type) {
72 if (other.value != null) {
75 } else if ( !value.equals(other.value)) {