Class | Line # | Actions | |||||
---|---|---|---|---|---|---|---|
TimePeriodType | 28 | 6 | 0% | 4 | 1 |
1 | /* | |
2 | * See the NOTICE file distributed with this work for additional | |
3 | * information regarding copyright ownership. | |
4 | * | |
5 | * This is free software; you can redistribute it and/or modify it | |
6 | * under the terms of the GNU Lesser General Public License as | |
7 | * published by the Free Software Foundation; either version 2.1 of | |
8 | * the License, or (at your option) any later version. | |
9 | * | |
10 | * This software 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 GNU | |
13 | * Lesser General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU Lesser General Public | |
16 | * License along with this software; if not, write to the Free | |
17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | |
18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | |
19 | */ | |
20 | package org.xwiki.chart.time; | |
21 | ||
22 | /** | |
23 | * Enumeration of supported time period types. | |
24 | * | |
25 | * @version $Id: 9487da3dfb45cf5e731210d4c0db53da53a7bbbc $ | |
26 | * @since 4.2M1 | |
27 | */ | |
28 | public enum TimePeriodType | |
29 | { | |
30 | /** Millisecond. */ | |
31 | MILLISECOND("millisecond"), | |
32 | /** Second. */ | |
33 | SECOND("second"), | |
34 | /** Minute. */ | |
35 | MINUTE("minute"), | |
36 | /** Hour. */ | |
37 | HOUR("hour"), | |
38 | /** A day. */ | |
39 | DAY("day"), | |
40 | /** Week. */ | |
41 | WEEK("week"), | |
42 | /** Month. */ | |
43 | MONTH("month"), | |
44 | /** Qarter of a year. */ | |
45 | QUARTER("quarter"), | |
46 | /** Year. */ | |
47 | YEAR("year"), | |
48 | /** A simple (irregular) time period. */ | |
49 | SIMPLE("simple"); | |
50 | ||
51 | /** The name. */ | |
52 | private final String name; | |
53 | ||
54 | /** | |
55 | * @param name the name. | |
56 | */ | |
57 | 10 | TimePeriodType(String name) |
58 | { | |
59 | 10 | this.name = name; |
60 | } | |
61 | ||
62 | /** @return the name. */ | |
63 | 30 | public String getName() |
64 | { | |
65 | 30 | return name; |
66 | } | |
67 | ||
68 | /** | |
69 | * @param name A plot type. | |
70 | * @return the axis type corresponding to the name, or {@code null}. | |
71 | */ | |
72 | 4 | public static TimePeriodType forName(String name) |
73 | { | |
74 | 4 | for (TimePeriodType type : values()) |
75 | { | |
76 | 30 | if (name.equals(type.getName())) { |
77 | 4 | return type; |
78 | } | |
79 | } | |
80 | ||
81 | 0 | return null; |
82 | } | |
83 | ||
84 | } |