001/* 002 * Copyright (c) 2010-2026 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 18.0</tt>, available at least until January 23, 2026 035 * 036 * @since September 12, 2023 037 */ 038 @Deprecated 039 VERSION_18_0("v18.0"), 040 041 /** 042 * <tt>Graph API 19.0</tt>, available at least until May 21, 2026 043 * 044 * @since January 23, 2024 045 */ 046 @Deprecated 047 VERSION_19_0("v19.0"), 048 049 /** 050 * <tt>Graph API 20.0</tt>, available at least until September 24, 2026 051 * 052 * @since May 21, 2024 053 */ 054 VERSION_20_0("v20.0"), 055 056 /** 057 * <tt>Graph API 21.0</tt>, available at least until January 21, 2027 058 * 059 * @since October 2, 2024 060 */ 061 VERSION_21_0("v21.0"), 062 063 /** 064 * <tt>Graph API 22.0</tt>, available at least until May 29, 2027 065 * 066 * @since January 21, 2025 067 */ 068 VERSION_22_0("v22.0"), 069 070 /** 071 * <tt>Graph API 23.0</tt>, available at least until October 8, 2027 072 * 073 * @since May 29, 2025 074 */ 075 VERSION_23_0("v23.0"), 076 077 /** 078 * <tt>Graph API 24.0</tt>, available at least until October 2027 079 * 080 * @since October 8, 2025 081 */ 082 VERSION_24_0("v24.0"), 083 084 /** 085 * <tt>Graph API 25.0</tt>, available at least until July 2028 086 * 087 * @since February 18, 2026 088 */ 089 VERSION_25_0("v25.0"), 090 091 /** 092 * <tt>Graph API 25.0</tt>, available at least until February 2028 093 * 094 * @since July 29, 2026 095 */ 096 VERSION_26_0("v26.0"), 097 098 /** 099 * convenience enum to provide simple access to the latest supported Graph API Version. 100 * <p> 101 * the current version is <tt>Graph API 26.0</tt> 102 * </p> 103 */ 104 LATEST("v26.0"), 105 106 /** 107 * <tt>Threads API 1.0</tt>, according to the documentation, this is the first Threads API Version 108 */ 109 THREADS_1_0("v1.0"), 110 111 /** 112 * convenience enum to provide simple access to the latest supported Threads API Version. 113 */ 114 THREADS_LATEST("v1.0"); 115 116 private final String urlElement; 117 118 Version(String urlElement) { 119 this.urlElement = urlElement; 120 } 121 122 public String getUrlElement() { 123 return this.urlElement; 124 } 125 126 public boolean isUrlElementRequired() { 127 return null != this.urlElement; 128 } 129 130 /** 131 * converts a String (for example the url parameter) into a Version object 132 * 133 * @param urlElementStr 134 * String that should 135 * @return the generated version 136 */ 137 public static Version getVersionFromString(String urlElementStr) { 138 if (urlElementStr == null) { 139 return UNVERSIONED; 140 } 141 142 return Arrays.stream(Version.values()).filter(v -> urlElementStr.equals(v.getUrlElement())).findFirst() 143 .orElse(UNVERSIONED); 144 } 145}