*/
package org.mxchange.jusercore.model.user.password_history;
+import java.text.MessageFormat;
import java.util.Date;
import java.util.Objects;
import javax.persistence.Basic;
* @param userPasswordHistoryUser User instance
*/
public UserPasswordHistory (final String userPasswordHistoryPasswordHash, final User userPasswordHistoryUser) {
+ /*
+ * Invoke default constructor. This one here (above this constructor)
+ * might do nothing useful, that's true. It is an empty method for the
+ * JPA to invoke, that's true, too. The thing here is, that you might
+ * become lazy and forget it somewhere else where you really have to
+ * invoke it or otherwise your object isn't fully/correctly initialized.
+ * This has leaded already to funny side-effects such as "suddenly it
+ * doesn't work, then it works again" and also to NPEs in the
+ * history.Thumb of a rule: If there is a simplier constructor, DO
+ * INVOKE it.
+ */
+ this();
+
+ // Validate all parameter
+ if (null == userPasswordHistoryPasswordHash) {
+ // Throw NPE
+ throw new NullPointerException("userPasswordHistoryPasswordHash is null"); //NOI18N
+ } else if (userPasswordHistoryPasswordHash.isEmpty()) {
+ // Throw IAE
+ throw new IllegalArgumentException("userPasswordHistoryPasswordHash is empty"); //NOI18N
+ } else if (null == userPasswordHistoryUser) {
+ // Throw NPE
+ throw new NullPointerException("userPasswordHistoryUser is null"); //NOI18N
+ } else if (userPasswordHistoryUser.getUserId() == null) {
+ // Throw NPE again
+ throw new NullPointerException("userPasswordHistoryUser.userId is null"); //NOI18N
+ } else if (userPasswordHistoryUser.getUserId() < 1) {
+ // Throw IAE
+ throw new IllegalArgumentException(MessageFormat.format("userPasswordHistoryUser.userId={0} is not valid", userPasswordHistoryUser.getUserId())); //NOI18N
+ }
+
// Set all
this.userPasswordHistoryPasswordHash = userPasswordHistoryPasswordHash;
this.userPasswordHistoryUser = userPasswordHistoryUser;
public enum ProfileMode implements Serializable {
/**
- * Invisible to guests and members (not administrators)
+ * Invisible to guests and members (but visible to administrators)
*/
INVISIBLE("PROFILE_MODE_INVISIBLE"), //NOI18N
* @param messageKey Message key
*/
private ProfileMode (final String messageKey) {
+ // Validate all parameter
+ if (null == messageKey) {
+ // Throw NPE
+ throw new NullPointerException("messageKey is null"); //NOI18N
+ } else if (messageKey.isEmpty()) {
+ // Throw IAE
+ throw new IllegalArgumentException("messageKey is empty"); //NOI18N
+ }
+
+ // Set all enum fields
this.messageKey = messageKey;
}
*/
public enum UserAccountStatus implements Serializable {
- /**
- * Unconfirmed (default)
- */
- UNCONFIRMED("USER_ACCOUNT_STATUS_UNCONFIRMED", "user-status-unconfirmed"), //NOI18N
-
/**
* Confirmed (email address validated)
*/
/**
* Locked (maybe violated T&C)
*/
- LOCKED("USER_ACCOUNT_STATUS_LOCKED", "user-status-locked"); //NOI18N
+ LOCKED("USER_ACCOUNT_STATUS_LOCKED", "user-status-locked"), //NOI18N
+
+ /**
+ * Unconfirmed (default)
+ */
+ UNCONFIRMED("DEPRECATED", "user-status-unconfirmed"); //NOI18N
/**
* Message key