Debian Codegraph @

src/ch/poole/openinghoursparser/WeekDay.java

raw symbols SCIP
1 package ch.poole.openinghoursparser;
2
3 import java.util.ArrayList;
4 import java.util.List;
5
6 import static ch.poole.openinghoursparser.I18n.tr;
7
8 /**
9 * Container for objects from the opening_hours specification
10 *
11 * @author Simon Poole
12 *
13 * Copyright (c) 2015 Simon Poole
14 *
15 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
16 * documentation files (the "Software"), to deal in the Software without restriction, including without
17 * limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
18 * Software, and to permit persons to whom the Software is furnished to do so, subject to the following
19 * conditions:
20 *
21 * The above copyright notice and this permission notice shall be included in all copies or substantial portions
22 * of the Software.
23 *
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
25 * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
27 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE " OR THE USE OR OTHER
28 * DEALINGS IN THE SOFTWARE.
29 */
30 public enum WeekDay {
31 MO("Mo"), TU("Tu"), WE("We"), TH("Th"), FR("Fr"), SA("Sa"), SU("Su");
32
33 private final String name;
34
35 /**
36 * Construct a new member of the enum
37 *
38 * @param name the name as a String
39 */
40 WeekDay(String name) {
41 this.name = name;
42 }
43
44 @Override
45 public String toString() {
46 return name;
47 }
48
49 /**
50 * Get the WeekDay value for a String
51 *
52 * @param day the WeekDay as a String
53 * @return a WeekDay or null
54 */
55 public static WeekDay getValue(String day) {
56 for (WeekDay w : WeekDay.values()) {
57 if (w.toString().equals(day)) {
58 return w;
59 }
60 }
61 throw new IllegalArgumentException(tr("invalid_week_day", day));
62 }
63
64 /**
65 * Get list of all values as Strings
66 *
67 * @return a List with all values
68 */
69 public static List<String> nameValues() {
70 List<String> result = new ArrayList<>();
71 for (WeekDay w : values()) {
72 result.add(w.toString());
73 }
74 return result;
75 }
76 }