Skip to content

Commit de15941

Browse files
committed
less warnings
1 parent f0c9d0a commit de15941

File tree

8 files changed

+351
-26
lines changed

8 files changed

+351
-26
lines changed

astra-db-java/src/main/java/com/datastax/astra/client/collections/definition/documents/Document.java

Lines changed: 68 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -554,52 +554,104 @@ public String toJson() {
554554
return toString();
555555
}
556556

557-
/** {@inheritDoc} */
557+
/**
558+
* Evaluation if a key is present in the document
559+
* @param key
560+
* key to evaluate
561+
* @return
562+
* true if the key is present
563+
*/
558564
public boolean containsKey(final Object key) {
559565
return documentMap.containsKey(key);
560566
}
561567

562-
/** {@inheritDoc} */
568+
569+
/**
570+
* Retrieves the value associated with the specified key from the document.
571+
*
572+
* @param key the key whose associated value is to be returned
573+
* @return the value associated with the specified key, or {@code null} if the key is not found
574+
*/
563575
public Object get(final Object key) {
564576
return documentMap.get(key);
565577
}
566578

567-
/** {@inheritDoc} */
579+
/**
580+
* Associates the specified value with the specified key in the document.
581+
* If the key already has a value, the old value is replaced.
582+
*
583+
* @param key the key with which the specified value is to be associated
584+
* @param value the value to be associated with the specified key
585+
* @return the previous value associated with the key, or {@code null} if there was no mapping for the key
586+
*/
568587
public Object put(final String key, final Object value) {
569588
return documentMap.put(key, value);
570589
}
571590

572-
/** {@inheritDoc} */
591+
/**
592+
* Removes the mapping for a key from the document if it is present.
593+
*
594+
* @param key the key whose mapping is to be removed
595+
* @return the value that was associated with the key, or {@code null} if the key was not mapped
596+
*/
573597
public Object remove(final Object key) {
574598
return documentMap.remove(key);
575599
}
576600

577-
/** {@inheritDoc} */
601+
/**
602+
* Copies all mappings from the specified map to this document.
603+
* Existing mappings will be replaced with mappings from the provided map.
604+
*
605+
* @param map the map containing mappings to be copied to this document
606+
*/
578607
public void putAll(final Map<? extends String, ?> map) {
579608
documentMap.putAll(map);
580609
}
581610

582-
/** {@inheritDoc} */
611+
/**
612+
* Copies all mappings from the specified {@code Document} to this document.
613+
* Existing mappings will be replaced with mappings from the provided document.
614+
*
615+
* @param doc the document whose mappings are to be copied to this document
616+
*/
583617
public void putAll(Document doc) {
584618
documentMap.putAll(doc.getDocumentMap());
585619
}
586620

587-
/** {@inheritDoc} */
621+
/**
622+
* Removes all mappings from this document.
623+
* The document will be empty after this operation.
624+
*/
588625
public void clear() {
589626
documentMap.clear();
590627
}
591628

592-
/** {@inheritDoc} */
629+
/**
630+
* Returns a collection view of the values contained in this document.
631+
*
632+
* @return a collection view of the values contained in this document
633+
*/
593634
public Collection<Object> values() {
594635
return documentMap.values();
595636
}
596637

597-
/** {@inheritDoc} */
638+
/**
639+
* Returns a set view of the mappings contained in this document.
640+
* Each entry in the set is a key-value pair.
641+
*
642+
* @return a set view of the mappings contained in this document
643+
*/
598644
public Set<Map.Entry<String, Object>> entrySet() {
599645
return documentMap.entrySet();
600646
}
601647

