--- /dev/null
+/*
+ * Copyright (c) 2017. Developed by Hedgecode.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.hedgecode.snooker.api;
+
+import java.util.Calendar;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * Season Entity.
+ *
+ * @author Dmitry Samoshin aka gotty
+ */
+public class Season {
+
+ private static final Calendar CURRENT_CALENDAR = Calendar.getInstance();
+
+ public static final int BEGIN_YEAR = 2005;
+ public static final int CURRENT_YEAR =
+ CURRENT_CALENDAR.get(Calendar.MONTH) >= 6
+ ? CURRENT_CALENDAR.get(Calendar.YEAR)
+ : CURRENT_CALENDAR.get(Calendar.YEAR) - 1;
+
+ private static final int ALL_SEASONS = -1;
+
+ public static final Season ALL = new Season(ALL_SEASONS);
+ public static final Season CURRENT_SEASON = new Season(CURRENT_YEAR);
+
+ public static Map<Integer, Season> SEASONS = new LinkedHashMap<>();
+
+ static {
+ for (int year = BEGIN_YEAR; year < CURRENT_YEAR; ++year) {
+ SEASONS.put(year, new Season(year));
+ }
+ SEASONS.put(CURRENT_YEAR, CURRENT_SEASON);
+ SEASONS.put(ALL_SEASONS, ALL);
+ }
+
+ private int year;
+
+ private Season(int year) {
+ this.year = year;
+ }
+
+ public static Season getSeason(int year) {
+ return SEASONS.get(year);
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ @Override
+ public String toString() {
+ return year == ALL_SEASONS ? "All Seasons" : year + "/" + (year + 1);
+ }
+
+}