List of usage examples for com.google.common.collect ImmutableList get
E get(int index);
From source file:org.xlrnet.tibaija.commands.math.UnaryCommand.java
@NotNull @Override//from ww w . j ava 2s .co m protected Optional<Value> execute(@NotNull ImmutableList<Parameter> arguments) { final Value operand = arguments.get(0).value(); final Value result = applyOperator(operand); LOGGER.debug("({}) {} -> {}", operator, operand.getValue(), result.getValue()); return Optional.of(result); }
From source file:org.xlrnet.tibaija.commands.math.UnaryCommand.java
/** * Check if both arguments are of a numerical type and not null. * * @param arguments//from w w w .jav a 2 s . com * The arguments for the command. * @return True if both arguments are of a numerical type and not null. */ @Override protected boolean hasValidArgumentValues(@NotNull ImmutableList<Parameter> arguments) { final Value operand = arguments.get(0).value(); checkNotNull(operand); if (!ValueUtils.isNumberOrList(operand)) throw new IllegalTypeException("Operand is not a Number: " + operand.getValue(), Variables.VariableType.NUMBER, operand.getType()); return true; }
From source file:com.opengamma.strata.pricer.calibration.CurveCalibrator.java
private static DoubleMatrix jacobianIndirect(DoubleMatrix res, DoubleMatrix pDmCurrentMatrix, int nbTrades, int totalParamsGroup, int totalParamsPrevious, ImmutableList<CurveParameterSize> orderPrevious, ImmutableMap<CurveName, JacobianCalibrationMatrix> jacobiansPrevious) { if (totalParamsPrevious == 0) { return DoubleMatrix.EMPTY; }/*w w w. j a v a2 s. co m*/ double[][] nonDirect = new double[totalParamsGroup][totalParamsPrevious]; for (int i = 0; i < nbTrades; i++) { System.arraycopy(res.rowArray(i), 0, nonDirect[i], 0, totalParamsPrevious); } DoubleMatrix pDpPreviousMatrix = (DoubleMatrix) MATRIX_ALGEBRA .scale(MATRIX_ALGEBRA.multiply(pDmCurrentMatrix, DoubleMatrix.copyOf(nonDirect)), -1d); // all curves: order and size int[] startIndexBefore = new int[orderPrevious.size()]; for (int i = 1; i < orderPrevious.size(); i++) { startIndexBefore[i] = startIndexBefore[i - 1] + orderPrevious.get(i - 1).getParameterCount(); } // transition Matrix: all curves from previous groups double[][] transition = new double[totalParamsPrevious][totalParamsPrevious]; for (int i = 0; i < orderPrevious.size(); i++) { int paramCountOuter = orderPrevious.get(i).getParameterCount(); JacobianCalibrationMatrix thisInfo = jacobiansPrevious.get(orderPrevious.get(i).getName()); DoubleMatrix thisMatrix = thisInfo.getJacobianMatrix(); int startIndexInner = 0; for (int j = 0; j < orderPrevious.size(); j++) { int paramCountInner = orderPrevious.get(j).getParameterCount(); if (thisInfo.containsCurve(orderPrevious.get(j).getName())) { // If not, the matrix stay with 0 for (int k = 0; k < paramCountOuter; k++) { System.arraycopy(thisMatrix.rowArray(k), startIndexInner, transition[startIndexBefore[i] + k], startIndexBefore[j], paramCountInner); } } startIndexInner += paramCountInner; } } DoubleMatrix transitionMatrix = DoubleMatrix.copyOf(transition); return (DoubleMatrix) MATRIX_ALGEBRA.multiply(pDpPreviousMatrix, transitionMatrix); }
From source file:org.waveprotocol.box.server.persistence.blocks.impl.SegmentOperationImpl.java
@Override public long getTargetVersion() { ImmutableList<? extends WaveletOperation> ops = rawOperation.getOperations(); return ops.get(ops.size() - 1).getContext().getSegmentVersion(); }
From source file:org.waveprotocol.box.server.persistence.blocks.impl.SegmentOperationImpl.java
@Override public long getTimestamp() { ImmutableList<? extends WaveletOperation> ops = rawOperation.getOperations(); return ops.get(ops.size() - 1).getContext().getTimestamp(); }
From source file:com.facebook.buck.query.BuildFileFunction.java
@Override public Set<QueryTarget> eval(QueryEnvironment env, ImmutableList<Argument> args, ListeningExecutorService executor) throws QueryException, InterruptedException { Set<QueryTarget> argumentSet = args.get(0).getExpression().eval(env, executor); return Sets.newHashSet(env.getBuildFiles(argumentSet)); }
From source file:org.spongepowered.mod.mixin.api.text.MixinTextTranslatable.java
private Object[] unwrapArguments(ImmutableList<Object> args) { Object[] ret = new Object[args.size()]; for (int i = 0; i < args.size(); ++i) { final Object arg = args.get(i); if (arg instanceof SpongeText) { ret[i] = ((SpongeText) arg).toComponent(); } else {//from w w w . j a v a 2 s.c om ret[i] = arg; } } return ret; }
From source file:com.google.template.soy.jssrc.dsl.ConditionalBuilder.java
/** Finishes building this conditional. */ @CheckReturnValue/* ww w. j av a 2 s .c o m*/ public CodeChunk build() { ImmutableList<IfThenPair> pairs = conditions.build(); if (isRepresentableAsTernaryExpression(pairs)) { return Ternary.create(pairs.get(0).predicate, (CodeChunk.WithValue) pairs.get(0).consequent, (CodeChunk.WithValue) trailingElse); } else { return Conditional.create(pairs, trailingElse); } }
From source file:org.spongepowered.common.mixin.api.text.MixinTextTranslatable.java
private Object[] unwrapArguments(ImmutableList<Object> args) { Object[] result = new Object[args.size()]; for (int i = 0; i < args.size(); i++) { final Object arg = args.get(i); if (arg instanceof IMixinText) { result[i] = ((IMixinText) arg).toComponent(); } else {//from ww w. j a v a2 s .co m result[i] = arg; } } return result; }
From source file:com.google.errorprone.bugpatterns.MixedArrayDimensions.java
private Description checkArrayDimensions(Tree tree, Tree type, VisitorState state) { if (!(type instanceof ArrayTypeTree)) { return NO_MATCH; }// w w w . j a v a 2 s . c o m CharSequence source = state.getSourceCode(); for (; type instanceof ArrayTypeTree; type = ((ArrayTypeTree) type).getType()) { Tree elemType = ((ArrayTypeTree) type).getType(); int start = state.getEndPosition(elemType); int end = state.getEndPosition(type); if (start >= end) { continue; } String dim = source.subSequence(start, end).toString(); if (dim.isEmpty()) { continue; } ImmutableList<ErrorProneToken> tokens = ErrorProneTokens.getTokens(dim.trim(), state.context); if (tokens.size() > 2 && tokens.get(0).kind() == TokenKind.IDENTIFIER) { int nonWhitespace = CharMatcher.isNot(' ').indexIn(dim); int idx = dim.indexOf("[]", nonWhitespace); if (idx > nonWhitespace) { String replacement = dim.substring(idx, dim.length()) + dim.substring(0, idx); return describeMatch(tree, SuggestedFix.replace(start, end, replacement)); } } } return NO_MATCH; }