Coverage Report - org.jtheque.core.managers.module.beans.ModuleContainer
 
Classes in this File Line Coverage Branch Coverage Complexity
ModuleContainer
0 %
0/27
N/A
1
 
 1  
 package org.jtheque.core.managers.module.beans;
 2  
 
 3  
 import org.jtheque.core.managers.Managers;
 4  
 import org.jtheque.core.managers.language.ILanguageManager;
 5  
 import org.jtheque.core.managers.module.annotations.Module;
 6  
 
 7  
 import java.io.File;
 8  
 
 9  
 /*
 10  
  * This file is part of JTheque.
 11  
  *
 12  
  * JTheque is free software: you can redistribute it and/or modify
 13  
  * it under the terms of the GNU General Public License as published by
 14  
  * the Free Software Foundation, either version 3 of the License.
 15  
  *
 16  
  * JTheque is distributed in the hope that it will be useful,
 17  
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 18  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 19  
  * GNU General Public License for more details.
 20  
  *
 21  
  * You should have received a copy of the GNU General Public License
 22  
  * along with JTheque.  If not, see <http://www.gnu.org/licenses/>.
 23  
  */
 24  
 
 25  
 /**
 26  
  * @author Baptiste Wicht
 27  
  */
 28  
 public final class ModuleContainer {
 29  
     private Object module;
 30  
     private final String beanName;
 31  
 
 32  
     private final Module infos;
 33  
 
 34  
     private BeanMethod plugMethod;
 35  
     private BeanMethod prePlugMethod;
 36  
     private BeanMethod unPlugMethod;
 37  
 
 38  
     private ModuleState state;
 39  
 
 40  
     /**
 41  
      * Construct a new ModuleContainer.
 42  
      *
 43  
      * @param beanName The name of the bean.
 44  
      * @param infos    The informations about the module.
 45  
      */
 46  
     public ModuleContainer(String beanName, Module infos) {
 47  0
         super();
 48  
 
 49  0
         this.beanName = beanName;
 50  0
         this.infos = infos;
 51  0
     }
 52  
 
 53  
     /**
 54  
      * Return the real module.
 55  
      *
 56  
      * @return The real module.
 57  
      */
 58  
     public Object getModule() {
 59  0
         return module;
 60  
     }
 61  
 
 62  
     /**
 63  
      * Return the plug method.
 64  
      *
 65  
      * @return The plug method.
 66  
      */
 67  
     public BeanMethod getPlugMethod() {
 68  0
         return plugMethod;
 69  
     }
 70  
 
 71  
     /**
 72  
      * Set the plug method.
 73  
      *
 74  
      * @param plugMethod The plug method.
 75  
      */
 76  
     public void setPlugMethod(BeanMethod plugMethod) {
 77  0
         this.plugMethod = plugMethod;
 78  0
     }
 79  
 
 80  
     /**
 81  
      * Return the pre plug method.
 82  
      *
 83  
      * @return The plug method.
 84  
      */
 85  
     public BeanMethod getPrePlugMethod() {
 86  0
         return prePlugMethod;
 87  
     }
 88  
 
 89  
     /**
 90  
      * Set the pre plug method.
 91  
      *
 92  
      * @param prePlugMethod The pre plug method.
 93  
      */
 94  
     public void setPrePlugMethod(BeanMethod prePlugMethod) {
 95  0
         this.prePlugMethod = prePlugMethod;
 96  0
     }
 97  
 
 98  
     /**
 99  
      * Return the unplug method.
 100  
      *
 101  
      * @return The plug method.
 102  
      */
 103  
     public BeanMethod getUnPlugMethod() {
 104  0
         return unPlugMethod;
 105  
     }
 106  
 
 107  
     /**
 108  
      * Set the unplug method.
 109  
      *
 110  
      * @param unPlugMethod The unplug method.
 111  
      */
 112  
     public void setUnPlugMethod(BeanMethod unPlugMethod) {
 113  0
         this.unPlugMethod = unPlugMethod;
 114  0
     }
 115  
 
 116  
     /**
 117  
      * Return the current state of the module.
 118  
      *
 119  
      * @return The current state of the module.
 120  
      */
 121  
     public ModuleState getState() {
 122  0
         return state;
 123  
     }
 124  
 
 125  
     /**
 126  
      * Set the state of the module.
 127  
      *
 128  
      * @param state The state of the module.
 129  
      */
 130  
     public void setState(ModuleState state) {
 131  0
         this.state = state;
 132  0
     }
 133  
 
 134  
     /**
 135  
      * Return the infos of the module.
 136  
      *
 137  
      * @return The infos of the module.
 138  
      */
 139  
     public Module getInfos() {
 140  0
         return infos;
 141  
     }
 142  
 
 143  
     /**
 144  
      * Return the file of the module.
 145  
      *
 146  
      * @return The file of the module.
 147  
      */
 148  
     public File getModuleFile() {
 149  0
         return new File(Managers.getCore().getFolders().getModulesFolder(), infos.jarFile());
 150  
     }
 151  
 
 152  
     /**
 153  
      * Return the name of the bean.
 154  
      *
 155  
      * @return The name of the bean.
 156  
      */
 157  
     public String getBeanName() {
 158  0
         return beanName;
 159  
     }
 160  
 
 161  
     /**
 162  
      * Set the module instance.
 163  
      *
 164  
      * @param module The module instance.
 165  
      */
 166  
     public void setModule(Object module) {
 167  0
         this.module = module;
 168  0
     }
 169  
 
 170  
     /**
 171  
      * Return the id of the module.
 172  
      *
 173  
      * @return The id of the module.
 174  
      */
 175  
     public String getId() {
 176  0
         return infos.id();
 177  
     }
 178  
 
 179  
     /**
 180  
      * Return the name key of the module.
 181  
      *
 182  
      * @return The name key of the module.
 183  
      */
 184  
     public String getName() {
 185  0
         return Managers.getManager(ILanguageManager.class).getMessage(infos.id() + ".name");
 186  
     }
 187  
 
 188  
     /**
 189  
      * Return the author key of the module.
 190  
      *
 191  
      * @return The author key of the module.
 192  
      */
 193  
     public String getAuthor() {
 194  0
         return Managers.getManager(ILanguageManager.class).getMessage(infos.id() + ".author");
 195  
     }
 196  
 
 197  
     /**
 198  
      * Return the key description of the module.
 199  
      *
 200  
      * @return The key description of the module.
 201  
      */
 202  
     public String getDescription() {
 203  0
         return Managers.getManager(ILanguageManager.class).getMessage(infos.id() + ".description");
 204  
     }
 205  
 
 206  
     @Override
 207  
     public String toString() {
 208  0
         return getName();
 209  
     }
 210  
 }