Android Open Source - jogjakota-perizinan User D B






From Project

Back to project page jogjakota-perizinan.

License

The source code is released under:

MIT License

If you think the Android project jogjakota-perizinan listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package id.go.jogjakota.perizinan.data;
//from  w w w . ja v  a 2 s  .c  om
import java.util.LinkedList;

import id.go.jogjakota.perizinan.domain.User;

public class UserDB {
    private static UserDB userDB;

    private LinkedList<User> users = new LinkedList<>();

    public static UserDB get() {
        if (userDB == null) {
            userDB = new UserDB();
        }

        return userDB;
    }

    public void addUser(User newUser) throws UserExistException {
        for (User user : users) {
            if (user.getUsername().equalsIgnoreCase(newUser.getUsername()))
                throw new UserExistException();
        }

        users.add(newUser);
    }

    public User getUser(String username, String password) throws UserNotFoundException {
        for (User user : users) {
            if (username.equalsIgnoreCase(user.getUsername()) && password.equals(user.getPassword()))
                return user;
        }

        throw new UserNotFoundException("Username atau password salah");
    }

    public static class UserNotFoundException extends Exception {
        public UserNotFoundException() {
        }

        public UserNotFoundException(String detailMessage) {
            super(detailMessage);
        }

        public UserNotFoundException(String detailMessage, Throwable throwable) {
            super(detailMessage, throwable);
        }

        public UserNotFoundException(Throwable throwable) {
            super(throwable);
        }
    }

    public static class UserExistException extends Exception {
        public UserExistException() {
        }

        public UserExistException(String detailMessage) {
            super(detailMessage);
        }

        public UserExistException(String detailMessage, Throwable throwable) {
            super(detailMessage, throwable);
        }

        public UserExistException(Throwable throwable) {
            super(throwable);
        }
    }
}




Java Source Code List

id.go.jogjakota.perizinan.ApplicationTest.java
id.go.jogjakota.perizinan.BaseActivity.java
id.go.jogjakota.perizinan.BaseApp.java
id.go.jogjakota.perizinan.LoginActivity.java
id.go.jogjakota.perizinan.MainActivity.java
id.go.jogjakota.perizinan.PermitDetailActivity.java
id.go.jogjakota.perizinan.PermitFormActivity.java
id.go.jogjakota.perizinan.PermitListActivity.java
id.go.jogjakota.perizinan.PermitTypeListActivity.java
id.go.jogjakota.perizinan.RegisterActivity.java
id.go.jogjakota.perizinan.SplashActivity.java
id.go.jogjakota.perizinan.StatusView.java
id.go.jogjakota.perizinan.Tag.java
id.go.jogjakota.perizinan.Transition.java
id.go.jogjakota.perizinan.TwoLineViewHolder.java
id.go.jogjakota.perizinan.data.Dummies.java
id.go.jogjakota.perizinan.data.PermitDB.java
id.go.jogjakota.perizinan.data.PermitTypes.java
id.go.jogjakota.perizinan.data.Session.java
id.go.jogjakota.perizinan.data.UserDB.java
id.go.jogjakota.perizinan.domain.PermitType.java
id.go.jogjakota.perizinan.domain.Permit.java
id.go.jogjakota.perizinan.domain.User.java