chapter_007/src/main/java/ru/job4j/storage/ValidateStub.java
/**
     * Check update user in the storage if true add user.
     *
     * @param user - user.
     */
Check update user in the storage if true add user.
@param user - user.
Check update user in the storage if true add user . @param user - user .
public boolean update(User user) {
        boolean result;
        if (user.getId() == 0) {
            throw new IncorrectDateException("User does not exist, please write correctly id");
        }
        User userCorrect = checkUser(user);
        if (this.logic.getClass().getSimpleName().equals("MemoryStore")) {
            for (User us : this.logic.findAll()) {
                if (user.getId() != us.getId() && (us.getLogin().equals(user.getLogin()) || us.getEmail().equals(user.getEmail()))) {
                    throw new IncorrectDateException("User or Email are busy");
                }
            }
        }
        result = logic.update(userCorrect);
        if (!result) {
            throw new IncorrectDateException("User does not exist");
        }
        return true;
    }
public boolean update ( User user ) { boolean result ; if ( user . getId ( ) == 0 ) { throw new IncorrectDateException ( "User does not exist, please write correctly id" ) ; } User userCorrect = checkUser ( user ) ; if ( this . logic . getClass ( ) . getSimpleName ( ) . equals ( "MemoryStore" ) ) { for ( User us : this . logic . findAll ( ) ) { if ( user . getId ( ) != us . getId ( ) && ( us . getLogin ( ) . equals ( user . getLogin ( ) ) || us . getEmail ( ) . equals ( user . getEmail ( ) ) ) ) { throw new IncorrectDateException ( "User or Email are busy" ) ; } } } result = logic . update ( userCorrect ) ; if ( ! result ) { throw new IncorrectDateException ( "User does not exist" ) ; } return true ; }
Check update user in the storage if true add user.
Check update user in the storage if true add user .