sdmxdl.Query Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sdmx-dl-api Show documentation
Show all versions of sdmx-dl-api Show documentation
Easily download official statistics - API
The newest version!
package sdmxdl;
import lombok.NonNull;
import java.util.stream.Stream;
@lombok.Value
@lombok.Builder(toBuilder = true)
public class Query {
public static final Query ALL = Query.builder().build();
@lombok.NonNull
@lombok.Builder.Default
Key key = Key.ALL;
@lombok.NonNull
@lombok.Builder.Default
Detail detail = Detail.FULL;
public @NonNull Stream execute(@NonNull Stream data) {
return data
.filter(key::containsKey)
.map(this::map);
}
private Series map(Series series) {
if (detail.isIgnoreData()) {
if (detail.isIgnoreMeta()) {
return series.toBuilder().clearObs().clearMeta().build();
} else {
return series.toBuilder().clearObs().build();
}
} else {
if (detail.isIgnoreMeta()) {
return series.toBuilder().clearMeta().build();
} else {
return series;
}
}
}
}