Source:
<code>public TopNQuery( @JsonProperty("dataSource") DataSource dataSource, @JsonProperty("virtualColumns") VirtualColumns virtualColumns, @JsonProperty("dimension") DimensionSpec dimensionSpec, @JsonProperty("metric") TopNMetricSpec topNMetricSpec, @JsonProperty("threshold") int threshold, @JsonProperty("intervals") QuerySegmentSpec querySegmentSpec, @JsonProperty("filter") DimFilter dimFilter, @JsonProperty("granularity") QueryGranularity granularity, @JsonProperty("aggregations") List<AggregatorFactory> aggregatorSpecs, @JsonProperty("postAggregations") List<PostAggregator> postAggregatorSpecs, @JsonProperty("context") Map<String, Object> context ) { super(dataSource, querySegmentSpec, false, context); <START> this.virtualColumns = virtualColumns == null ? VirtualColumns.EMPTY : virtualColumns; <END> this.dimensionSpec = dimensionSpec; this.topNMetricSpec = topNMetricSpec; this.threshold = threshold; this.dimFilter = dimFilter; this.granularity = granularity; this.aggregatorSpecs = aggregatorSpecs == null ? ImmutableList.<AggregatorFactory>of() : aggregatorSpecs; this.postAggregatorSpecs = postAggregatorSpecs == null ? ImmutableList.<PostAggregator>of() : postAggregatorSpecs; Preconditions.checkNotNull(dimensionSpec, "dimensionSpec can't be null"); Preconditions.checkNotNull(topNMetricSpec, "must specify a metric"); Preconditions.checkArgument(threshold != 0, "Threshold cannot be equal to 0."); topNMetricSpec.verifyPreconditions(this.aggregatorSpecs, this.postAggregatorSpecs); Queries.verifyAggregations(this.aggregatorSpecs, this.postAggregatorSpecs); }</code><technical_language>Consider adding helper VirualColumns.nullToEmpty()</technical_language>

Target:
public TopNQuery( @JsonProperty("dataSource") DataSource dataSource, @JsonProperty("virtualColumns") VirtualColumns virtualColumns, @JsonProperty("dimension") DimensionSpec dimensionSpec, @JsonProperty("metric") TopNMetricSpec topNMetricSpec, @JsonProperty("threshold") int threshold, @JsonProperty("intervals") QuerySegmentSpec querySegmentSpec, @JsonProperty("filter") DimFilter dimFilter, @JsonProperty("granularity") QueryGranularity granularity, @JsonProperty("aggregations") List<AggregatorFactory> aggregatorSpecs, @JsonProperty("postAggregations") List<PostAggregator> postAggregatorSpecs, @JsonProperty("context") Map<String, Object> context ) { super(dataSource, querySegmentSpec, false, context); this.virtualColumns = VirtualColumns.nullToEmpty(virtualColumns); this.dimensionSpec = dimensionSpec; this.topNMetricSpec = topNMetricSpec; this.threshold = threshold; this.dimFilter = dimFilter; this.granularity = granularity; this.aggregatorSpecs = aggregatorSpecs == null ? ImmutableList.<AggregatorFactory>of() : aggregatorSpecs; this.postAggregatorSpecs = Queries.prepareAggregations( this.aggregatorSpecs, postAggregatorSpecs == null ? ImmutableList.<PostAggregator>of() : postAggregatorSpecs ); Preconditions.checkNotNull(dimensionSpec, "dimensionSpec can't be null"); Preconditions.checkNotNull(topNMetricSpec, "must specify a metric"); Preconditions.checkArgument(threshold != 0, "Threshold cannot be equal to 0."); topNMetricSpec.verifyPreconditions(this.aggregatorSpecs, this.postAggregatorSpecs); }