Debian Codegraph @

src/dr/inference/trace/TraceType.java

raw symbols SCIP
1 /*
2 * TraceFactory.java
3 *
4 * Copyright (c) 2002-2015 Alexei Drummond, Andrew Rambaut and Marc Suchard
5 *
6 * This file is part of BEAST.
7 * See the NOTICE file distributed with this work for additional
8 * information regarding copyright ownership and licensing.
9 *
10 * BEAST is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as
12 * published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * BEAST is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with BEAST; if not, write to the
22 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23 * Boston, MA 02110-1301 USA
24 */
25
26 package dr.inference.trace;
27
28 /**
29 * The trace type to determine what statistics
30 *
31 * @author Alexei Drummond
32 * @author Walter Xie
33 * @author Andrew Rambaut
34 */
35 public enum TraceType {
36 // changed this to 'real' as this is less Comp Sci. than 'double'
37 REAL("real", "R", Double.class),
38 INTEGER("integer", "I", Integer.class),
39 CATEGORICAL("categorical", "C", String.class),
40 BINARY("binary", "B", Integer.class);
41
42 TraceType(String name, String brief, Class type) {
43 this.name = name;
44 this.brief = brief;
45 this.type = type;
46 }
47
48 public String toString() {
49 return name;
50 }
51
52 public String getBrief() {
53 return brief;
54 }
55
56 private Class getTypeClass() {
57 return type;
58 }
59
60 public boolean isContinuous() {
61 return getTypeClass() == Double.class;
62 }
63
64 /**
65 * is the data type numerical
66 * @return
67 */
68 public boolean isNumber() {
69 return getTypeClass() == Double.class || getTypeClass() == Integer.class;
70 }
71
72 /**
73 * is the datatype ordinal (integer or binary)
74 * @return
75 */
76 public boolean isInteger() {
77 return getTypeClass() == Integer.class;
78 }
79
80 /**
81 * is the datatype discrete (ordinal or categorical)
82 * @return
83 */
84 public boolean isDiscrete() {
85 return isInteger() || isCategorical();
86 }
87
88 /**
89 * is the datatype binary
90 * @return
91 */
92 public boolean isBinary() {
93 return this == BINARY;
94 }
95
96 public boolean isIntegerOrBinary() {
97 return isInteger() || isBinary();
98 }
99
100 /**
101 * is the datatype categorical
102 * @return
103 */
104 public boolean isCategorical() {
105 return getTypeClass() == String.class;
106 }
107
108 private final String name;
109 private final String brief;
110 private final Class type;
111
112 }