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

com.netflix.astyanax.cql.reads.model.CqlRangeBuilder Maven / Gradle / Ivy

package com.netflix.astyanax.cql.reads.model;

/**
 * Helpful class that tracks the state for building a {@link ColumnSlice} query using column range specification. 
 * 
 * @author poberai
 *
 * @param 
 */
public class CqlRangeBuilder {
	
    private T start = null;
    private T end = null;
    private int limit = -1;
    private boolean reversed = false;
    private int fetchSize = -1;

    private String columnName = "column1";

    public CqlRangeBuilder withRange(CqlRangeImpl oldRange) {
    	if (oldRange != null) {
    		this.start = oldRange.getCqlStart();
    		this.end = oldRange.getCqlEnd();
    		this.limit = oldRange.getLimit();
    		this.reversed = oldRange.isReversed();
    		this.fetchSize = oldRange.getFetchSize();
    	}
        return this;
    }

    public CqlRangeBuilder setLimit(int count) {
        this.limit = count;
        return this;
    }

    public int getLimit() {
    	return this.limit;
    }
    
    public CqlRangeBuilder setReversed(boolean reversed) {
        this.reversed = reversed;
        return this;
    }
    
    public boolean getReversed() {
    	return this.reversed;
    }

    public CqlRangeBuilder setStart(T value) {
        start = value;
        return this;
    }

    public T getStart() {
    	return this.start;
    }
    
    public CqlRangeBuilder setEnd(T value) {
        end = value;
        return this;
    }

    public T getEnd() {
    	return this.end;
    }
    
    public CqlRangeBuilder setColumn(String name) {
    	this.columnName = name;
    	return this;
    }

    public String getColumn() {
    	return this.columnName;
    }
    
    public CqlRangeBuilder setFetchSize(int count) {
        this.fetchSize = count;
        return this;
    }

    public int getFetchSize() {
    	return this.fetchSize;
    }

    public CqlRangeImpl build() {
    	return new CqlRangeImpl(columnName, start, end, limit, reversed, fetchSize);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy