Example usage for com.google.common.base Preconditions checkElementIndex

List of usage examples for com.google.common.base Preconditions checkElementIndex

Introduction

In this page you can find the example usage for com.google.common.base Preconditions checkElementIndex.

Prototype

public static int checkElementIndex(int index, int size) 

Source Link

Document

Ensures that index specifies a valid element in an array, list or string of size size .

Usage

From source file:org.grouplens.lenskit.scored.PackedScoredIdList.java

@Override
public ScoredId get(int i) {
    Preconditions.checkElementIndex(i, size());
    return getFlyweight(i);
}

From source file:com.opengamma.strata.market.surface.ConstantSurface.java

@Override
public ConstantSurface withParameter(int parameterIndex, double newValue) {
    Preconditions.checkElementIndex(parameterIndex, 1);
    return new ConstantSurface(metadata, newValue);
}

From source file:eu.lp0.cursus.scoring.scores.base.AbstractRaceDiscardsData.java

@Override
public final int getRaceDiscard(Pilot pilot, int discard) {
    Preconditions.checkArgument(discard > 0);
    Preconditions.checkElementIndex(discard - 1, discards);
    return lazyRaceDiscards.get().get(pilot).get(discard - 1);
}

From source file:com.opengamma.strata.market.curve.ConstantCurve.java

@Override
public ConstantCurve withParameter(int parameterIndex, double newValue) {
    Preconditions.checkElementIndex(parameterIndex, 1);
    return new ConstantCurve(metadata, newValue);
}

From source file:gobblin.source.extractor.extract.kafka.MultiLongWatermark.java

/**
 * The idx'th value of this watermark. idx must be between 0 and size()-1.
 * @return/* ww w.j av a2s .c o  m*/
 */
public long get(int idx) {
    Preconditions.checkElementIndex(idx, this.values.size());
    return this.values.get(idx);
}

From source file:com.bazaarvoice.jless.ast.node.InternalNode.java

@Override
public void setChild(int index, Node child) {
    Preconditions.checkElementIndex(index, _children.size());

    // ignore empty nodes
    if (child == null) {
        return;//from  w  w  w.j a  v  a 2s.  c  o  m
    }

    // detach old child
    Node old = _children.get(index);
    if (old == child) {
        return;
    }
    old.setParent(null);

    // detach new child from old parent
    InternalNode parent = child.getParent();
    if (parent != null && parent != this) {
        TreeUtils.removeChild(parent, child);
    }

    // attach new child
    _children.set(index, child);
    child.setParent(this);
}

From source file:org.eclipse.viatra.query.runtime.localsearch.MatchingFrame.java

/**
 * Sets the value of the variable at the given position. For internal use in LS matching only.
 * /*from   ww w  .  j a v  a  2 s  .co m*/
 * @param position the position of the variable within the frame
 * @param value the value to be set for the variable
 */
public void setValue(int position, Object value) {
    Preconditions.checkElementIndex(position, frame.length);
    frame[position] = value;
}

From source file:com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Generic.GenericCommentsTableModel.java

@Override
public int getColumnWidthInCharacters(int columnIndex) {
    Preconditions.checkElementIndex(columnIndex, columns.length);
    return columns[columnIndex].getWidth();
}

From source file:gobblin.source.extractor.extract.kafka.MultiLongWatermark.java

/**
 * Set the idx'th value of this watermark. idx must be between 0 and size()-1.
 *//*from  ww w  .  j  av  a  2 s. co  m*/
public long set(int idx, long value) {
    Preconditions.checkElementIndex(idx, this.values.size());
    return this.values.set(idx, value);
}

From source file:com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Generic.GenericCommentsTableModel.java

@Override
public String getColumnName(int columnIndex) {
    Preconditions.checkElementIndex(columnIndex, columns.length);
    return columns[columnIndex].getName();
}