Skip to content

Commit 9b4fc4e

Browse files
committed
Update DeprecatedSince style and Site enum
1 parent 89d10d4 commit 9b4fc4e

File tree

3 files changed

+165
-50
lines changed

3 files changed

+165
-50
lines changed

.github/CONTRIBUTING.md

Lines changed: 46 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -91,41 +91,63 @@ In most cases will you only update `{build}` and nothing else. If you're unsure
9191
Please **do not change already existing since annotations**. This also includes adding ones to already existing methods/classes.
9292

9393
### Deprecated methods
94+
> Please also see the [Deprecation Policy](#deprecation-policy) about how to handle deprecations
95+
9496
If you're deprecating a method will you need to add the `@Deprecated` annotation and also include a `@deprecated` tag in the comment explain why it was deprecated and mention possible replacements.
9597

96-
You also need to add the `@DeprecatedSince` annotation to indicate since when a method is deprecated. This annotation has a required version field and an optional replacements field.
97-
You may also add the `@PlannedRemoval` annotation if the object is planned to be removed in a future release. This annotation has a required version field, which indicate in what version the object will be removed.
98-
The specified version has to be at least 2 versions away from the one that the object got deprecated in (i.e. deprecating a method in `5.2.0` will require you to set the version to at least `5.2.2` in the `PlannedRemoval` annotation).
98+
You also need to add the `@DeprecatedSince` annotation to indicate since when a method is deprecated. This annotation has the fields `major`, `minor`, `patch` and `replacement` from which the last one is optional.
99+
You may also add the `@PlannedRemoval` annotation if the object is planned to be removed in a future release. This annotation has a `major`, `minor` and `patch` field to mark the version for when the object is removed.
100+
101+
### CheckUtil
102+
JavaBotBlockAPI has a CheckUtil with some static void methods for checking various things such as if a String is empty.
103+
104+
When using any methods of the CheckUtil should you add the following text to the Javadoc comment as its own Paragraph:
105+
```java
106+
/**
107+
* <p>Following Exceptions can be thrown from the {@link org.botblock.javabotblockapi.core.CheckUtil CheckUtil}:
108+
* <ul>
109+
* <li>{@link java.lang.NullPointerException NullPointerException} - Mention the cause here.</li>
110+
* <li>{@link java.lang.IllegalStateException IllegalStateException} - Mention the cause here.</li>
111+
* </ul>
112+
*/
113+
```
114+
115+
The CheckUtil has the following methods which can have the mentioned Excpetions:
116+
117+
- `ChekUtil#notEmpty(String value, String name)` - Checks the String "value" is empty and throws a NullPointerException with the message `name + " may not be empty."` in such a case.
118+
- `CheckUtil#notEmpty(Map<?, ?> value, String name)` - Checks if the Map "value" is empty and throws a NullPointerException with the message `name + " may not be empty."` in such a case.
119+
- `CheckUtil#condition(boolean expression, String message)` - Checks if the boolean "expression" returns true and throws a IllegalStateException with the message `message`.
99120

100121
### Other Styling
101122
Please make sure that all text is on the same vertical line (block).
102123
This means that when f.e. a `@return` is used, that you have to use two spaces after `@param` instead of one.
103124

104125
### Order of the parts
105-
Here is an example of the different parts being used:
126+
Here is an example of using the different parts together:
106127
```java
107128
/**
108129
* Adds "Bar" to the provided text.
109130
* <br>Will throw an error when not providing text.
131+
*
132+
* <p>Following Exceptions can be thrown from the {@link org.botblock.javabotblockapi.core.CheckUtil CheckUtil}:
133+
* <ul>
134+
* <li>{@link java.lang.NullPointerException NullPointerException} - When foo is empty.</li>
135+
* </ul>
110136
*
111137
* @param foo
112138
* The text that should get "Bar" added to it.
113139
*
114140
* @return The provided String with "Bar" added to it.
115141
*
116-
* @throws IllegalArgumentException
117-
* When the provided String is empty/null.
118-
*
119-
* @since v1.0.0
142+
* @since 1.0.0
120143
*
121144
* @deprecated Use {@link #getFooBar() getFooBar()} instead.
122145
*/
123146
@Deprecated
124-
@DeprecatedSince(version = "1.0.0", replacements = {"#getFooBar"}) // If you deprecate a method, add this one too.
125-
@PlannedRemoval(version = "1.0.2") // When the objects gets removed in the future, add this annotation.
126-
public String getFooBar(String foo) throws IllegalArgumentException{
127-
if(foo.isEmpty())
128-
throw new IllegalArgumentException("foo may not be empty");
147+
@DeprecatedSince(major = 1, minor = 0, patch = 0, replacements = {"#getFooBar"}) // If you deprecate a method, add this one too.
148+
@PlannedRemoval(major = 1, minor = 0, patch = 2)
149+
public String getFooBar(@Nonnull String foo){
150+
CheckUtil.notEmpty(foo, "Foo");
129151

130152
return foo + "Bar";
131153
}
@@ -135,14 +157,23 @@ public String getFooBar(String foo) throws IllegalArgumentException{
135157
*
136158
* @return {@code "foobar"}
137159
*
138-
* @since v1.0.1
160+
* @since 1.0.1
139161
*/
140162
public String getFooBar(){
141163
return "foobar";
142164
}
143165
```
144166

167+
## Deprecation Policy
168+
To not fully break the Wrapper on each release do we follow a general deprecation policy, to give people time to move to any replacement method, if available.
169+
170+
If possible should always a replacement method, field or other object be provided when deprecating an object.
171+
Any deprecated method is also planned for removal which is indicated by the `@PlannedRemoval` annotation. The version you define there has to be at least two patch-versions from the one the object became deprecated.
172+
This means that deprecating a method in `6.2.0` results in the major, minor and patch version of the annotation to display `6`, `2` and `2` respectively.
173+
174+
At **no point** should an object just be removed. We always mark it as deprecated first and give the aforementioned minimal delay for people to update, before removing it completely.
175+
145176
## [Code of Conduct]
146177
We want to give everyone a chance to contribute to the project.
147-
So please keep your comments and messages nice. Every message that is considered rasist, insulting or similar will be removed.
178+
So please keep your comments and messages nice. Every message that is considered racist, insulting or similar will be removed.
148179
If you continue to send those messages will we permanently remove you from this repository.

core/src/main/java/org/botblock/javabotblockapi/core/Site.java

Lines changed: 88 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717
*/
1818
package org.botblock.javabotblockapi.core;
1919

20+
import org.botblock.javabotblockapi.core.annotations.DeprecatedSince;
21+
import org.botblock.javabotblockapi.core.annotations.PlannedRemoval;
22+
23+
import java.util.Arrays;
24+
import java.util.List;
25+
2026
/**
2127
* Enum class containing all sites currently supported by BotBlock.org.
2228
*
@@ -27,164 +33,184 @@ public enum Site {
2733
/**
2834
* <a href="https://arcane-center.xyz" target="_blank">arcane-center.xyz</a>
2935
*/
30-
ARCANE_CENTER_XYZ("arcane-center.xyz", true, true),
36+
ARCANE_CENTER_XYZ("arcane-center.xyz", new HttpMethod[]{HttpMethod.POST}),
37+
38+
/**
39+
* <a href="https://bladebotlist.xyz" target="_blanK">bladebotlist.xyz</a>
40+
*
41+
* @since 6.3.0
42+
*/
43+
BLADEBOTLIST_XYZ("bladebotlist.xyz", new HttpMethod[]{HttpMethod.GET, HttpMethod.POST}),
3144

3245
/**
3346
* <a href="https://blist.xyz" target="_blank">blist.xyz</a>
3447
*/
35-
BLIST_XYZ("blist.xyz", true, true),
48+
BLIST_XYZ("blist.xyz", new HttpMethod[]{HttpMethod.GET, HttpMethod.POST}),
3649

3750
/**
3851
* <a href="https://botlist.space" target="_blank">botlist.space</a>
3952
*/
40-
BOTLIST_SPACE("botlist.space", true, true),
53+
BOTLIST_SPACE("botlist.space", new HttpMethod[]{HttpMethod.GET, HttpMethod.POST}),
4154

4255
/**
4356
* <a href="https://botsdatabase.com" target="_blank">botsdatabase.com</a>
4457
*/
45-
BOTSDATABASE_COM("botsdatabase.com", true, true),
58+
BOTSDATABASE_COM("botsdatabase.com", new HttpMethod[]{HttpMethod.GET, HttpMethod.POST}),
4659

4760
/**
4861
* <a href="https://bots.discordlabs.org" target="_blank">bots.discordlabs.org</a>
4962
*/
50-
BOTS_DISCORDLABS_ORG("bots.discordlabs.org", true, true),
63+
BOTS_DISCORDLABS_ORG("bots.discordlabs.org", new HttpMethod[]{HttpMethod.GET, HttpMethod.POST}),
5164

5265
/**
5366
* <a href="https://botsfordiscord.com" target="_blank">botsfordiscord.com</a>
5467
*/
55-
BOTSFORDISCORD_COM("botsfordiscord.com", true, true),
68+
BOTSFORDISCORD_COM("botsfordiscord.com", new HttpMethod[]{HttpMethod.GET, HttpMethod.POST}),
5669

5770
/**
5871
* <a href="https://bots.ondiscord.xyz" target="_blank">bots.ondiscord.xyz</a>
5972
*/
60-
BOTS_ONDISCORD_XYZ("bots.ondiscord.xyz", true, true),
73+
BOTS_ONDISCORD_XYZ("bots.ondiscord.xyz", new HttpMethod[]{HttpMethod.POST}),
6174

6275
/**
6376
* <a href="https://dblista.pl" target="_blank">dblista.pl</a>
6477
*/
65-
DBLISTA_PL("dblista.pl", true, true),
78+
DBLISTA_PL("dblista.pl", new HttpMethod[]{HttpMethod.GET}),
6679

6780
/**
6881
* <a href="https://discordapps.dev" target="_blank">discordapps.dev</a>
6982
*/
70-
DISCORDAPPS_DEV("discordapps.dev", true, true),
83+
DISCORDAPPS_DEV("discordapps.dev", new HttpMethod[]{HttpMethod.GET, HttpMethod.POST}),
7184

7285
/**
7386
* <a href="https://discord.boats" target="_blank">discord.boats</a>
7487
*/
75-
DISCORD_BOATS("discord.boats", true, true),
88+
DISCORD_BOATS("discord.boats", new HttpMethod[]{HttpMethod.GET, HttpMethod.POST}),
7689

7790
/**
7891
* <a href="https://discordbotdirectory.net" target="_blank">discordbotdirectory.net</a>
7992
*
8093
* @since 6.3.0
8194
*/
82-
DISCORDBOTDIRECTORY_NET("discordbotdirectory.net", true, false),
95+
DISCORDBOTDIRECTORY_NET("discordbotdirectory.net", new HttpMethod[]{HttpMethod.GET}),
8396

8497
/**
8598
* <a href="https://discordbotlist.com" target="_blank">discordbotlist.com</a>
8699
*/
87-
DISCORDBOTLIST_COM("discordbotlist.com", true, true),
100+
DISCORDBOTLIST_COM("discordbotlist.com", new HttpMethod[]{HttpMethod.GET, HttpMethod.POST}),
88101

89102
/**
90103
* <a href="https://discordbots.co" target="_blank">discordbots.co</a>
91104
*
92105
* @since 5.2.3
93106
*/
94-
DISCORDBOTS_CO("discordbots.co", true, true),
107+
DISCORDBOTS_CO("discordbots.co", new HttpMethod[]{HttpMethod.GET, HttpMethod.POST}),
95108

96109
/**
97110
* <a href="https://discord.bots.gg" target="_blank">discord.bots.gg</a>
98111
*/
99-
DISCORD_BOTS_GG("discord.bots.gg", true, true),
112+
DISCORD_BOTS_GG("discord.bots.gg", new HttpMethod[]{HttpMethod.GET, HttpMethod.POST}),
100113

101114
/**
102115
* <a href="https://discordbots.fun" target="_blank">discordbots.fun</a>
116+
*
117+
* @deprecated No longer exists
103118
*/
104-
DISCORDBOTS_FUN("discordbots.fun", true, true),
119+
@Deprecated
120+
@DeprecatedSince(major = 6, minor = 3, patch = 0)
121+
@PlannedRemoval(major = 6, minor = 3, patch = 2)
122+
DISCORDBOTS_FUN("discordbots.fun", new HttpMethod[0]),
105123

106124
/**
107125
* <a href="https://discordextremelist.xyz" target="_blank">discordextremelist.xyz</a>
108126
*
109127
* @since 2.3.3
110128
*/
111-
DISCORDEXTREMELIST_XYZ("discordextremelist.xyz", true, true),
129+
DISCORDEXTREMELIST_XYZ("discordextremelist.xyz", new HttpMethod[]{HttpMethod.GET, HttpMethod.POST}),
112130

113131
/**
114132
* <a href="https://discordlist.co" target="_blank">discordlist.co</a>
133+
*
134+
* @deprecated No longer exists
115135
*/
116-
DISCORDLIST_CO("discordlist.co", true, true),
136+
@Deprecated
137+
@DeprecatedSince(major = 6, minor = 3, patch = 0)
138+
@PlannedRemoval(major = 6, minor = 3, patch = 2)
139+
DISCORDLIST_CO("discordlist.co", new HttpMethod[0]),
117140

118141
/**
119142
* <a href="https://discordlistology.com" target="_blank">discordlistology.com</a>
120143
*
121144
* @since 5.2.1
122145
*/
123-
DISCORDLISTOLOGY_COM("discordlistology.com", true, true),
146+
DISCORDLISTOLOGY_COM("discordlistology.com", new HttpMethod[]{HttpMethod.GET, HttpMethod.POST}),
124147

125148
/**
126149
* <a href="https://disforge.com/bots" target="_blank">disforge.com</a>
127150
*
128151
* @since 6.2.2
129152
*/
130-
DISFORGE_COM("disforge.com", true, true),
153+
DISFORGE_COM("disforge.com", new HttpMethod[]{HttpMethod.POST}),
131154

132155
/**
133156
* <a href="https://glennbotlist.xyz" target="_blank">glennbotlist.xyz</a>
157+
*
158+
* @deprecated No longer exists
134159
*/
135-
GLENNBOTLIST_XYZ("glennbotlist.xyz", true, true),
160+
@Deprecated
161+
@DeprecatedSince(major = 6, minor = 3, patch = 0)
162+
@PlannedRemoval(major = 6, minor = 3, patch = 2)
163+
GLENNBOTLIST_XYZ("glennbotlist.xyz", new HttpMethod[0]),
136164

137165
/**
138166
* <a href="https://hydrogenbots.club" target="_blank">hydrogenbots.club</a>
139167
*
140168
* @since 6.2.1
141169
*/
142-
HYDROGENBOTS_CLUB("hydrogenbots.club", true, true),
170+
HYDROGENBOTS_CLUB("hydrogenbots.club", new HttpMethod[]{HttpMethod.GET, HttpMethod.POST}),
143171

144172
/**
145173
* <a href="https://mythicalbots.xyz" target="_blank">mythicalbots.xyz</a>
146174
*/
147-
MYTHICALBOTS_XYZ("mythicalbots.xyz", true, true),
175+
MYTHICALBOTS_XYZ("mythicalbots.xyz", new HttpMethod[]{HttpMethod.GET, HttpMethod.POST}),
148176

149177
/**
150178
* <a href="https://space-bot-list.xyz" target="_blank">space-bot-list.xyz</a>
151179
*/
152-
SPACE_BOT_LIST_XYZ("space-bot-list.xyz", true, true),
180+
SPACE_BOT_LIST_XYZ("space-bot-list.xyz", new HttpMethod[]{HttpMethod.GET, HttpMethod.POST}),
153181

154182
/**
155183
* <a href="https://topcord.xyz" target="_blank">topcord.xyz</a>
156184
*/
157-
TOPCORD_XYZ("topcord.xyz", true, true),
185+
TOPCORD_XYZ("topcord.xyz", new HttpMethod[]{HttpMethod.GET, HttpMethod.POST}),
158186

159187
/**
160188
* <a href="https://voidbots.net" target="_blank">voidbots.net</a>
161189
*
162190
* @since 6.3.0
163191
*/
164-
VOIDBOTS_NET("voidbots.net", true, true),
192+
VOIDBOTS_NET("voidbots.net", new HttpMethod[]{HttpMethod.GET, HttpMethod.POST}),
165193

166194
/**
167195
* <a href="https://wonderbotlist.com" target="_blank">wonderbotlist.com</a>
168196
*/
169-
WONDERBOTLIST_COM("wonderbotlist.com", true, true),
197+
WONDERBOTLIST_COM("wonderbotlist.com", new HttpMethod[]{HttpMethod.GET, HttpMethod.POST}),
170198

171199
/**
172200
* <a href="https://yabl.xyz" target="_blank">yabl.xyz</a>
173201
*
174202
* @since 2.1.1
175203
*/
176-
YABL_XYZ("yabl.xyz", true, true);
204+
YABL_XYZ("yabl.xyz", new HttpMethod[]{HttpMethod.GET, HttpMethod.POST});
177205

178206
private final String site;
179207

180-
private final boolean hasGet;
181-
private final boolean hasPost;
208+
private final List<HttpMethod> methods;
182209

183-
Site(String site, boolean hasGet, boolean hasPost){
210+
Site(String site, HttpMethod[] methods){
184211
this.site = site;
185212

186-
this.hasGet = hasGet;
187-
this.hasPost = hasPost;
213+
this.methods = Arrays.asList(methods);
188214
}
189215

190216
/**
@@ -196,11 +222,39 @@ public String getSite(){
196222
return this.site;
197223
}
198224

225+
/**
226+
* Returns if the Site supports GET requests for retrieving Bot information.
227+
* <br>This is only used in GetBotAction methods as the BotBlock API will return list information no matter what.
228+
*
229+
* @return Whether this Site supports GET requests for retrieval of Bot information or not.
230+
*/
231+
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
199232
public boolean supportsGet(){
200-
return hasGet;
233+
return methods.contains(HttpMethod.GET);
201234
}
202235

236+
/**
237+
* Returns if the Site supports POST requests for submiting bot information.
238+
* <br>This is used for the {@link org.botblock.javabotblockapi.core.BotBlockAPI.Builder BotBlockAPI Builder}.
239+
*
240+
* @return Whether this Site supports POST requests for submiting Bot information to them.
241+
*/
203242
public boolean supportsPost(){
204-
return hasPost;
243+
return methods.contains(HttpMethod.POST);
244+
}
245+
246+
/**
247+
* Enum containing the different Http Request methods a bot list could have.
248+
*/
249+
public enum HttpMethod{
250+
/**
251+
* The Bot List supports GETting information about a specific bot.
252+
*/
253+
GET,
254+
255+
/**
256+
* The Bot List supports POSTing information of a bot to their site.
257+
*/
258+
POST
205259
}
206260
}

0 commit comments

Comments
 (0)