List of usage examples for com.google.common.base Preconditions checkPositionIndex
public static int checkPositionIndex(int index, int size)
From source file:io.github.msdk.util.MsSpectrumUtil.java
/** * Returns the m/z range of given data points. Can return null if the data * point list is empty.//from w w w .j av a 2s .c o m * * @return a {@link com.google.common.collect.Range} object. * @param mzValues * an array of double. * @param size * a {@link java.lang.Integer} object. */ @Nullable public static Range<Double> getMzRange(@Nonnull double mzValues[], @Nonnull Integer size) { // Parameter check Preconditions.checkNotNull(mzValues); Preconditions.checkNotNull(size); Preconditions.checkPositionIndex(size, mzValues.length); if (size == 0) return null; double min = mzValues[0]; double max = mzValues[size - 1]; return Range.closed(min, max); }
From source file:io.github.msdk.util.ChromatogramUtil.java
/** * Returns the range of ChromatographyInfo of all data points in this * feature.//from w ww.j a va 2 s. c om * * @return a {@link com.google.common.collect.Range} object. * @param rtValues * an array of * {@link io.github.msdk.datamodel.rawdata.ChromatographyInfo} * objects. * @param size * a {@link java.lang.Integer} object. */ @SuppressWarnings("null") @Nonnull public static Range<ChromatographyInfo> getDataPointsChromatographyRange(@Nonnull ChromatographyInfo rtValues[], @Nonnull Integer size) { // Parameter check Preconditions.checkNotNull(rtValues); Preconditions.checkNotNull(size); Preconditions.checkPositionIndex(size, rtValues.length); final Range<ChromatographyInfo> chromatographyRange = Range.closed(rtValues[0], rtValues[size - 1]); return chromatographyRange; }
From source file:io.airlift.compress.ByteArrayOutputStream.java
public void write(int b) { Preconditions.checkPositionIndex(size + 1, buffer.length); buffer[size++] = (byte) b; }
From source file:org.iq80.snappy.ByteArrayOutputStream.java
@Override public void write(int b) { Preconditions.checkPositionIndex(size + 1, buffer.length); buffer[size++] = (byte) b; }
From source file:io.github.msdk.util.MsSpectrumUtil.java
/** * Calculates the total ion current (=sum of all intensity values) * * @return a {@link java.lang.Float} object. * @param intensityValues//w ww . j av a2 s .c o m * an array of float. * @param size * a {@link java.lang.Integer} object. */ public static @Nonnull Float getTIC(@Nonnull float intensityValues[], @Nonnull Integer size) { // Parameter check Preconditions.checkNotNull(intensityValues); Preconditions.checkNotNull(size); Preconditions.checkPositionIndex(size, intensityValues.length); float tic = 0f; for (int i = 0; i < size; i++) { tic += intensityValues[i]; } return tic; }
From source file:org.b1.pack.standard.common.ByteArrayWritable.java
@Override public void writeTo(OutputStream stream, long start, long end) throws IOException { Preconditions.checkPositionIndex(Ints.checkedCast(end), size); stream.write(bytes, Ints.checkedCast(start), Ints.checkedCast(end - start)); }
From source file:com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.DeleteCommentAction.java
public DeleteCommentAction(final JTable table, final int row, final int column) { super("Delete Comment"); this.table = Preconditions.checkNotNull(table, "IE02635: table argument can not be null"); this.row = Preconditions.checkPositionIndex(row, this.table.getModel().getRowCount()); this.column = Preconditions.checkPositionIndex(column, this.table.getModel().getColumnCount()); }
From source file:io.airlift.compress.ByteArrayOutputStream.java
public void write(byte b[], int off, int len) { Preconditions.checkPositionIndex(size + len, buffer.length); System.arraycopy(b, off, buffer, size, len); size += len;/*from ww w . j a v a2s . co m*/ }
From source file:org.iq80.snappy.ByteArrayOutputStream.java
@Override public void write(byte b[], int off, int len) { Preconditions.checkPositionIndex(size + len, buffer.length); System.arraycopy(b, off, buffer, size, len); size += len;/* w w w . ja v a2 s .c o m*/ }
From source file:ca.draconic.stipple.wangtiles.RecursiveTile.java
public RecursiveTile<T> getSubtile(int x, int y) { Preconditions.checkPositionIndex(x, k); Preconditions.checkPositionIndex(y, k); return subtiles[x + k * y]; }