package com.devicehive.model.updates;

/*
 * #%L
 * DeviceHive Common Dao Interfaces
 * %%
 * Copyright (C) 2016 DataArt
 * %%
 * 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.
 * #L%
 */

import com.devicehive.model.HiveEntity;
import com.devicehive.model.JsonStringWrapper;
import com.devicehive.model.enums.UserRole;
import com.devicehive.model.enums.UserStatus;
import com.devicehive.vo.UserVO;
import com.google.gson.annotations.SerializedName;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.Size;
import java.util.Optional;

public class UserUpdate implements HiveEntity {

    private static final long serialVersionUID = -8353201743020153250L;

    @Size(min = 1, max = 128, message = "Field login cannot be empty. The length of login should not be more than 128 symbols.")
    private String login;

    @Max(value = 1, message = "The value of role should not be more than 1.")
    @Min(value = 0, message = "The value of role should not be less than 0.")
    private Integer role;

    @Max(value = 3, message = "The value of status should not be more than 3.")
    @Min(value = 0, message = "The value of status should not be less than 0.")
    private Integer status;

    @Size(max = 128, message = "The length of password should not be more than 128 symbols.")
    private String password;

    @Size(max = 128, message = "The length of old password should not be more than 128 symbols.")
    private String oldPassword;

    private JsonStringWrapper data;

    private Boolean introReviewed;

    public Optional<String> getLogin() {
        return Optional.ofNullable(login);
    }

    public void setLogin(String login) {
        this.login = login;
    }

    public Optional<Integer> getRole() {
        return Optional.ofNullable(role);
    }

    public void setRole(Integer role) {
        this.role = role;
    }

    public Optional<Integer> getStatus() {
        return Optional.ofNullable(status);
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Optional<String> getPassword() {
        return Optional.ofNullable(password);
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Optional<String> getOldPassword() {
        return Optional.ofNullable(oldPassword);
    }

    public void setOldPassword(String oldPassword) {
        this.oldPassword = oldPassword;
    }

    public Optional<JsonStringWrapper> getData() {
        return Optional.ofNullable(data);
    }

    public void setData(JsonStringWrapper data) {
        this.data = data;
    }

    public Optional<Boolean> getIntroReviewed() {
        return Optional.ofNullable(introReviewed);
    }

    public void setIntroReviewed(Boolean introReviewed) {
        this.introReviewed = introReviewed;
    }

    public UserRole getRoleEnum() {
        return getRole().map(UserRole::getValueForIndex).orElse(null);
    }

    public UserStatus getStatusEnum() {
        return getStatus().map(UserStatus::getValueForIndex).orElse(null);
    }

    public UserVO convertTo() {
        UserVO result = new UserVO();
        if (login != null) {
            result.setLogin(login);
        }
        if (data != null) {
            result.setData(data);
        }
        if (introReviewed != null) {
            result.setIntroReviewed(introReviewed);
        }
        result.setStatus(getStatusEnum());
        result.setRole(getRoleEnum());
        return result;
    }
}

@@ -950,16 +950,64 @@
 zedName;
+%0Aimport io.swagger.annotations.ApiModelProperty;
 %0A%0Aimport
@@ -1430,16 +1430,79 @@
 login;%0A%0A
+    @ApiModelProperty(value = %220 for 'ADMIN', 1 for 'CLIENT'%22)%0A
     @Max
@@ -1676,16 +1676,119 @@
  role;%0A%0A
+    @ApiModelProperty(value = %220 for 'ACTIVE', 1 for 'LOCKED_OUT', 2 for 'DISABLED', 3 for 'DELETED'%22)%0A
     @Max
@@ -3581,32 +3581,69 @@
 eviewed;%0A    %7D%0A%0A
+    @ApiModelProperty(hidden = true)%0A
     public UserR
@@ -3732,32 +3732,69 @@
 e(null);%0A    %7D%0A%0A
+    @ApiModelProperty(hidden = true)%0A
     public UserS

Add swagger annotations for UserUpdate model