001/* 002 * Copyright (c) 2010-2025 Mark Allen, Norbert Bartels. 003 * 004 * Permission is hereby granted, free of charge, to any person obtaining a copy 005 * of this software and associated documentation files (the "Software"), to deal 006 * in the Software without restriction, including without limitation the rights 007 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 008 * copies of the Software, and to permit persons to whom the Software is 009 * furnished to do so, subject to the following conditions: 010 * 011 * The above copyright notice and this permission notice shall be included in 012 * all copies or substantial portions of the Software. 013 * 014 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 015 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 016 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 017 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 018 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 019 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 020 * THE SOFTWARE. 021 */ 022package com.restfb; 023 024import java.util.Arrays; 025 026public enum Version { 027 028 /** 029 * unversiond api 030 */ 031 UNVERSIONED(null), 032 033 /** 034 * <tt>Graph API 12.0</tt>, available until February 8th, 2024 035 * 036 * @since September 14th, 2021 037 */ 038 @Deprecated 039 VERSION_12_0("v12.0"), 040 041 /** 042 * <tt>Graph API 13.0</tt>, available until May 28th, 2024 043 * 044 * @since February 8th, 2022 045 */ 046 @Deprecated 047 VERSION_13_0("v13.0"), 048 049 /** 050 * <tt>Graph API 14.0</tt>, available until September 17th, 2024 051 * 052 * @since May 25th, 2022 053 */ 054 @Deprecated 055 VERSION_14_0("v14.0"), 056 057 /** 058 * <tt>Graph API 15.0</tt>, available until February 2nd, 2025 059 * 060 * @since September 17th, 2022 061 */ 062 @Deprecated 063 VERSION_15_0("v15.0"), 064 065 /** 066 * <tt>Graph API 16.0</tt>, available until May 23, 2025 067 * 068 * @since February 2nd, 2023 069 */ 070 @Deprecated 071 VERSION_16_0("v16.0"), 072 073 /** 074 * <tt>Graph API 17.0</tt>, available until September 12, 2025 075 * 076 * @since May 23, 2023 077 */ 078 VERSION_17_0("v17.0"), 079 080 /** 081 * <tt>Graph API 18.0</tt>, available at least until January 23, 2026 082 * 083 * @since September 12, 2023 084 */ 085 VERSION_18_0("v18.0"), 086 087 /** 088 * <tt>Graph API 19.0</tt>, available at least until May 21, 2026 089 * 090 * @since January 23, 2024 091 */ 092 VERSION_19_0("v19.0"), 093 094 /** 095 * <tt>Graph API 20.0</tt>, available at least until September 24, 2026 096 * 097 * @since May 21, 2024 098 */ 099 VERSION_20_0("v20.0"), 100 101 /** 102 * <tt>Graph API 21.0</tt>, available at least until January 21, 2027 103 * 104 * @since October 2, 2024 105 */ 106 VERSION_21_0("v21.0"), 107 108 /** 109 * <tt>Graph API 22.0</tt>, available at least until May 29, 2027 110 * 111 * @since January 21, 2025 112 */ 113 VERSION_22_0("v22.0"), 114 115 /** 116 * <tt>Graph API 23.0</tt>, available at least until May 2027 117 * 118 * @since May 29, 2025 119 */ 120 VERSION_23_0("v23.0"), 121 122 /** 123 * convenience enum to provide simple access to the latest supported Graph API Version. 124 * <p> 125 * the current version is <tt>Graph API 23.0</tt> 126 * </p> 127 */ 128 LATEST("v23.0"), 129 130 /** 131 * <tt>Threads API 1.0</tt>, according to the documentation, this is the first Threads API Version 132 */ 133 THREADS_1_0("v1.0"), 134 135 /** 136 * convenience enum to provide simple access to the latest supported Threads API Version. 137 */ 138 THREADS_LATEST("v1.0"); 139 140 private final String urlElement; 141 142 Version(String urlElement) { 143 this.urlElement = urlElement; 144 } 145 146 public String getUrlElement() { 147 return this.urlElement; 148 } 149 150 public boolean isUrlElementRequired() { 151 return null != this.urlElement; 152 } 153 154 /** 155 * converts a String (for example the url parameter) into a Version object 156 * 157 * @param urlElementStr 158 * String that should 159 * @return the generated version 160 */ 161 public static Version getVersionFromString(String urlElementStr) { 162 if (urlElementStr == null) { 163 return UNVERSIONED; 164 } 165 166 return Arrays.stream(Version.values()).filter(v -> urlElementStr.equals(v.getUrlElement())).findFirst() 167 .orElse(UNVERSIONED); 168 } 169}