/*
 * Copyright 2016-2017 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package es.esky.role.users.domain;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.Size;
import java.io.Serializable;

import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;

import es.esky.role.users.domain.validator.Lowercase;
import es.esky.role.users.domain.validator.Uppercase;

import static com.fasterxml.jackson.annotation.JsonProperty.Access.WRITE_ONLY;

/**
 * User domain model.
 *
 * @author Cristian Mateos López
 * @since 1.0.0
 */
@Entity
@Table(name = "USERS")
public class User implements Serializable {
	public static final long serialVersionUID = 1L;

	@Id
	private String username;

	@JsonProperty(access = WRITE_ONLY)
	@Lowercase
	@Uppercase
	@Size(min = 8)
	private String password;

	/**
	 * Get username.
	 *
	 * @return username.
	 * @since 1.0.0
	 */
	public String getUsername() {
		return username;
	}

	/**
	 * Set username.
	 *
	 * @param username username.
	 * @since 1.0.0
	 */
	public void setUsername(String username) {
		this.username = username;
	}

	/**
	 * Get password.
	 *
	 * @return password.
	 * @since 1.0.0
	 */
	public String getPassword() {
		return password;
	}

	/**
	 * Set password.
	 *
	 * @param password password.
	 * @since 1.0.0
	 */
	public void setPassword(String password) {
		this.password = password;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public boolean equals(Object o) {
		if (this == o) {
			return true;
		}

		if (o == null || getClass() != o.getClass()) {
			return false;
		}

		User user = (User) o;

		return new EqualsBuilder()
				.append(username, user.username)
				.append(password, user.password)
				.isEquals();
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public int hashCode() {
		return new HashCodeBuilder(17, 37)
				.append(username)
				.append(password)
				.toHashCode();
	}
}

@@ -982,16 +982,73 @@
 Builder;
+%0Aimport org.apache.commons.lang3.builder.ToStringBuilder;
 %0A%0Aimport
@@ -1389,21 +1389,22 @@
 ble %7B%0A%09p
-ublic
+rivate
  static 
@@ -2633,11 +2633,168 @@
 de();%0A%09%7D
+%0A%0A%09/**%0A%09 * %7B@inheritDoc%7D%0A%09 */%0A%09@Override%0A%09public String toString() %7B%0A%09%09return new ToStringBuilder(this)%0A%09%09%09%09.append(%22username%22, username)%0A%09%09%09%09.toString();%0A%09%7D
 %0A%7D%0A

Add to string and privatize serialVersionUID.