Skip to content

Commit 0687655

Browse files
committed
chore: Adds FDv2 PayloadProcessor
1 parent 8cac362 commit 0687655

File tree

13 files changed

+3265
-0
lines changed

13 files changed

+3265
-0
lines changed

lib/sdk/server/src/main/java/com/launchdarkly/sdk/server/subsystems/DataStoreTypes.java

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ public String toString() {
259259
*
260260
* @param <TDescriptor> will be {@link ItemDescriptor} or {@link SerializedItemDescriptor}
261261
*/
262+
@Deprecated("Use DataSet instead. The term Full was too specific")
262263
public static final class FullDataSet<TDescriptor> {
263264
private final Iterable<Map.Entry<DataKind, KeyedItems<TDescriptor>>> data;
264265

@@ -290,6 +291,48 @@ public int hashCode() {
290291
return data.hashCode();
291292
}
292293
}
294+
295+
/**
296+
* Wrapper for a set of storable items being passed to a data store.
297+
* <p>
298+
* Since the generic type signature for the data set is somewhat complicated (it is an ordered
299+
* list of key-value pairs where each key is a {@link DataKind}, and each value is another ordered
300+
* list of key-value pairs for the individual data items), this type simplifies the declaration of
301+
* data store methods and makes it easier to see what the type represents.
302+
*
303+
* @param <TDescriptor> will be {@link ItemDescriptor} or {@link SerializedItemDescriptor}
304+
*/
305+
public static final class DataSet<TDescriptor> {
306+
private final Iterable<Map.Entry<DataKind, KeyedItems<TDescriptor>>> data;
307+
308+
/**
309+
* Returns the wrapped data set.
310+
*
311+
* @return an enumeration of key-value pairs; may be empty, but will not be null
312+
*/
313+
public Iterable<Map.Entry<DataKind, KeyedItems<TDescriptor>>> getData() {
314+
return data;
315+
}
316+
317+
/**
318+
* Constructs a new instance.
319+
*
320+
* @param data the data set
321+
*/
322+
public DataSet(Iterable<Map.Entry<DataKind, KeyedItems<TDescriptor>>> data) {
323+
this.data = data == null ? ImmutableList.of(): data;
324+
}
325+
326+
@Override
327+
public boolean equals(Object o) {
328+
return o instanceof FullDataSet<?> && data.equals(((FullDataSet<?>)o).data);
329+
}
330+
331+
@Override
332+
public int hashCode() {
333+
return data.hashCode();
334+
}
335+
}
293336

294337
/**
295338
* Wrapper for a set of storable items being passed to a data store, within a single
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
package com.launchdarkly.sdk.internal.fdv2.processor;
2+
3+
import java.util.List;
4+
5+
import static java.util.Collections.emptyList;
6+
7+
/**
8+
* Represents a collection of updates from the FDv2 services. If basis is true, the set of updates
9+
* represents the complete state of the payload.
10+
*/
11+
public final class Payload {
12+
private String id;
13+
private int version;
14+
private String state;
15+
private boolean basis;
16+
private List<Update> updates;
17+
18+
/**
19+
* Default constructor.
20+
*/
21+
public Payload() {}
22+
23+
/**
24+
* Constructs a Payload with the specified properties.
25+
*
26+
* @param id the payload identifier
27+
* @param version the payload version
28+
* @param state the payload state (optional)
29+
* @param basis whether this represents the complete state
30+
* @param updates the list of updates
31+
*/
32+
public Payload(String id, int version, String state, boolean basis, List<Update> updates) {
33+
this.id = id;
34+
this.version = version;
35+
this.state = state;
36+
this.basis = basis;
37+
this.updates = updates;
38+
}
39+
40+
/**
41+
* Returns the payload identifier.
42+
*
43+
* @return the payload identifier
44+
*/
45+
public String getId() {
46+
return id;
47+
}
48+
49+
/**
50+
* Sets the payload identifier.
51+
*
52+
* @param id the payload identifier
53+
*/
54+
public void setId(String id) {
55+
this.id = id;
56+
}
57+
58+
/**
59+
* Returns the payload version.
60+
*
61+
* @return the payload version
62+
*/
63+
public int getVersion() {
64+
return version;
65+
}
66+
67+
/**
68+
* Sets the payload version.
69+
*
70+
* @param version the payload version
71+
*/
72+
public void setVersion(int version) {
73+
this.version = version;
74+
}
75+
76+
/**
77+
* Returns the payload state.
78+
*
79+
* @return the payload state, or null if not present
80+
*/
81+
public String getState() {
82+
return state;
83+
}
84+
85+
/**
86+
* Sets the payload state.
87+
*
88+
* @param state the payload state
89+
*/
90+
public void setState(String state) {
91+
this.state = state;
92+
}
93+
94+
/**
95+
* Returns whether this represents the complete state.
96+
*
97+
* @return true if this represents the complete state, false otherwise
98+
*/
99+
public boolean isBasis() {
100+
return basis;
101+
}
102+
103+
/**
104+
* Sets whether this represents the complete state.
105+
*
106+
* @param basis true if this represents the complete state, false otherwise
107+
*/
108+
public void setBasis(boolean basis) {
109+
this.basis = basis;
110+
}
111+
112+
/**
113+
* Returns the list of updates.
114+
*
115+
* @return the list of updates (never null)
116+
*/
117+
public List<Update> getUpdates() {
118+
return updates == null ? emptyList() : updates;
119+
}
120+
121+
/**
122+
* Sets the list of updates.
123+
*
124+
* @param updates the list of updates
125+
*/
126+
public void setUpdates(List<Update> updates) {
127+
this.updates = updates;
128+
}
129+
}
130+

0 commit comments

Comments
 (0)