Coverage Report - org.jtheque.core.managers.module.beans.ModuleState
 
Classes in this File Line Coverage Branch Coverage Complexity
ModuleState
0 %
0/24
0 %
0/9
4
ModuleState$1
0 %
0/1
N/A
4
 
 1  
 package org.jtheque.core.managers.module.beans;
 2  
 
 3  
 /*
 4  
  * This file is part of JTheque.
 5  
  *
 6  
  * JTheque is free software: you can redistribute it and/or modify
 7  
  * it under the terms of the GNU General Public License as published by
 8  
  * the Free Software Foundation, either version 3 of the License.
 9  
  *
 10  
  * JTheque is distributed in the hope that it will be useful,
 11  
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 12  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 13  
  * GNU General Public License for more details.
 14  
  *
 15  
  * You should have received a copy of the GNU General Public License
 16  
  * along with JTheque.  If not, see <http://www.gnu.org/licenses/>.
 17  
  */
 18  
 
 19  
 import org.jtheque.core.managers.Managers;
 20  
 import org.jtheque.core.managers.language.ILanguageManager;
 21  
 
 22  
 /**
 23  
  * The state of a module.
 24  
  *
 25  
  * @author Baptiste Wicht
 26  
  */
 27  0
 public enum ModuleState {
 28  0
     LOADED,
 29  0
     INSTALLED,
 30  0
     JUST_INSTALLED,
 31  0
     DISABLED,
 32  0
     UNINSTALLED;
 33  
 
 34  
     /**
 35  
      * Return the enum value from the ordinal value.
 36  
      *
 37  
      * @param ordinal The ordinal value.
 38  
      * @return The enum value corresponding to the ordinal value.
 39  
      */
 40  
     public static ModuleState valueOf(int ordinal) {
 41  0
         ModuleState state = LOADED;
 42  
 
 43  0
         for (ModuleState s : values()) {
 44  0
             if (s.ordinal() == ordinal) {
 45  0
                 state = s;
 46  0
                 break;
 47  
             }
 48  
         }
 49  
 
 50  0
         return state;
 51  
     }
 52  
 
 53  
     @Override
 54  
     public String toString() {
 55  
         String state;
 56  
 
 57  0
         switch (valueOf(ordinal())) {
 58  
             case LOADED:
 59  0
                 state = Managers.getManager(ILanguageManager.class).getMessage("modules.state.loaded");
 60  
 
 61  0
                 break;
 62  
             case INSTALLED:
 63  0
                 state = Managers.getManager(ILanguageManager.class).getMessage("modules.state.installed");
 64  
 
 65  0
                 break;
 66  
             case DISABLED:
 67  0
                 state = Managers.getManager(ILanguageManager.class).getMessage("modules.state.disabled");
 68  
 
 69  0
                 break;
 70  
             case UNINSTALLED:
 71  0
                 state = Managers.getManager(ILanguageManager.class).getMessage("modules.state.uninstalled");
 72  
 
 73  0
                 break;
 74  
             default:
 75  0
                 state = "Undefined";
 76  
 
 77  0
                 break;
 78  
         }
 79  
 
 80  0
         return state;
 81  
     }
 82  
 }