Skip to content

Commit 7c697a5

Browse files
committed
Add public ref doc
1 parent ab2aaab commit 7c697a5

File tree

5 files changed

+1967
-77
lines changed

5 files changed

+1967
-77
lines changed

google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static FilterCondition toPipelineFilterCondition(FilterInternal f) {
6262
return and(field.exists(), inAny(field, Lists.newArrayList(valuesList)));
6363
case ARRAY_CONTAINS_ANY:
6464
List<Value> valuesListAny = value.getArrayValue().getValuesList();
65-
return and(field.exists(), arrayContainsAny(field, valuesListAny.toArray()));
65+
return and(field.exists(), arrayContainsAny(field, Lists.newArrayList(valuesListAny)));
6666
case NOT_IN:
6767
List<Value> notInValues = value.getArrayValue().getValuesList();
6868
return and(field.exists(), not(inAny(field, Lists.newArrayList(notInValues))));

google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/Field.java

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,22 @@
88
import com.google.firestore.v1.Value;
99
import javax.annotation.Nullable;
1010

11+
/**
12+
* Represents a reference to a field in a Firestore document.
13+
*
14+
* <p>Field references are used to access document field values in expressions and to specify fields
15+
* for sorting, filtering, and projecting data in Firestore pipelines.
16+
*
17+
* <p>You can create a `Field` instance using the static {@link #of(String)} method:
18+
*
19+
* <pre>{@code
20+
* // Create a Field instance for the 'name' field
21+
* Field nameField = Field.of("name");
22+
*
23+
* // Create a Field instance for a nested field 'address.city'
24+
* Field cityField = Field.of("address.city");
25+
* }</pre>
26+
*/
1127
@BetaApi
1228
public final class Field implements Expr, Selectable {
1329
public static final String DOCUMENT_ID = "__name__";
@@ -18,6 +34,25 @@ private Field(FieldPath path) {
1834
this.path = path;
1935
}
2036

37+
/**
38+
* Creates a {@code Field} instance representing the field at the given path.
39+
*
40+
* <p>The path can be a simple field name (e.g., "name") or a dot-separated path to a nested field
41+
* (e.g., "address.city").
42+
*
43+
* <p>Example:
44+
*
45+
* <pre>{@code
46+
* // Create a Field instance for the 'title' field
47+
* Field titleField = Field.of("title");
48+
*
49+
* // Create a Field instance for a nested field 'author.firstName'
50+
* Field authorFirstNameField = Field.of("author.firstName");
51+
* }</pre>
52+
*
53+
* @param path The path to the field.
54+
* @return A new {@code Field} instance representing the specified field.
55+
*/
2156
@BetaApi
2257
public static Field of(String path) {
2358
if (path.equals(DOCUMENT_ID)) {
@@ -52,9 +87,4 @@ public int hashCode() {
5287
public FieldPath getPath() {
5388
return path;
5489
}
55-
56-
@InternalApi
57-
public Pipeline getPipeline() {
58-
return pipeline;
59-
}
6090
}

google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/Fields.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,23 @@
77
import java.util.List;
88
import java.util.stream.Collectors;
99

10+
/**
11+
* Represents a selection of multiple {@link Field} instances.
12+
*
13+
* <p>This class is used to conveniently specify multiple fields for operations like selecting
14+
* fields in a pipeline.
15+
*
16+
* <p>Example:
17+
*
18+
* <pre>{@code
19+
* // Select the 'name', 'email', and 'age' fields
20+
* Fields selectedFields = Fields.of("name", "email", "age");
21+
*
22+
* firestore.pipeline().collection("users")
23+
* .select(selectedFields)
24+
* .execute();
25+
* }</pre>
26+
*/
1027
@BetaApi
1128
public final class Fields implements Expr, Selectable {
1229
private final List<Field> fields;
@@ -15,18 +32,38 @@ private Fields(List<Field> fs) {
1532
this.fields = fs;
1633
}
1734

35+
/**
36+
* Creates a {@code Fields} instance containing the specified fields.
37+
*
38+
* @param f1 The first field to include.
39+
* @param f Additional fields to include.
40+
* @return A new {@code Fields} instance containing the specified fields.
41+
*/
1842
@BetaApi
1943
public static Fields of(String f1, String... f) {
2044
List<Field> fields = Arrays.stream(f).map(Field::of).collect(Collectors.toList());
2145
fields.add(0, Field.of(f1)); // Add f1 at the beginning
2246
return new Fields(fields);
2347
}
2448

49+
/**
50+
* Creates a {@code Fields} instance representing a selection of all fields.
51+
*
52+
* <p>This is equivalent to not specifying any fields in a select operation, resulting in all
53+
* fields being included in the output.
54+
*
55+
* @return A new {@code Fields} instance representing all fields.
56+
*/
2557
@BetaApi
2658
public static Fields ofAll() {
2759
return new Fields(Collections.singletonList(Field.of("")));
2860
}
2961

62+
/**
63+
* Returns the list of {@link Field} instances contained in this {@code Fields} object.
64+
*
65+
* @return The list of fields.
66+
*/
3067
@InternalApi
3168
public List<Field> getFields() {
3269
return fields;

0 commit comments

Comments
 (0)