View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      https://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,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.commons.statistics.distribution;
18  
19  import java.util.Locale;
20  
21  /**
22   * Contains the names for the standard tests.
23   * These names are used as keys in the test resource properties files.
24   */
25  enum TestName {
26      PDF,
27      LOGPDF,
28      PMF,
29      LOGPMF,
30      CDF,
31      SF,
32      CDF_HP,
33      SF_HP,
34      ICDF,
35      ISF,
36      CDF_MAPPING,
37      SF_MAPPING,
38      CDF_HP_MAPPING,
39      SF_HP_MAPPING,
40      COMPLEMENT,
41      CONSISTENCY,
42      OUTSIDE_SUPPORT,
43      SAMPLING,
44      SAMPLING_PMF,
45      INTEGRALS,
46      SUPPORT,
47      MOMENTS,
48      MEDIAN,
49      PMF_SUM;
50  
51      /** Cache the values for use in string conversion. */
52      private static final TestName[] VALUES = values();
53  
54      /** The test name as a String. */
55      private final String name;
56  
57      /**
58       * Create an instance.
59       */
60      TestName() {
61          name = this.name().toLowerCase(Locale.ROOT).replace('_', '.');
62      }
63  
64      @Override
65      public String toString() {
66          return name;
67      }
68  
69      /**
70       * Get the instance from the String representation.
71       *
72       * @param key String representation.
73       * @return the instance (or null)
74       */
75      static TestName fromString(String key) {
76          for (final TestName v : VALUES) {
77              if (v.name.equals(key)) {
78                  return v;
79              }
80          }
81          return null;
82      }
83  }
84