Skip to content

Commit 62766b2

Browse files
ker2xsarthakaggarwal97
authored andcommitted
Fixing various javadocs (opensearch-project#9817)
* fixing javadoc of org.opensearch.cli.Terminal Signed-off-by: Laurent Laborde <kerdezixe@gmail.com> * fixing javadoc of org.opensearch.cli.ExitCodes Signed-off-by: Laurent Laborde <kerdezixe@gmail.com> * fixing javadoc Signed-off-by: Laurent Laborde <kerdezixe@gmail.com> * fixing a mishap in formatting rule Signed-off-by: Laurent Laborde <kerdezixe@gmail.com> --------- Signed-off-by: Laurent Laborde <kerdezixe@gmail.com>
1 parent 27986f5 commit 62766b2

File tree

8 files changed

+147
-38
lines changed

8 files changed

+147
-38
lines changed

libs/cli/src/main/java/org/opensearch/cli/ExitCodes.java

+27-13
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,34 @@
3636
* POSIX exit codes.
3737
*/
3838
public class ExitCodes {
39+
/** No error */
3940
public static final int OK = 0;
40-
public static final int USAGE = 64; /* command line usage error */
41-
public static final int DATA_ERROR = 65; /* data format error */
42-
public static final int NO_INPUT = 66; /* cannot open input */
43-
public static final int NO_USER = 67; /* addressee unknown */
44-
public static final int NO_HOST = 68; /* host name unknown */
45-
public static final int UNAVAILABLE = 69; /* service unavailable */
46-
public static final int CODE_ERROR = 70; /* internal software error */
47-
public static final int CANT_CREATE = 73; /* can't create (user) output file */
48-
public static final int IO_ERROR = 74; /* input/output error */
49-
public static final int TEMP_FAILURE = 75; /* temp failure; user is invited to retry */
50-
public static final int PROTOCOL = 76; /* remote error in protocol */
51-
public static final int NOPERM = 77; /* permission denied */
52-
public static final int CONFIG = 78; /* configuration error */
41+
/** command line usage error */
42+
public static final int USAGE = 64;
43+
/** data format error */
44+
public static final int DATA_ERROR = 65;
45+
/** cannot open input */
46+
public static final int NO_INPUT = 66;
47+
/** addressee unknown */
48+
public static final int NO_USER = 67;
49+
/** host name unknown */
50+
public static final int NO_HOST = 68;
51+
/** service unavailable */
52+
public static final int UNAVAILABLE = 69;
53+
/** internal software error */
54+
public static final int CODE_ERROR = 70;
55+
/** can't create (user) output file */
56+
public static final int CANT_CREATE = 73;
57+
/** input/output error */
58+
public static final int IO_ERROR = 74;
59+
/** temp failure; user is invited to retry */
60+
public static final int TEMP_FAILURE = 75;
61+
/** remote error in protocol */
62+
public static final int PROTOCOL = 76;
63+
/** permission denied */
64+
public static final int NOPERM = 77;
65+
/** configuration error */
66+
public static final int CONFIG = 78;
5367

5468
private ExitCodes() { /* no instance, just constants */ }
5569
}

libs/cli/src/main/java/org/opensearch/cli/Terminal.java

+83-20
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@
5151
* which allows {@link #println(Verbosity,String)} calls which act like a logger,
5252
* only actually printing if the verbosity level of the terminal is above
5353
* the verbosity of the message.
54+
* @see ConsoleTerminal
55+
* @see SystemTerminal
5456
*/
5557
public abstract class Terminal {
5658

@@ -65,35 +67,57 @@ private static PrintWriter newErrorWriter() {
6567
return new PrintWriter(System.err);
6668
}
6769

68-
/** Defines the available verbosity levels of messages to be printed. */
70+
/** Defines the available verbosity levels of messages to be printed.*/
6971
public enum Verbosity {
70-
SILENT, /* always printed */
71-
NORMAL, /* printed when no options are given to cli */
72-
VERBOSE /* printed only when cli is passed verbose option */
72+
/** always printed */
73+
SILENT,
74+
/** printed when no options are given to cli */
75+
NORMAL,
76+
/** printed only when cli is passed verbose option */
77+
VERBOSE
7378
}
7479

7580
/** The current verbosity for the terminal, defaulting to {@link Verbosity#NORMAL}. */
7681
private Verbosity verbosity = Verbosity.NORMAL;
7782

78-
/** The newline used when calling println. */
83+
/** The newline separator used when calling println. */
7984
private final String lineSeparator;
8085

86+
/** Constructs a new terminal with the given line separator.
87+
* @param lineSeparator the line separator to use when calling println
88+
* */
8189
protected Terminal(String lineSeparator) {
8290
this.lineSeparator = lineSeparator;
8391
}
8492

85-
/** Sets the verbosity of the terminal. */
93+
/** Sets the {@link Terminal#verbosity} of the terminal. (Default is {@link Verbosity#NORMAL})
94+
* @param verbosity the {@link Verbosity} level that will be used for printing
95+
* */
8696
public void setVerbosity(Verbosity verbosity) {
8797
this.verbosity = verbosity;
8898
}
8999

90-
/** Reads clear text from the terminal input. See {@link Console#readLine()}. */
100+
/** Reads clear text from the terminal input.
101+
* @see Console#readLine()
102+
* @param prompt message to display to the user
103+
* @return the text entered by the user
104+
* */
91105
public abstract String readText(String prompt);
92106

93-
/** Reads password text from the terminal input. See {@link Console#readPassword()}}. */
107+
/** Reads secret text from the terminal input with echoing disabled.
108+
* @see Console#readPassword()
109+
* @param prompt message to display to the user
110+
* @return the secret as a character array
111+
* */
94112
public abstract char[] readSecret(String prompt);
95113

96-
/** Read password text form terminal input up to a maximum length. */
114+
/** Read secret text from terminal input with echoing disabled, up to a maximum length.
115+
* @see Console#readPassword()
116+
* @param prompt message to display to the user
117+
* @param maxLength the maximum length of the secret
118+
* @return the secret as a character array
119+
* @throws IllegalStateException if the secret exceeds the maximum length
120+
* */
97121
public char[] readSecret(String prompt, int maxLength) {
98122
char[] result = readSecret(prompt);
99123
if (result.length > maxLength) {
@@ -103,30 +127,48 @@ public char[] readSecret(String prompt, int maxLength) {
103127
return result;
104128
}
105129

106-
/** Returns a Writer which can be used to write to the terminal directly using standard output. */
130+
/** Returns a Writer which can be used to write to the terminal directly using standard output.
131+
* @return a writer to {@link Terminal#DEFAULT} output
132+
* @see Terminal.ConsoleTerminal
133+
* @see Terminal.SystemTerminal
134+
* */
107135
public abstract PrintWriter getWriter();
108136

109-
/** Returns a Writer which can be used to write to the terminal directly using standard error. */
137+
/** Returns a Writer which can be used to write to the terminal directly using standard error.
138+
* @return a writer to stderr
139+
* */
110140
public PrintWriter getErrorWriter() {
111141
return ERROR_WRITER;
112142
}
113143

114-
/** Prints a line to the terminal at {@link Verbosity#NORMAL} verbosity level. */
144+
/** Prints a line to the terminal at {@link Verbosity#NORMAL} verbosity level, with a {@link Terminal#lineSeparator}
145+
* @param msg the message to print
146+
* */
115147
public final void println(String msg) {
116148
println(Verbosity.NORMAL, msg);
117149
}
118150

119-
/** Prints a line to the terminal at {@code verbosity} level. */
151+
/** Prints message to the terminal's standard output at {@link Verbosity} level, with a {@link Terminal#lineSeparator}.
152+
* @param verbosity the {@link Verbosity} level at which to print
153+
* @param msg the message to print
154+
* */
120155
public final void println(Verbosity verbosity, String msg) {
121156
print(verbosity, msg + lineSeparator);
122157
}
123158

124-
/** Prints message to the terminal's standard output at {@code verbosity} level, without a newline. */
159+
/** Prints message to the terminal's standard output at {@link Verbosity} level, without adding a {@link Terminal#lineSeparator}.
160+
* @param verbosity the {@link Verbosity} level at which to print
161+
* @param msg the message to print
162+
* */
125163
public final void print(Verbosity verbosity, String msg) {
126164
print(verbosity, msg, false);
127165
}
128166

129-
/** Prints message to the terminal at {@code verbosity} level, without a newline. */
167+
/** Prints message to either standard or error output at {@link Verbosity} level, without adding a {@link Terminal#lineSeparator}.
168+
* @param verbosity the {@link Verbosity} level at which to print.
169+
* @param msg the message to print
170+
* @param isError if true, prints to standard error instead of standard output
171+
* */
130172
private void print(Verbosity verbosity, String msg, boolean isError) {
131173
if (isPrintable(verbosity)) {
132174
PrintWriter writer = isError ? getErrorWriter() : getWriter();
@@ -135,29 +177,44 @@ private void print(Verbosity verbosity, String msg, boolean isError) {
135177
}
136178
}
137179

138-
/** Prints a line to the terminal's standard error at {@link Verbosity#NORMAL} verbosity level, without a newline. */
180+
/** Prints a line to the terminal's standard error at {@link Verbosity} level, without adding a {@link Terminal#lineSeparator}.
181+
* @param verbosity the {@link Verbosity} level at which to print.
182+
* @param msg the message to print
183+
* */
139184
public final void errorPrint(Verbosity verbosity, String msg) {
140185
print(verbosity, msg, true);
141186
}
142187

143-
/** Prints a line to the terminal's standard error at {@link Verbosity#NORMAL} verbosity level. */
188+
/** Prints a line to the terminal's standard error at {@link Verbosity#NORMAL} verbosity level, with a {@link Terminal#lineSeparator}
189+
* @param msg the message to print
190+
* */
144191
public final void errorPrintln(String msg) {
145192
errorPrintln(Verbosity.NORMAL, msg);
146193
}
147194

148-
/** Prints a line to the terminal's standard error at {@code verbosity} level. */
195+
/** Prints a line to the terminal's standard error at {@link Verbosity} level, with a {@link Terminal#lineSeparator}.
196+
* @param verbosity the {@link Verbosity} level at which to print.
197+
* @param msg the message to print
198+
* */
149199
public final void errorPrintln(Verbosity verbosity, String msg) {
150200
errorPrint(verbosity, msg + lineSeparator);
151201
}
152202

153-
/** Checks if is enough {@code verbosity} level to be printed */
203+
/** Checks if given {@link Verbosity} level is high enough to be printed at the level defined by {@link Terminal#verbosity}
204+
* @param verbosity the {@link Verbosity} level to check
205+
* @return true if the {@link Verbosity} level is high enough to be printed
206+
* @see Terminal#setVerbosity(Verbosity)
207+
* */
154208
public final boolean isPrintable(Verbosity verbosity) {
155209
return this.verbosity.ordinal() >= verbosity.ordinal();
156210
}
157211

158212
/**
159-
* Prompt for a yes or no answer from the user. This method will loop until 'y' or 'n'
213+
* Prompt for a yes or no answer from the user. This method will loop until 'y', 'n'
160214
* (or the default empty value) is entered.
215+
* @param prompt the prompt to display to the user
216+
* @param defaultYes if true, the default answer is 'y', otherwise it is 'n'
217+
* @return true if the user answered 'y', false if the user answered 'n' or the defaultYes value if the user entered nothing
161218
*/
162219
public final boolean promptYesNo(String prompt, boolean defaultYes) {
163220
String answerPrompt = defaultYes ? " [Y/n]" : " [y/N]";
@@ -181,6 +238,11 @@ public final boolean promptYesNo(String prompt, boolean defaultYes) {
181238
* character is immediately preceded by a carriage return, we have
182239
* a Windows-style newline, so we discard the carriage return as well
183240
* as the newline.
241+
* @param reader the reader to read from
242+
* @param maxLength the maximum length of the line to read
243+
* @return the line read from the reader
244+
* @throws RuntimeException if the line read exceeds the maximum length
245+
* @throws RuntimeException if an IOException occurs while reading
184246
*/
185247
public static char[] readLineToCharArray(Reader reader, int maxLength) {
186248
char[] buf = new char[maxLength + 2];
@@ -215,6 +277,7 @@ public static char[] readLineToCharArray(Reader reader, int maxLength) {
215277
}
216278
}
217279

280+
/** Flushes the terminal's standard output and standard error. */
218281
public void flush() {
219282
this.getWriter().flush();
220283
this.getErrorWriter().flush();

libs/common/src/main/java/org/opensearch/common/collect/Tuple.java

+22
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,20 @@ public V2 v2() {
6161
return v2;
6262
}
6363

64+
/**
65+
* Returns {@code true} if the given object is also a tuple and the two tuples
66+
* have equal {@link #v1()} and {@link #v2()} values.
67+
* <p>
68+
* Returns {@code false} otherwise, including for {@code null} values or
69+
* objects of different types.
70+
* <p>
71+
* Note: {@code Tuple} instances are equal if the underlying values are
72+
* equal, even if the types are different.
73+
*
74+
* @param o the object to compare to
75+
* @return {@code true} if the given object is also a tuple and the two tuples
76+
* have equal {@link #v1()} and {@link #v2()} values.
77+
*/
6478
@Override
6579
public boolean equals(Object o) {
6680
if (this == o) return true;
@@ -74,13 +88,21 @@ public boolean equals(Object o) {
7488
return true;
7589
}
7690

91+
/**
92+
* Returns the hash code value for this Tuple.
93+
* @return the hash code value for this Tuple.
94+
*/
7795
@Override
7896
public int hashCode() {
7997
int result = v1 != null ? v1.hashCode() : 0;
8098
result = 31 * result + (v2 != null ? v2.hashCode() : 0);
8199
return result;
82100
}
83101

102+
/**
103+
* Returns a string representation of a Tuple
104+
* @return {@code "Tuple [v1=value1, v2=value2]"}
105+
*/
84106
@Override
85107
public String toString() {
86108
return "Tuple [v1=" + v1 + ", v2=" + v2 + "]";

libs/common/src/main/java/org/opensearch/common/crypto/CryptoHandler.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
* Crypto provider abstractions for encryption and decryption of data. Allows registering multiple providers
2020
* for defining different ways of encrypting or decrypting data.
2121
*
22-
* T - Encryption Metadata / CryptoContext
23-
* U - Parsed Encryption Metadata / CryptoContext
22+
* @param <T> Encryption Metadata / CryptoContext
23+
* @param <U> Parsed Encryption Metadata / CryptoContext
2424
*/
2525
@ExperimentalApi
2626
public interface CryptoHandler<T, U> extends Closeable {
@@ -38,6 +38,7 @@ public interface CryptoHandler<T, U> extends Closeable {
3838
* Note that underlying information in the loaded metadata object is same as present in the object created during
3939
* encryption but object type may differ.
4040
*
41+
* @param encryptedHeaderContentSupplier supplier for encrypted header content.
4142
* @return crypto metadata instance used in decryption.
4243
*/
4344
U loadEncryptionMetadata(EncryptedHeaderContentSupplier encryptedHeaderContentSupplier) throws IOException;

libs/common/src/main/java/org/opensearch/common/crypto/DataKeyPair.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111
* Key pair generated by {@link MasterKeyProvider}
1212
*/
1313
public class DataKeyPair {
14+
15+
/** Unencrypted data key used for encryption and decryption */
1416
private final byte[] rawKey;
17+
/** Encrypted version of rawKey */
1518
private final byte[] encryptedKey;
1619

1720
/**
@@ -25,7 +28,7 @@ public DataKeyPair(byte[] rawKey, byte[] encryptedKey) {
2528
}
2629

2730
/**
28-
* Returns raw key
31+
* Returns Unencrypted data key
2932
* @return raw/decrypted key
3033
*/
3134
public byte[] getRawKey() {

libs/common/src/main/java/org/opensearch/common/crypto/DecryptedRangedStreamProvider.java

+2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
*/
1717
public class DecryptedRangedStreamProvider {
1818

19+
/** Adjusted range of partial encrypted content which needs to be used for decryption. */
1920
private final long[] adjustedRange;
21+
/** Stream provider for decryption and range re-adjustment. */
2022
private final UnaryOperator<InputStream> decryptedStreamProvider;
2123

2224
/**

libs/common/src/main/java/org/opensearch/common/crypto/MasterKeyProvider.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public interface MasterKeyProvider extends Closeable {
2222
DataKeyPair generateDataPair();
2323

2424
/**
25-
* Returns decrpted key against the encrypted key.
25+
* Returns decrypted key against the encrypted key.
2626
* @param encryptedKey Key to decrypt
2727
* @return Decrypted version of key.
2828
*/
@@ -35,6 +35,7 @@ public interface MasterKeyProvider extends Closeable {
3535
String getKeyId();
3636

3737
/**
38+
* Returns encryption context associated with this master key.
3839
* @return encryption context associated with this master key.
3940
*/
4041
Map<String, String> getEncryptionContext();

libs/compress/src/main/java/org/opensearch/compress/spi/CompressionProvider.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@
2323
*/
2424
public class CompressionProvider implements CompressorProvider {
2525

26-
/** Returns the concrete {@link Compressor}s provided by the compress library */
26+
/**
27+
* Returns the concrete {@link Compressor}s provided by the compress library
28+
* @return a list of {@link Compressor}s
29+
* */
2730
@SuppressWarnings({ "unchecked", "rawtypes" })
2831
@Override
2932
public List<Entry<String, Compressor>> getCompressors() {

0 commit comments

Comments
 (0)