001// Generated by delombok at Thu Aug 13 13:56:44 UTC 2026 002/* 003 * Copyright (c) 2010-2026 Mark Allen, Norbert Bartels. 004 * 005 * Permission is hereby granted, free of charge, to any person obtaining a copy 006 * of this software and associated documentation files (the "Software"), to deal 007 * in the Software without restriction, including without limitation the rights 008 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 009 * copies of the Software, and to permit persons to whom the Software is 010 * furnished to do so, subject to the following conditions: 011 * 012 * The above copyright notice and this permission notice shall be included in 013 * all copies or substantial portions of the Software. 014 * 015 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 016 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 017 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 018 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 019 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 020 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 021 * THE SOFTWARE. 022 */ 023package com.restfb.types; 024 025import java.util.Collections; 026import java.util.HashMap; 027import java.util.Map; 028 029public class Hours extends AbstractFacebookType { 030 private Map<DayOfWeek, Map<Integer, Hour>> hours = new HashMap<>(); 031 032 /** 033 * Returns a map of indices and {@link Hour} objects with the open and close time 034 * 035 * @param day 036 * the day the map should be returned for 037 * @return the map containing the index and the {@link Hour} object 038 */ 039 public Map<Integer, Hour> getHours(DayOfWeek day) { 040 if (hours.get(day) == null) { 041 return null; 042 } 043 return Collections.unmodifiableMap(hours.get(day)); 044 } 045 046 /** 047 * returns the complete overview, with the day as key and a map as value 048 * 049 * @return the complete overview 050 */ 051 public Map<DayOfWeek, Map<Integer, Hour>> getHours() { 052 return hours; 053 } 054 055 public boolean addHour(String key, String value) { 056 String dayStr = key.substring(0, 3); 057 DayOfWeek day = DayOfWeek.valueOf(dayStr.toUpperCase()); 058 if (!hours.containsKey(day)) { 059 hours.put(day, new HashMap<>()); 060 } 061 if (key.endsWith("open")) { 062 String indexStr = key.substring(4).replace("_open", ""); 063 hours.get(day).get(createIndex(day, indexStr)).setOpen(value); 064 return true; 065 } 066 if (key.endsWith("close")) { 067 String indexStr = key.substring(4).replace("_close", ""); 068 hours.get(day).get(createIndex(day, indexStr)).setClose(value); 069 return true; 070 } 071 return false; 072 } 073 074 private Integer createIndex(DayOfWeek day, String indexStr) { 075 Integer index = Integer.valueOf(indexStr); 076 if (hours.get(day).get(index) == null) { 077 hours.get(day).put(index, new Hour()); 078 } 079 return index; 080 } 081 082 083 public static class Hour extends AbstractFacebookType { 084 private static final long serialVersionUID = 1L; 085 private String open; 086 private String close; 087 088 @java.lang.SuppressWarnings("all") 089 @lombok.Generated 090 public String getOpen() { 091 return this.open; 092 } 093 094 @java.lang.SuppressWarnings("all") 095 @lombok.Generated 096 public void setOpen(final String open) { 097 this.open = open; 098 } 099 100 @java.lang.SuppressWarnings("all") 101 @lombok.Generated 102 public String getClose() { 103 return this.close; 104 } 105 106 @java.lang.SuppressWarnings("all") 107 @lombok.Generated 108 public void setClose(final String close) { 109 this.close = close; 110 } 111 } 112 113 114 public enum DayOfWeek { 115 MON, TUE, WED, THU, FRI, SAT, SUN; 116 } 117 118 private static final long serialVersionUID = 1L; 119}