Skip to content

Commit 2eca27e

Browse files
[Javadoc]: Add usage examples to CharSet.contains Javadoc (#1605)
* [Javadoc]: Add usage examples to `CharSet.contains` Javadoc * [Javadoc]: Fix minor punctuation in `CharSet.contains` Javadoc * [Javadoc]: Standardize parameter description in `CharSet.contains` Javadoc - revert to original form * [Javadoc]: Expand and copy examples in `CharSet.contains` Javadoc for clarification from class level. * Clarify examples for negation character in CharSet Updated example description to clarify usage of negation character. --------- Co-authored-by: Gary Gregory <garydgregory@users.noreply.github.com>
1 parent 7ebab00 commit 2eca27e

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/main/java/org/apache/commons/lang3/CharSet.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,17 @@ protected void add(final String str) {
221221
* Does the {@link CharSet} contain the specified
222222
* character {@code ch}.
223223
*
224+
* <p>Examples using the negation character:</p>
225+
* <pre>
226+
* CharSet.getInstance("^a-c").contains('a') = false
227+
* CharSet.getInstance("^a-c").contains('d') = true
228+
* CharSet.getInstance("^^a-c").contains('a') = true // (only '^' is negated)
229+
* CharSet.getInstance("^^a-c").contains('^') = false
230+
* CharSet.getInstance("^a-cd-f").contains('d') = true
231+
* CharSet.getInstance("a-c^").contains('^') = true
232+
* CharSet.getInstance("^", "a-c").contains('^') = true
233+
* </pre>
234+
*
224235
* @param ch the character to check for
225236
* @return {@code true} if the set contains the characters
226237
*/

0 commit comments

Comments
 (0)