Skip to content

Singleton

Stefania Bezerra da Silva edited this page May 13, 2017 · 2 revisions
Data Versão Descrição Autor
11/05/2017 1.0 Criação do documento Stefania Bezerra
11/05/2017 1.1 Adicionando o padrão Stefania Bezerra
/* This method can be used to get an instance of a user from the database. It also validates
     *  if the student can be found in a DAO.
     *
     * @return Student object found
     */
    public Student getUserInstance(){
        Student foundStudent = null;
        final StudentDAO studentDAO= this.getUserDB();

        final Boolean isStudentDAOAvailable = studentDAO != null;

        // If the DAO is ready, the condition will try to get the student available in the DB.
        if(isStudentDAOAvailable){
            foundStudent = this.getUserDB().getDefaultStudent();
        } else
        {
            Log.e("UserData: ", "NULLPOINTER found! Could not access StudentDAO in getUserInstance.");
        }

        return foundStudent;
    }