List of usage examples for com.google.common.collect Lists reverse
@CheckReturnValue public static <T> List<T> reverse(List<T> list)
From source file:org.apache.flink.runtime.security.SecurityUtils.java
static void uninstall() { if (installedModules != null) { for (SecurityModule module : Lists.reverse(installedModules)) { try { module.uninstall();/*from w ww .j av a 2 s . c om*/ } catch (UnsupportedOperationException ignored) { } catch (SecurityModule.SecurityInstallException e) { LOG.warn("unable to uninstall a security module", e); } } installedModules = null; } installedContext = new NoOpSecurityContext(); }
From source file:com.puppetlabs.geppetto.validation.runner.MetadataInfo.java
/** * @param circle */ public void addCircularity(List<MetadataInfo> circle) { circularities.add(ImmutableList.copyOf(Lists.reverse(circle))); }
From source file:org.sonar.java.se.checks.ExceptionalYieldChecker.java
private static Set<List<JavaFileScannerContext.Location>> flowsForMethodArguments(ExplodedGraph.Node node, MethodInvocationTree mit) {//from ww w . j a va 2 s. co m ProgramState programState = node.programState; List<SymbolicValue> arguments = Lists.reverse(programState.peekValues(mit.arguments().size())); List<Class<? extends Constraint>> domains = domainsFromArguments(programState, arguments); return FlowComputation.flow(node, new LinkedHashSet<>(arguments), c -> true, c -> false, domains, programState.getLastEvaluated()); }
From source file:com.google.api.codegen.transformer.py.PythonSamplePrintArgTransformer.java
private static String getEnumTypeClassName(MethodContext context, TypeModel type) { checkArgument(type instanceof ProtoTypeRef, "%s: type %s is not a proto type", context.getMethodModel().getSimpleName(), type); checkArgument(((ProtoTypeRef) type).isEnum(), "%s: type %s is not an enum type", context.getMethodModel().getSimpleName(), type); TypeRef protoType = ((ProtoTypeRef) type).getProtoType(); ProtoElement t = protoType.getEnumType(); List<String> names = new ArrayList<>(); while (!(t instanceof ProtoFile)) { names.add(t.getSimpleName());// w w w.j ava2 s .com t = t.getParent(); } names.add("enums"); StringBuilder builder = new StringBuilder(); for (String name : Lists.reverse(names)) { builder.append(name).append("."); } return builder.substring(0, builder.length() - 1); }
From source file:org.killbill.billing.plugin.analytics.dao.factory.BusinessAccountTransitionFactory.java
@VisibleForTesting Collection<BusinessAccountTransitionModelDao> createBusinessAccountTransitions( final BusinessContextFactory businessContextFactory, final Iterable<SubscriptionEvent> blockingStatesOrdered) throws AnalyticsRefreshException { final Account account = businessContextFactory.getAccount(); final Long accountRecordId = businessContextFactory.getAccountRecordId(); final Long tenantRecordId = businessContextFactory.getTenantRecordId(); final ReportGroup reportGroup = businessContextFactory.getReportGroup(); final List<BusinessAccountTransitionModelDao> businessAccountTransitions = new LinkedList<BusinessAccountTransitionModelDao>(); // Reverse to compute the end date of each state final List<SubscriptionEvent> blockingStates = Lists .reverse(ImmutableList.<SubscriptionEvent>copyOf(blockingStatesOrdered)); // To remove duplicates final Set<UUID> blockingStateIdsSeen = new HashSet<UUID>(); final Map<String, LocalDate> previousStartDatePerService = new HashMap<String, LocalDate>(); for (final SubscriptionEvent state : blockingStates) { if (blockingStateIdsSeen.contains(state.getId())) { continue; } else {//w w w . j a va 2 s . c om blockingStateIdsSeen.add(state.getId()); } final Long blockingStateRecordId = businessContextFactory.getBlockingStateRecordId(state.getId()); final AuditLog creationAuditLog = businessContextFactory .getBlockingStateCreationAuditLog(state.getId()); // TODO We're missing information about block billing, etc. Maybe capture it in an event name? final BusinessAccountTransitionModelDao accountTransition = new BusinessAccountTransitionModelDao( account, accountRecordId, state.getServiceName(), state.getServiceStateName(), state.getEffectiveDate(), blockingStateRecordId, previousStartDatePerService.get(state.getServiceName()), creationAuditLog, tenantRecordId, reportGroup); businessAccountTransitions.add(accountTransition); previousStartDatePerService.put(state.getServiceName(), state.getEffectiveDate()); } // Reverse again to store the events chronologically return Lists.<BusinessAccountTransitionModelDao>reverse(businessAccountTransitions); }
From source file:de.marx_labs.utilities.common.searchtree.MapDBSearchTree.java
@Override public Set<T> findOld(Long term, int size) { Set<T> matches = new LinkedHashSet<T>(); Long key = treeMap.lowerKey(term); for (int i = 0; i < size; i++) { matches.add(treeMap.get(key));/*from w w w . j a va 2 s .com*/ key = treeMap.lowerKey(key); if (key == null) { break; } } List<T> reverseList = Lists.reverse(Lists.newArrayList(matches)); return Sets.newLinkedHashSet(reverseList); }
From source file:com.googlecode.blaisemath.graphics.swing.MultilineTextRenderer.java
@Override public void render(AnchoredText text, AttributeSet style, Graphics2D canvas) { if (Strings.isNullOrEmpty(text.getText())) { return;//from w ww .j ava2 s. c om } Font f = Styles.getFont(style); canvas.setFont(f); canvas.setColor(style.getColor(Styles.FILL)); double lineHeight = canvas.getFontMetrics().getHeight(); Rectangle2D bounds = boundingBox(text, style); String[] lns = text.getText().split("\n|\r\n"); double y0 = bounds.getMaxY(); double x0 = bounds.getMinX(); for (String s : Lists.reverse(Arrays.asList(lns))) { canvas.drawString(s, (float) x0, (float) y0); y0 -= lineHeight; } }
From source file:org.hawkular.metrics.core.impl.BucketedOutputMapper.java
@Override public BucketedOutput<POINT> call(List<DataPoint<DATA>> dataList) { BucketedOutput<POINT> output = new BucketedOutput<>(tenantId, id.getName(), Collections.emptyMap()); output.setData(new ArrayList<>(buckets.getCount())); if (!(dataList instanceof RandomAccess)) { dataList = new ArrayList<>(dataList); }/*from w ww . j av a2s . c o m*/ if (isDescending) { dataList = Lists.reverse(dataList); // We expect input data to be sorted in descending order } int dataIndex = 0; DataPoint<DATA> previous; for (int bucketIndex = 0; bucketIndex < buckets.getCount(); bucketIndex++) { long from = buckets.getStart() + bucketIndex * buckets.getStep(); long to = buckets.getStart() + (bucketIndex + 1) * buckets.getStep(); if (dataIndex >= dataList.size()) { // Reached end of data points output.getData().add(newEmptyPointInstance(from, to)); continue; } DataPoint<DATA> current = dataList.get(dataIndex); if (current.getTimestamp() >= to) { // Current data point does not belong to this bucket output.getData().add(newEmptyPointInstance(from, to)); continue; } List<DataPoint<DATA>> metricDatas = new ArrayList<>(); do { // Add current value to this bucket's summary metricDatas.add(current); // Move to next data point previous = current; dataIndex++; current = dataIndex < dataList.size() ? dataList.get(dataIndex) : null; // checkOrder(previous, current); // Continue until end of data points is reached or data point does not belong to this bucket } while (current != null && current.getTimestamp() < to); output.getData().add(newPointInstance(from, to, metricDatas)); } return output; }
From source file:ch.puzzle.itc.mobiliar.presentation.globalFunctions.EditGlobalFunctionView.java
private void refreshRevisionInformation(Integer funId) { revisionInformations = Lists.reverse(functionsBoundary.getFunctionRevisions(funId)); }
From source file:org.ros.android.renderer.VisualizationView.java
@Override public boolean onTouchEvent(MotionEvent event) { for (Layer layer : Lists.reverse(layers)) { if (layer != null && layer.onTouchEvent(this, event)) { return true; }// w w w. j av a2s . c o m } return false; }