001package com.box.sdk;
002
003/**
004 * Class is used to be a range for two byte numbers. Ususally paired with varying search filters.
005 */
006public class SizeRange {
007    private int lowerBoundBytes;
008    private int upperBoundBytes;
009
010    /**
011     * Used for specify a file size range to filter to be used in search.
012     *
013     * @param lowerBoundBytes is the lower size in the byte range.
014     * @param upperBoundBytes is the upper limit in the byte range.
015     */
016    public SizeRange(int lowerBoundBytes, int upperBoundBytes) {
017        this.lowerBoundBytes = lowerBoundBytes;
018        this.upperBoundBytes = upperBoundBytes;
019    }
020
021    /**
022     * Return the lower size in the byte range.
023     *
024     * @return int that represents the lower size of a file.
025     */
026    public int getLowerBoundBytes() {
027        return this.lowerBoundBytes;
028    }
029
030    /**
031     * Set the lower bound bytes in the byte file size range.
032     *
033     * @param lowerBoundBytes used for the lower file size range.
034     */
035    public void setLowerBoundBytes(int lowerBoundBytes) {
036        this.lowerBoundBytes = lowerBoundBytes;
037    }
038
039    /**
040     * Get the upper bound bytes in the file size range.
041     *
042     * @return int that represents the upper limit of the file size.
043     */
044    public int getUpperBoundBytes() {
045        return this.upperBoundBytes;
046    }
047
048    /**
049     * Set the upper bound bytes in the file size range.
050     *
051     * @param upperBoundBytes used for the upper file size range.
052     */
053    public void setUpperBoundBytes(int upperBoundBytes) {
054        this.upperBoundBytes = upperBoundBytes;
055    }
056
057    /**
058     * Used to build out a string a http box api friendly range string.
059     *
060     * @return String that is uses as a rest parameter.
061     */
062    public String buildRangeString() {
063        String lowerBoundString = "";
064        if (this.lowerBoundBytes > -1) {
065            lowerBoundString = String.valueOf(this.lowerBoundBytes);
066        }
067
068        String upperBoundString = "";
069        if (this.upperBoundBytes > -1) {
070            upperBoundString = String.valueOf(this.upperBoundBytes);
071        }
072        String rangeString = String.format("%s,%s", lowerBoundString, upperBoundString);
073        if (rangeString == ",") {
074            rangeString = null;
075        }
076        return rangeString;
077    }
078}