blob: ffa07e0bd87619a6d5ddb2a4c12ef64591798ac8 (
plain) (
blame)
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.flags.json.wire;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import static com.yahoo.yolean.Exceptions.uncheck;
/**
* @author hakonhall
*/
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class WireFlagDataList {
@JsonProperty("flags")
public List<WireFlagData> flags = new ArrayList<>();
private static final ObjectMapper mapper = new ObjectMapper();
public void serializeToOutputStream(OutputStream outputStream) {
uncheck(() -> mapper.writeValue(outputStream, this));
}
public byte[] serializeToBytes() {
return uncheck(() -> mapper.writeValueAsBytes(this));
}
public static WireFlagDataList deserializeFrom(byte[] bytes) {
return uncheck(() -> mapper.readValue(bytes, WireFlagDataList.class));
}
}
|