Skip to content

Commit 3c6f9d5

Browse files
committed
Add missing Javadocs
1 parent a308715 commit 3c6f9d5

23 files changed

Lines changed: 661 additions & 12 deletions

build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ dependencies {
4343
// Fix Java's service loading, which Flyway uses
4444
tasks.withType<ShadowJar> { mergeServiceFiles() }
4545

46+
// Show warnings for missing Javadocs
47+
tasks.withType<Javadoc> { (options as StandardJavadocDocletOptions).addStringOption("Xdoclint:all", "-quiet") }
48+
4649
setupPublishingEnv(publishingSimpleConfig(
4750
artifactId = "lazy-library",
4851
url = "https://lazy-library.srnyx.com",

src/main/java/xyz/srnyx/lazylibrary/LazyComponent.java

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,29 @@
1010
import org.jetbrains.annotations.Nullable;
1111

1212

13+
/**
14+
* A utility class that provides methods for creating common components used in the bot's responses.
15+
* It includes methods for generating error messages, permission messages, and invalid argument messages, all formatted as Container components.
16+
*/
1317
public class LazyComponent {
18+
/**
19+
* Creates a ContainerChildComponent that contains either a Section with an accessory or just a TextDisplay, depending on whether the accessory is null
20+
*
21+
* @param accessory the SectionAccessoryComponent to include in the Section, or null if no accessory is needed
22+
* @param textDisplay the TextDisplay to include in the Section or return directly if no accessory is provided
23+
*
24+
* @return a ContainerChildComponent that is either a Section with the accessory and text display or just the text display
25+
*/
1426
@NotNull
1527
public static ContainerChildComponent getSectionElseText(@Nullable SectionAccessoryComponent accessory, @NotNull TextDisplay textDisplay) {
1628
return accessory == null ? textDisplay : Section.of(accessory, textDisplay);
1729
}
1830

31+
/**
32+
* Creates a Container with a standardized unexpected error message, including a warning emoji and instructions for the user to try again or contact support if the issue persists.
33+
*
34+
* @return a Container containing the unexpected error message
35+
*/
1936
@NotNull
2037
public static Container unexpectedError() {
2138
return Container.of(TextDisplay.of(
@@ -24,6 +41,13 @@ public static Container unexpectedError() {
2441
"*If the issue persists, please contact support*"));
2542
}
2643

44+
/**
45+
* Creates a Container with a standardized unexpected error message that includes the provided error details, along with a warning emoji and instructions for the user to try again or contact support if the issue persists.
46+
*
47+
* @param error the specific error details to include in the message
48+
*
49+
* @return a Container containing the unexpected error message with the provided error details
50+
*/
2751
@NotNull
2852
public static Container unexpectedError(@NotNull String error) {
2953
return Container.of(TextDisplay.of(
@@ -33,27 +57,56 @@ public static Container unexpectedError(@NotNull String error) {
3357
"**Error:** " + error));
3458
}
3559

60+
/**
61+
* Creates a Container with a standardized no permission message, including a no entry emoji and instructions for the user that they don't have the required permissions to perform the action.
62+
*
63+
* @return a Container containing the no permission message
64+
*/
3665
@NotNull
3766
public static Container noPermission() {
3867
return Container.of(TextDisplay.of(
3968
"# " + LazyEmoji.NO_CLEAR + " No permission!\n" +
4069
"You don't have the required permissions to do that!"));
4170
}
4271

72+
/**
73+
* Creates a Container with a standardized no permission message that includes the specific requirement needed to perform the action, along with a no entry emoji and instructions for the user that they must have the specified requirement to do that.
74+
*
75+
* @param requirement the specific requirement (e.g., role, permission) that the user must have to perform the action
76+
*
77+
* @return a Container containing the no permission message with the specified requirement
78+
*/
4379
@NotNull
4480
public static Container noPermission(@NotNull Object requirement) {
4581
return Container.of(TextDisplay.of(
4682
"# " + LazyEmoji.NO_CLEAR + " No permission!\n" +
4783
"You must have " + requirement + " to do that!"));
4884
}
4985

86+
/**
87+
* Creates a Container with a standardized invalid argument message that includes the specific argument and its value that caused the issue, along with a no entry emoji and instructions for the user that the provided argument is invalid.
88+
*
89+
* @param argument the name of the argument that is invalid
90+
* @param value the value of the argument that is invalid (can be null)
91+
*
92+
* @return a Container containing the invalid argument message with the specified argument and value
93+
*/
5094
@NotNull
5195
public static Container invalidArgument(@NotNull String argument, @Nullable Object value) {
5296
return Container.of(TextDisplay.of(
5397
"# " + LazyEmoji.NO_CLEAR + " Invalid argument!\n" +
5498
"**" + argument + ":** " + value));
5599
}
56100

101+
/**
102+
* Creates a Container with a standardized invalid argument message that includes the specific argument and its value that caused the issue, along with a description of why the argument is invalid, a no entry emoji, and instructions for the user that the provided argument is invalid.
103+
*
104+
* @param argument the name of the argument that is invalid
105+
* @param value the value of the argument that is invalid (can be null)
106+
* @param description a description explaining why the argument is invalid or what the expected format/values are
107+
*
108+
* @return a Container containing the invalid argument message with the specified argument, value, and description
109+
*/
57110
@NotNull
58111
public static Container invalidArgument(@NotNull String argument, @Nullable Object value, @NotNull String description) {
59112
return Container.of(TextDisplay.of(
@@ -62,6 +115,16 @@ public static Container invalidArgument(@NotNull String argument, @Nullable Obje
62115
"**" + argument + ":** " + value));
63116
}
64117

118+
/**
119+
* Creates a Container with a standardized invalid arguments message that includes a list of argument names and their corresponding values that caused the issue, along with a no entry emoji and instructions for the user that the provided arguments are invalid.
120+
* The argumentsValues parameter should contain pairs of argument names and values (e.g., "argument1", value1, "argument2", value2, etc.).
121+
*
122+
* @param argumentsValues an array of objects representing pairs of argument names and their corresponding values that are invalid
123+
*
124+
* @return a Container containing the invalid arguments message with the specified argument names and values
125+
*
126+
* @throws IllegalArgumentException if the number of elements in argumentsValues is not even (i.e., each argument name does not have a corresponding value)
127+
*/
65128
@NotNull
66129
public static Container invalidArguments(@NotNull Object... argumentsValues) {
67130
if (argumentsValues.length % 2 != 0) throw new IllegalArgumentException("Each argument must have a value!");
@@ -73,4 +136,11 @@ public static Container invalidArguments(@NotNull Object... argumentsValues) {
73136
"# " + LazyEmoji.NO_CLEAR + " Invalid arguments!\n" +
74137
description));
75138
}
139+
140+
/**
141+
* Private constructor to prevent instantiation of this utility class, as it only contains static methods and should not be instantiated
142+
*/
143+
private LazyComponent() {
144+
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
145+
}
76146
}

0 commit comments

Comments
 (0)