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 module state. Every instance of this class is unique.
23   *
24   * @author  Michael Meyling
25   */
26  public final class LoadingImportsState extends AbstractState implements State {
27  
28      /** Undefined loading state. */
29      public static final LoadingImportsState STATE_UNDEFINED = new LoadingImportsState(
30          LoadingImportsStateDescriptions.STATE_STRING_UNDEFINED, false,
31          LoadingImportsStateDescriptions.STATE_CODE_UNDEFINED);
32  
33      /** Loading directly required (= imported) modules. */
34      public static final LoadingImportsState STATE_LOADING_IMPORTS = new LoadingImportsState(
35          LoadingImportsStateDescriptions.STATE_STRING_LOADING_IMPORTS, false,
36          LoadingImportsStateDescriptions.STATE_CODE_LOADING_IMPORTS);
37  
38      /** Loading directly required modules failed. */
39      public static final LoadingImportsState STATE_LOADING_IMPORTS_FAILED = new LoadingImportsState(
40          LoadingImportsStateDescriptions.STATE_STRING_LOADING_IMPORTS_FAILED, true,
41          LoadingImportsStateDescriptions.STATE_CODE_LOADING_IMPORTS_FAILED);
42  
43      /** All directly required modules are loaded. */
44      public static final LoadingImportsState STATE_LOADED_IMPORTED_MODULES = new LoadingImportsState(
45          LoadingImportsStateDescriptions.STATE_STRING_LOADED_IMPORTED_MODULES, false,
46          LoadingImportsStateDescriptions.STATE_CODE_LOADED_IMPORTED_MODULES);
47  
48  
49      /**
50       * Creates new module state.
51       *
52       * @param   text    meaning of this state, <code>null</code> is not permitted.
53       * @param   failure is this a failure state?
54       * @param   code    code of this state.
55       * @throws  IllegalArgumentException    text == <code>null</code>
56       */
57      private LoadingImportsState(final String text, final boolean failure, final int code) {
58          super(text, failure, code);
59      }
60  
61      /**
62       * Are all directly required modules loaded?
63       *
64       * @return  Are all directly imported modules loaded?
65       */
66      public boolean areAllDirectlyRequiredLoaded() {
67          return getCode() == STATE_LOADED_IMPORTED_MODULES.getCode();
68      }
69  
70  }