602-
/** {@inheritDoc} */
648+
/**
649+
* Compares this document to another object for equality.
650+
* Two documents are considered equal if their underlying maps are equal.
651+
*
652+
* @param o the object to compare with this document
653+
* @return {@code true} if the specified object is equal to this document, {@code false} otherwise
654+
*/
603655
@Override
604656
public boolean equals(final Object o) {
605657
if (this == o) {
@@ -612,13 +664,17 @@ public boolean equals(final Object o) {
612664
return documentMap.equals(document.documentMap);
613665
}
614666

615-
/** {@inheritDoc} */
667+
/**
668+
* Returns the hash code value for this document.
669+
* The hash code is computed based on the underlying map.
670+
*
671+
* @return the hash code value for this document
672+
*/
616673
@Override
617674
public int hashCode() {
618675
return documentMap.hashCode();
619676
}
620677

621678

622679

623-
624680
}

astra-db-java/src/main/java/com/datastax/astra/client/core/paging/CollectionCursor.java

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ public CollectionCursor<T> clone() {
127127
*
128128
* @param newFilter
129129
* a new filter
130+
* @return a new {@code CollectionCursor} instance with the filter applied
130131
*/
131132
public CollectionCursor<T> filter(Filter newFilter) {
132133
checkIdleState();
@@ -140,6 +141,7 @@ public CollectionCursor<T> filter(Filter newFilter) {
140141
*
141142
* @param newProjection
142143
* a new projection
144+
* @return a new {@code CollectionCursor} instance with the projection applied
143145
*/
144146
public CollectionCursor<T> project(Projection... newProjection) {
145147
checkIdleState();
@@ -236,7 +238,12 @@ private void rewind() {
236238
this.consumedCount = 0;
237239
}
238240

239-
// Buffer consumption
241+
/**
242+
* Consume the buffer and return the results.
243+
*
244+
* @return
245+
* list of results
246+
*/
240247
public List<T> consumeBuffer(int n) {
241248
if (state == CursorState.CLOSED || state == CursorState.IDLE) {
242249
return Collections.emptyList();
@@ -297,7 +304,9 @@ public T next() {
297304
}
298305
}
299306

300-
// Fetch next batch of documents
307+
/**
308+
* Fetch the next batch of documents into the buffer.
309+
*/
301310
private void fetchNextBatch() {
302311
if (currentPage == null) {
303312
currentPage = myCollection.findPage(filter, findOptions);
@@ -311,15 +320,32 @@ private void fetchNextBatch() {
311320
}
312321
}
313322

314-
// Additional methods
323+
/**
324+
* Check if there is a next element.
325+
*
326+
* @return
327+
* true if there is a next element
328+
*/
315329
public boolean hasNext() {
316330
return iterator().hasNext();
317331
}
318332

333+
/**
334+
* Retrieve the next element.
335+
*
336+
* @return
337+
* next element
338+
*/
319339
public T next() {
320340
return iterator().next();
321341
}
322342

343+
/**
344+
* Retrieve all the elements in a list.
345+
*
346+
* @return
347+
* list of elements
348+
*/
323349
public List<T> toList() {
324350
List<T> result = new ArrayList<>();
325351
try {

astra-db-java/src/main/java/com/datastax/astra/client/exceptions/ClientErrorCodes.java

Lines changed: 85 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,110 @@
2222

2323
import lombok.Getter;
2424

25+
/**
26+
* Represents client error codes used to standardize error reporting in the application.
27+
* Each error code is associated with a unique identifier (`code`) and a descriptive message (`message`).
28+
* <p>
29+
* This enum is designed to facilitate consistent error handling and logging across various components.
30+
* Some codes are pre-configured with detailed messages that accept placeholders for dynamic values,
31+
* while others are placeholders for future implementation.
32+
* </p>
33+
*
34+
* <p>Example usage:</p>
35+
* <pre>
36+
* {@code
37+
* String errorCode = ClientErrorCodes.CONFIG_MISSING.getCode();
38+
* String errorMessage = String.format(ClientErrorCodes.CONFIG_MISSING.getMessage(), "paramName", "operationName");
39+
* }
40+
* </pre>
41+
*/
2542
@Getter
2643
public enum ClientErrorCodes {
44+
45+
/**
46+
* Indicates that the operation is restricted to Astra environments.
47+
* Dynamic placeholders:
48+
* <ul>
49+
* <li>{@code '%s'}: The operation name.</li>
50+
* <li>{@code '%s'}: The current environment.</li>
51+
* </ul>
52+
*/
2753
ENV_RESTRICTED_ASTRA("ASTRA_RESTRICTED", "Operation '%s' available only for Astra environments (current is '%s')"),
54+
55+
/**
56+
* Indicates that a required configuration parameter is missing.
57+
* Dynamic placeholders:
58+
* <ul>
59+
* <li>{@code '%s'}: The name of the missing configuration parameter.</li>
60+
* <li>{@code '%s'}: The operation requiring the parameter.</li>
61+
* </ul>
62+
*/
2863
CONFIG_MISSING("CLIENT_CONFIG_MISSING", "Configuration parameter is missing : '%s' for operation '%s'"),
64+
65+
/**
66+
* Indicates that a required annotation is missing from a bean.
67+
* Dynamic placeholders:
68+
* <ul>
69+
* <li>{@code '%s'}: The name of the missing annotation.</li>
70+
* <li>{@code '%s'}: The name of the bean.</li>
71+
* <li>{@code '%s'}: The operation requiring the annotation.</li>
72+
* </ul>
73+
*/
2974
MISSING_ANNOTATION("CLIENT_MISSING_ANNOTATION", "Annotation '%s' is missing on bean '%s' for operation '%s'"),
3075

31-
// TODO
76+
/**
77+
* Generic client error with no specific message.
78+
*/
3279
ERROR("CLIENT_ERROR", ""),
80+
81+
/**
82+
* Indicates an HTTP error encountered by the client.
83+
*/
3384
HTTP("CLIENT_HTTP", ""),
85+
86+
/**
87+
* Indicates a timeout error encountered by the client.
88+
*/
3489
TIMEOUT("CLIENT_TIMEOUT", ""),
90+
91+
/**
92+
* Indicates an operation was interrupted.
93+
*/
3594
INTERRUPTED("CLIENT_INTERRUPTED", ""),
95+
96+
/**
97+
* Placeholder for random client errors.
98+
*/
3699
RANDOM("CLIENT_RANDOM", ""),
100+
101+
/**
102+
* Indicates an error related to cursor operations.
103+
*/
37104
CURSOR("CLIENT_CURSOR", ""),
105+
106+
/**
107+
* Indicates an error in client-side serialization.
108+
*/
38109
SERIALIZATION("CLIENT_SERIALIZATION", "CLIENT_SERIALIZATION");
39110

111+
/**
112+
* The unique code representing the error.
113+
*/
40114
private final String code;
41115

116+
/**
117+
* The descriptive message associated with the error.
118+
*/
42119
private final String message;
43120

121+
/**
122+
* Constructs a new {@code ClientErrorCodes} instance with the specified code and message.
123+
*
124+
* @param code the unique code representing the error
125+
* @param message the descriptive message associated with the error
126+
*/
44127
ClientErrorCodes(String code, String message) {
45-
this.code = code;
128+
this.code = code;
46129
this.message = message;
47130
}
48131
}

astra-db-java/src/main/java/com/datastax/astra/client/tables/commands/options/AlterTableOptions.java

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,30 +27,54 @@
2727

2828
import static com.datastax.astra.client.tables.Table.DEFAULT_TABLE_SERIALIZER;
2929

30+
/**
31+
* Represents options for altering a table in a database schema.
32+
* Extends {@link BaseOptions} to provide additional functionality for table alteration commands.
33+
* <p>
34+
* This class supports a fluent, chainable API using the {@link Accessors} annotation.
35+
* Common options include specifying whether to include an "IF EXISTS" condition during the operation.
36+
* </p>
37+
*
38+
* <p>Example usage:</p>
39+
* <pre>
40+
* {@code
41+
* AlterTableOptions options = new AlterTableOptions()
42+
* .ifExists(true);
43+
* }
44+
* </pre>
45+
*/
3046
@Setter
3147
@Accessors(fluent = true, chain = true)
3248
public class AlterTableOptions extends BaseOptions<AlterTableOptions> {
3349

34-
/** Improve syntax. */
50+
/**
51+
* A predefined instance of {@code AlterTableOptions} with the "IF EXISTS" condition enabled.
52+
* This improves syntax for commonly used configurations.
53+
*/
3554
public static final AlterTableOptions IF_EXISTS = new AlterTableOptions().ifExists(true);
3655

3756
/**
38-
* Condition to upsert the table.
57+
* Indicates whether the "IF EXISTS" condition should be applied to the table alteration.
58+
* When {@code true}, the operation will only proceed if the table exists.
3959
*/
40-
boolean ifExists = true;
60+
private boolean ifExists = true;
4161

62+
/**
63+
* Constructs a new {@code AlterTableOptions} instance with default settings.
64+
* Initializes the options with {@link CommandType#TABLE_ADMIN} and the default table serializer.
65+
*/
4266
public AlterTableOptions() {
4367
super(null, CommandType.TABLE_ADMIN, DEFAULT_TABLE_SERIALIZER, null);
4468
}
4569

4670
/**
47-
* Accessor for serialization.
71+
* Retrieves the value of the "IF EXISTS" condition.
72+
* This condition determines whether the operation should check for the existence of the table.
4873
*
49-
* @return
50-
* accessor for serialization
74+
* @return {@code true} if the "IF EXISTS" condition is enabled, {@code false} otherwise
5175
*/
5276
public boolean isIfExists() {
5377
return ifExists;
5478
}
55-
5679
}
80+

0 commit comments

Comments
 (0)