package at.gv.egovernment.moa.id.commons.db.dao.config; import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Id; import javax.persistence.MappedSuperclass; @MappedSuperclass public abstract class AbstractConfigProperty implements Serializable{ /** * */ private static final long serialVersionUID = 1L; @Id @Column(name = "propertyKey", unique = true) protected String key; public AbstractConfigProperty() { super(); } /** * Returns the property's value (which might be {@code null}). * @return The property's value (might be {@code null}). */ abstract public String getValue(); /** * Sets the property's value. * @param value The value */ abstract public void setValue(String value); /** * Returns the property's key. * @return The key. */ public String getKey() { return key; } /** * Sets the property's key. * @param key The key */ public void setKey(String key) { this.key = key; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((key == null) ? 0 : key.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; AbstractConfigProperty other = (AbstractConfigProperty) obj; if (key == null) { if (other.key != null) return false; } else if (!key.equals(other.key)) return false; return true; } public String toString() { StringBuilder builder = new StringBuilder(); builder.append(getImplementationName()); builder.append(" [key="); builder.append(getKey()); builder.append(", value="); builder.append(getValue()); builder.append("]"); return builder.toString(); } /** * Get a name for this Entity-Implementation class * * @return */ protected String getImplementationName() { return getImplementationClass().getSimpleName(); } /** * Get get Class of the implemented Entity * * @return */ abstract protected Class getImplementationClass(); }