
com.launchdarkly.sdk.LDValueArray Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of launchdarkly-java-sdk-common Show documentation
Show all versions of launchdarkly-java-sdk-common Show documentation
LaunchDarkly SDK Java Common Classes
package com.launchdarkly.sdk;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import static java.util.Collections.unmodifiableList;
@JsonAdapter(LDValueTypeAdapter.class)
final class LDValueArray extends LDValue {
private static final LDValueArray EMPTY = new LDValueArray(Collections.emptyList());
private final List list;
// Note that this is not
static LDValueArray fromList(List list) {
return list.isEmpty() ? EMPTY : new LDValueArray(list);
}
private LDValueArray(List list) {
this.list = unmodifiableList(list);
}
public LDValueType getType() {
return LDValueType.ARRAY;
}
@Override
public int size() {
return list.size();
}
@Override
public Iterable values() {
return list;
}
@Override
public LDValue get(int index) {
if (index >= 0 && index < list.size()) {
return list.get(index);
}
return ofNull();
}
@Override
void write(JsonWriter writer) throws IOException {
writer.beginArray();
for (LDValue v: list) {
v.write(writer);
}
writer.endArray();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy