View Javadoc
1   /*
2    * Metis: Java Data Framework
3    * Copyright 2012-2026. Tony Washer
4    *
5    * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6    * use this file except in compliance with the License.  You may obtain a copy
7    * of the License at
8    *
9    *   http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
14   * License for the specific language governing permissions and limitations under
15   * the License.
16   */
17  package io.github.tonywasher.joceanus.metis.viewer;
18  
19  import io.github.tonywasher.joceanus.oceanus.resource.OceanusBundleId;
20  
21  /**
22   * Standard Viewer Entries.
23   */
24  public enum MetisViewerStandardEntry {
25      /**
26       * Error entry.
27       */
28      ERROR,
29  
30      /**
31       * Profile entry.
32       */
33      PROFILE,
34  
35      /**
36       * Data entry.
37       */
38      DATA,
39  
40      /**
41       * Updates entry.
42       */
43      UPDATES,
44  
45      /**
46       * View entry.
47       */
48      VIEW,
49  
50      /**
51       * Preferences entry.
52       */
53      PREFERENCES;
54  
55      /**
56       * The String name.
57       */
58      private String theName;
59  
60      @Override
61      public String toString() {
62          /* If we have not yet loaded the name */
63          if (theName == null) {
64              /* Load the name */
65              theName = bundleIdForEntry(this).getValue();
66          }
67  
68          /* return the name */
69          return theName;
70      }
71  
72      /**
73       * Obtain the resource bundleId for the entry.
74       *
75       * @param pEntry the entry
76       * @return the resource bundleId
77       */
78      private static OceanusBundleId bundleIdForEntry(final MetisViewerStandardEntry pEntry) {
79          /* Create the map and return it */
80          return switch (pEntry) {
81              case ERROR -> MetisViewerResource.VIEWER_ENTRY_ERROR;
82              case PROFILE -> MetisViewerResource.VIEWER_ENTRY_PROFILE;
83              case DATA -> MetisViewerResource.VIEWER_ENTRY_DATA;
84              case UPDATES -> MetisViewerResource.VIEWER_ENTRY_UPDATES;
85              case VIEW -> MetisViewerResource.VIEWER_ENTRY_VIEW;
86              case PREFERENCES -> MetisViewerResource.VIEWER_ENTRY_PREF;
87              default -> throw new IllegalArgumentException();
88          };
89      }
90  }