-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathValueFactory.java
More file actions
96 lines (86 loc) · 2.68 KB
/
Copy pathValueFactory.java
File metadata and controls
96 lines (86 loc) · 2.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package io.qdrant.client;
import io.qdrant.client.grpc.JsonWithInt.ListValue;
import io.qdrant.client.grpc.JsonWithInt.NullValue;
import io.qdrant.client.grpc.JsonWithInt.Struct;
import io.qdrant.client.grpc.JsonWithInt.Value;
import java.util.List;
import java.util.Map;
/** Convenience methods for constructing {@link Value} */
public final class ValueFactory {
private ValueFactory() {}
/**
* Creates a value from a {@link String}
*
* @param value The value
* @return a new instance of {@link io.qdrant.client.grpc.JsonWithInt.Value}
*/
public static Value value(String value) {
return Value.newBuilder().setStringValue(value).build();
}
/**
* Creates a value from a {@link long}
*
* @param value The value
* @return a new instance of {@link io.qdrant.client.grpc.JsonWithInt.Value}
*/
public static Value value(long value) {
return Value.newBuilder().setIntegerValue(value).build();
}
/**
* Creates a value from a {@link double}
*
* @param value The value
* @return a new instance of {@link io.qdrant.client.grpc.JsonWithInt.Value}
*/
public static Value value(double value) {
return Value.newBuilder().setDoubleValue(value).build();
}
/**
* Creates a value from a {@link boolean}
*
* @param value The value
* @return a new instance of {@link io.qdrant.client.grpc.JsonWithInt.Value}
*/
public static Value value(boolean value) {
return Value.newBuilder().setBoolValue(value).build();
}
/**
* Creates a null value
*
* @return a new instance of {@link io.qdrant.client.grpc.JsonWithInt.Value}
*/
public static Value nullValue() {
return Value.newBuilder().setNullValue(NullValue.NULL_VALUE).build();
}
/**
* Creates a value from a list of values
*
* @param values The list of values
* @return a new instance of {@link io.qdrant.client.grpc.JsonWithInt.Value}
*/
public static Value list(List<Value> values) {
return Value.newBuilder()
.setListValue(ListValue.newBuilder().addAllValues(values).build())
.build();
}
/**
* Creates a value from a list of values. Same as {@link #list(List)}
*
* @param values The list of values
* @return a new instance of {@link io.qdrant.client.grpc.JsonWithInt.Value}
*/
public static Value value(List<Value> values) {
return list(values);
}
/**
* Creates a value from a map of nested values
*
* @param values The map of values
* @return a new instance of {@link io.qdrant.client.grpc.JsonWithInt.Value}
*/
public static Value value(Map<String, Value> values) {
return Value.newBuilder()
.setStructValue(Struct.newBuilder().putAllFields(values).build())
.build();
}
}