View Javadoc

1   /* This file is part of the project "Hilbert II" - http://www.qedeq.org" target="alexandria_uri">http://www.qedeq.org
2    *
3    * Copyright 2000-2014,  Michael Meyling <mime@qedeq.org>.
4    *
5    * "Hilbert II" is free software; you can redistribute
6    * it and/or modify it under the terms of the GNU General Public
7    * License as published by the Free Software Foundation; either
8    * version 2 of the License, or (at your option) any later version.
9    *
10   * This program 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  
16  package org.qedeq.kernel.se.state;
17  
18  import org.qedeq.kernel.se.common.State;
19  
20  
21  /**
22   * Represents a mathematical module state. All existing instances of this class are the public
23   * constants of this class.
24   *
25   * @author  Michael Meyling
26   */
27  public final class DependencyState extends AbstractState implements State {
28  
29      /** Undefined loading state. */
30      public static final DependencyState STATE_UNDEFINED = new DependencyState(
31          DependencyStateDescriptions.STATE_STRING_UNDEFINED, false,
32          DependencyStateDescriptions.STATE_CODE_UNDEFINED);
33  
34      /** Loading required modules. */
35      public static final DependencyState STATE_LOADING_REQUIRED_MODULES = new DependencyState(
36          DependencyStateDescriptions.STATE_STRING_LOADING_REQUIRED_MODULES, false,
37          DependencyStateDescriptions.STATE_CODE_LOADING_REQUIRED_MODULES);
38  
39      /** Loading required modules failed. */
40      public static final DependencyState STATE_LOADING_REQUIRED_MODULES_FAILED = new DependencyState(
41          DependencyStateDescriptions.STATE_STRING_LOADING_REQUIRED_MODULES_FAILED, true,
42          DependencyStateDescriptions.STATE_CODE_LOADING_REQUIRED_MODULES_FAILED);
43  
44      /** Completely loaded. */
45      public static final DependencyState STATE_LOADED_REQUIRED_MODULES = new DependencyState(
46          DependencyStateDescriptions.STATE_STRING_LOADED_REQUIRED_MODULES, false,
47          DependencyStateDescriptions.STATE_CODE_LOADED_REQUIRED_MODULES);
48  
49  
50      /**
51       * Creates new module state.
52       *
53       * @param   text    meaning of this state, <code>null</code> is not permitted.
54       * @param   failure is this a failure state?
55       * @param   code    code of this state.
56       * @throws  IllegalArgumentException    text == <code>null</code>
57       */
58      private DependencyState(final String text, final boolean failure, final int code) {
59          super(text, failure, code);
60      }
61  
62      /**
63       * Are all required modules loaded?
64       *
65       * @return  Are all required modules loaded?
66       */
67      public boolean areAllRequiredLoaded() {
68          return getCode() == STATE_LOADED_REQUIRED_MODULES.getCode();
69      }
70  
71  
72  }