All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.sphere.client.model.facets.NumberRangeFacetItem Maven / Gradle / Ivy

There is a newer version: 0.72.1
Show newest version
package io.sphere.client.model.facets;

import com.google.common.base.Function;
import io.sphere.internal.util.SearchUtil;

/** Number of resources found for an individual range of a number range facet ({@link NumberRangeFacetResult}). */
public class NumberRangeFacetItem implements FacetResultItem {
    private Double from;
    private Double to;
    private Double mean;
    private int count;

    /** The lower endpoint of this range. */
    public Double getFrom() { return from; }

    /** The upper endpoint of this range. */
    public Double getTo() { return to; }

    /** Arithmetic mean of values that fall into this range. */
    public Double getMean() { return mean; }

    /** Number of resources that fall into this range. */
    public int getCount() { return count; }

    static Function fromBackendDoubles = new Function() {
        public NumberRangeFacetItem apply(RangeFacetItem rangeCount) {
            return new NumberRangeFacetItem(
                    rangeCount.getFrom(),
                    SearchUtil.adjustDoubleBackFromSearch(rangeCount.getTo()),
                    rangeCount.getMean(),
                    rangeCount.getCount());
        }
    };

    private NumberRangeFacetItem(double from, double to, double mean, int count) {
        this.from = from;
        this.to = to;
        this.mean = mean;
        this.count = count;
    }

    @Override
    public String toString() {
        return "NumberRangeFacetItem{" +
                "from=" + from +
                ", to=" + to +
                ", mean=" + mean +
                ", count=" + count +
                '}';
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy