List of usage examples for com.google.common.base Preconditions checkPositionIndex
public static int checkPositionIndex(int index, int size)
From source file:com.lithium.yoda.IsoWeekYear.java
@Override public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException { Preconditions.checkPositionIndex(0, arguments.length); if (!(arguments[0] instanceof LongObjectInspector)) { throw new IllegalArgumentException( "Input to weekyear UDF must be a bigint. Given " + arguments[0].getTypeName()); }//w ww .java 2 s .c o m timestampOi = (LongObjectInspector) arguments[0]; return PrimitiveObjectInspectorFactory.javaIntObjectInspector; }
From source file:com.lithium.yoda.IsoWeekOfWeekYear.java
@Override public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException { Preconditions.checkPositionIndex(0, arguments.length); if (!(arguments[0] instanceof LongObjectInspector)) { throw new IllegalArgumentException( "Input to week_of_weekyear UDF must be a bigint. Given " + arguments[0].getTypeName()); }//from w w w . ja v a 2 s .com timestampOi = (LongObjectInspector) arguments[0]; return PrimitiveObjectInspectorFactory.javaIntObjectInspector; }
From source file:io.github.bktlib.command.args.CommandArgsImpl.java
@Override public String get(int argIndex) { Preconditions.checkPositionIndex(argIndex, size()); return rawArgs[argIndex]; }
From source file:com.lithium.yoda.UsWeekYear.java
@Override public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException { Preconditions.checkPositionIndex(0, arguments.length); if (!(arguments[0] instanceof LongObjectInspector)) { throw new IllegalArgumentException( "Input to UsWeekOfWeekYear UDF must be a bigint. Given " + arguments[0].getTypeName()); }//from w w w. ja v a 2s. c o m timestampOi = (LongObjectInspector) arguments[0]; calendar.setTimeZone(TimeZone.getTimeZone("UTC")); calendar.setFirstDayOfWeek(Calendar.SUNDAY); calendar.setMinimalDaysInFirstWeek(4); // Which ever year has 4 weeks starting on Sunday get's the week return PrimitiveObjectInspectorFactory.javaIntObjectInspector; }
From source file:org.sonar.sslr.internal.text.LocatedText.java
@Override public TextLocation getLocation(int index) { Preconditions.checkPositionIndex(index, length()); int line = getLineNumber(index); int column = index - getLineStart(line) + 1; return new TextLocation(file, uri, line, column); }
From source file:org.xpect.expectation.impl.AbstractExpectation.java
public AbstractExpectation(XpectArgument argument, TargetSyntaxSupport targetSyntax) { super();//from w ww . j a va 2s. c o m this.argument = argument; this.region = argument.getStatement().getRelatedRegion(IExpectationRegion.class); Preconditions.checkPositionIndex(region.getOffset(), region.getDocument().length()); Preconditions.checkPositionIndex(region.getOffset() + region.getLength(), region.getDocument().length()); this.targetSyntax = targetSyntax; this.targetLiteral = targetSyntax.getLiteralSupport(region.getOffset()); }
From source file:edu.byu.nlp.util.DenseCounter.java
/** {@inheritDoc} */ @Override/*from w ww. j a va 2 s .c o m*/ public int decrementCount(Integer ele, int val) { Preconditions.checkNotNull(ele); Preconditions.checkPositionIndex(ele, counts.length); int ret = counts[ele]; counts[ele] -= val; return ret; }
From source file:ca.draconic.stipple.wangtiles.RecursiveTile.java
protected void setSubtile(int x, int y, RecursiveTile<T> t) { Preconditions.checkPositionIndex(x, k); Preconditions.checkPositionIndex(y, k); Preconditions.checkArgument(t.set == this.set); subtiles[x + k * y] = t;// ww w . java 2s . c o m }
From source file:io.github.msdk.util.ChromatogramUtil.java
/** * Returns the range of intensity values of all data points in this * chromatogram.//from w w w . ja va2s . c o m * * @return a {@link com.google.common.collect.Range} object. * @param intensityValues * an array of {@link java.lang.Float} objects. * @param size * a {@link java.lang.Integer} object. */ public static @Nullable Range<Float> getDataPointsIntensityRange(@Nonnull Float intensityValues[], @Nonnull Integer size) { // Parameter check Preconditions.checkNotNull(intensityValues); Preconditions.checkNotNull(size); Preconditions.checkPositionIndex(size, intensityValues.length); if (size == 0) return null; float lower = intensityValues[0]; float upper = intensityValues[0]; for (int i = 0; i < size; i++) { if (intensityValues[i] < lower) lower = intensityValues[i]; if (intensityValues[i] > upper) upper = intensityValues[i]; } final Range<Float> intensityRange = Range.closed(lower, upper); return intensityRange; }
From source file:com.lithium.yoda.IsoStartDateOfWeek.java
@Override public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException { Preconditions.checkPositionIndex(0, arguments.length); if (!(arguments[0] instanceof LongObjectInspector)) { throw new IllegalArgumentException( "Input to IsoStartDateOfWeek UDF must be a bigint. Given " + arguments[0].getTypeName()); }//from w w w . j a v a 2 s . com timestampOi = (LongObjectInspector) arguments[0]; YYYYMMDD = org.joda.time.format.DateTimeFormat.forPattern("YYYY-MM-dd"); mdt = new MutableDateTime(0, DateTimeZone.UTC); return PrimitiveObjectInspectorFactory.javaIntObjectInspector; }