/*
 * Copyright 2014-2016 CyberVision, Inc.
 *
 * 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 org.kaaproject.kaa.common.dto;

import javax.validation.constraints.NotNull;
import java.io.Serializable;
import javax.validation.constraints.Size;

public class UserDto implements HasId, Serializable {

    private static final long serialVersionUID = 2052580632293959408L;

    private String id;
    @Size(min = 2 , max = 35)
    @NotNull(message="username can't be null")
    private String username;
    private String externalUid;
    private String tenantId;
    @NotNull(message="authority can't be null")
    private KaaAuthorityDto authority;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }
    
    public String getExternalUid() {
        return externalUid;
    }

    public void setExternalUid(String externalUid) {
        this.externalUid = externalUid;
    }

    public String getTenantId() {
        return tenantId;
    }

    public void setTenantId(String tenantId) {
        this.tenantId = tenantId;
    }

    public KaaAuthorityDto getAuthority() {
        return authority;
    }

    public void setAuthority(KaaAuthorityDto authority) {
        this.authority = authority;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result
                + ((externalUid == null) ? 0 : externalUid.hashCode());
        result = prime * result + ((id == null) ? 0 : id.hashCode());
        result = prime * result
                + ((tenantId == null) ? 0 : tenantId.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;
        }
        UserDto other = (UserDto) obj;
        if (externalUid == null) {
            if (other.externalUid != null) {
                return false;
            }
        } else if (!externalUid.equals(other.externalUid)) {
            return false;
        }
        if (id == null) {
            if (other.id != null) {
                return false;
            }
        } else if (!id.equals(other.id)) {
            return false;
        }
        if (tenantId == null) {
            if (other.tenantId != null) {
                return false;
            }
        } else if (!tenantId.equals(other.tenantId)) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "UserDto [id=" + id + ", username=" + username
                + ", externalUid=" + externalUid + ", tenantId=" + tenantId
                + ", authority=" + authority + "]";
    }
    
}

@@ -928,20 +928,9 @@
 n = 
-2 , max = 35
+1
 )%0A  

add @Valid annotation to the editUser() parameter method