List of usage examples for com.google.common.collect Iterables getLast
public static <T> T getLast(Iterable<T> iterable)
From source file:org.sosy_lab.cpachecker.cpa.smg.refiner.SMGRefiner.java
private VariableTrackingPrecision mergeValuePrecisionsForSubgraph(final ARGState pRefinementRoot, final ARGReachedSet pReached) { // get all unique precisions from the subtree Set<VariableTrackingPrecision> uniquePrecisions = Sets.newIdentityHashSet(); for (ARGState descendant : getNonCoveredStatesInSubgraph(pRefinementRoot)) { uniquePrecisions.add(extractValuePrecision(pReached, descendant)); }/*from w w w .j a v a 2 s .c o m*/ // join all unique precisions into a single precision VariableTrackingPrecision mergedPrecision = Iterables.getLast(uniquePrecisions); for (VariableTrackingPrecision precision : uniquePrecisions) { mergedPrecision = mergedPrecision.join(precision); } return mergedPrecision; }
From source file:org.pentaho.di.trans.dataservice.optimization.paramgen.AutoParameterGenerationService.java
private List<PushDownOptimizationMeta> generateOptimizationList(SourceLineageMap sourceLineageMap) { Map<String, Set<List<StepFieldOperations>>> inputSteps = Multimaps.asMap(sourceLineageMap); List<PushDownOptimizationMeta> optimizationList = Lists.newArrayListWithExpectedSize(inputSteps.size()); for (Map.Entry<String, Set<List<StepFieldOperations>>> inputStepLineage : inputSteps.entrySet()) { String inputStep = inputStepLineage.getKey(); Set<List<StepFieldOperations>> lineageSet = inputStepLineage.getValue(); PushDownOptimizationMeta pushDownOptimizationMeta = new PushDownOptimizationMeta(); ParameterGeneration parameterGeneration = serviceProvider.createPushDown(); pushDownOptimizationMeta.setName(MessageFormat.format("Parameter Generator: {0}", inputStep)); pushDownOptimizationMeta.setStepName(inputStep); pushDownOptimizationMeta.setType(parameterGeneration); parameterGeneration/*from w w w . j a v a 2 s. co m*/ .setParameterName("DATA_SERVICE_QUERY_" + inputStep.replaceAll("\\s", "_").toUpperCase()); for (List<StepFieldOperations> fieldLineage : lineageSet) { StepFieldOperations origin = fieldLineage.get(0); StepFieldOperations last = Iterables.getLast(fieldLineage); parameterGeneration.createFieldMapping(last.getFieldName(), origin.getFieldName()); } optimizationList.add(pushDownOptimizationMeta); } return optimizationList; }
From source file:org.eclipse.hawkbit.ui.common.table.AbstractTable.java
private void onValueChange() { eventBus.publish(this, UploadArtifactUIEvent.HIDE_DROP_HINTS); final Set<Long> values = getTableValue(this); Long lastId = null;/*from w w w.jav a2 s . co m*/ if (!values.isEmpty()) { lastId = Iterables.getLast(values); } setManagementEntityStateValues(values, lastId); selectEntity(lastId); afterEntityIsSelected(); }
From source file:edu.harvard.med.screensaver.ui.libraries.LibraryCopyPlateCommentSearchResults.java
@Override protected List<? extends TableColumn<PlateActivity, ?>> buildColumns() { List<TableColumn<PlateActivity, ?>> columns = Lists.newArrayList(); columns.add(new IntegerColumn<PlateActivity>("Plate", "Plate number", TableColumn.UNGROUPED) { @Override/*from www .j a va 2s. co m*/ public Integer getCellValue(PlateActivity ae) { return ae.getPlate().getPlateNumber(); } }); columns.add(new TextColumn<PlateActivity>("Copy", "The library copy containing the plate", TableColumn.UNGROUPED) { @Override public String getCellValue(PlateActivity ae) { return ae.getPlate().getCopy().getName(); } @Override public boolean isCommandLink() { return true; } @Override public Object cellAction(PlateActivity ae) { getIsPanelCollapsedMap().put("lcpcsr", true); return _libraryCopyViewer.viewEntity(ae.getPlate().getCopy()); } }); Iterables.getLast(columns).setVisible(_mode != Mode.COPY); columns.add(new TextColumn<PlateActivity>("Library", "The library containing the plate", TableColumn.UNGROUPED) { @Override public String getCellValue(PlateActivity ae) { return ae.getPlate().getCopy().getLibrary().getLibraryName(); } @Override public boolean isCommandLink() { return true; } @Override public Object cellAction(PlateActivity ae) { getIsPanelCollapsedMap().put("lcpcsr", true); return _libraryViewer.viewEntity(ae.getPlate().getCopy().getLibrary()); } }); Iterables.getLast(columns).setVisible(_mode == Mode.ALL); columns.add(new TextColumn<PlateActivity>("Comment", "Comment", TableColumn.UNGROUPED) { @Override public String getCellValue(PlateActivity activity) { return activity.getAdministrativeActivity().getComments(); } }); columns.add(new DateColumn<PlateActivity>("Comment Date", "The date that a corresponding real-world activity was performed", TableColumn.UNGROUPED) { @Override protected LocalDate getDate(PlateActivity pa) { return pa.getAdministrativeActivity().getDateOfActivity(); } }); columns.add(new UserNameColumn<PlateActivity, ScreensaverUser>(null, "Comment by", "The administrator who made the comment", TableColumn.UNGROUPED, null) { @Override public ScreensaverUser getUser(PlateActivity ae) { return (ScreensaverUser) ae.getAdministrativeActivity().getPerformedBy(); } }); return columns; }
From source file:org.eclipse.xtext.xbase.typesystem.internal.ConstructorLinkingCandidate.java
@Override protected List<JvmTypeParameter> getDeclaredTypeParameters() { if (isAnonymousClassConstructorCall()) { JvmDeclaredType anonymousType = getConstructor().getDeclaringType(); JvmTypeReference superType = Iterables.getLast(anonymousType.getSuperTypes()); JvmType rawSuperType = superType.getType(); if (rawSuperType instanceof JvmTypeParameterDeclarator) { return ((JvmTypeParameterDeclarator) rawSuperType).getTypeParameters(); }/*ww w .ja va 2 s. co m*/ return Collections.emptyList(); } return new FeatureLinkHelper().getDeclaredTypeParameters(getConstructor()); }
From source file:org.diqube.plan.planner.MasterColumnManager.java
@Override public void wireOutputOfColumnIfAvailable(String colName, ExecutablePlanStep targetStep) { if (functionMasterSteps.containsKey(colName)) { ExecutablePlanStep previousStep = Iterables.getLast(functionMasterSteps.get(colName)); masterWireManager.wire(ColumnVersionBuiltConsumer.class, previousStep, targetStep); masterWireManager.wire(ColumnBuiltConsumer.class, previousStep, targetStep); } else if (columnsThatNeedToBeAvailable.contains(colName)) { if (!delayedWires.containsKey(colName)) delayedWires.put(colName, new ArrayList<>()); delayedWires.get(colName).add(targetStep); }/* w w w .jav a2 s .c o m*/ }
From source file:org.opendaylight.sfc.scfofrenderer.utils.SfcNshHeader.java
public static SfcNshHeader getSfcNshHeader(RspName rspName) { if (rspName == null) { LOG.error("getSfcNshHeader: rspName is null\n"); return null; }//w w w. j a va2 s . co m RenderedServicePath renderedServicePath = SfcProviderRenderedPathAPI.readRenderedServicePath(rspName); if (renderedServicePath == null) { LOG.error("getSfcNshHeader: rsp is null\n"); return null; } RenderedServicePathFirstHop rspFirstHop = SfcProviderRenderedPathAPI .readRenderedServicePathFirstHop(rspName); if (rspFirstHop == null) { LOG.error("getSfcNshHeader: rsp first hop is null\n"); return null; } if (renderedServicePath.getRenderedServicePathHop() == null) { LOG.error("getSfcNshHeader: getRenderedServicePathHop is null\n"); return null; } RenderedServicePathHop lastRspHop = Iterables.getLast(renderedServicePath.getRenderedServicePathHop()); if (lastRspHop == null) { LOG.error("getSfcNshHeader: last rsp hop is null\n"); return null; } RenderedServicePathHop theFirstHop = renderedServicePath.getRenderedServicePathHop().get(0); SfcNshHeader sfcNshHeader = new SfcNshHeader().setRsp(renderedServicePath) .setNshNsp(renderedServicePath.getPathId()).setNshStartNsi(rspFirstHop.getStartingIndex()) .setNshEndNsi((short) (lastRspHop.getServiceIndex().intValue() - 1)) .setSffName(lastRspHop.getServiceFunctionForwarder()) .setFirstSfName(theFirstHop.getServiceFunctionName()); if (rspFirstHop.getIp() != null) { sfcNshHeader.setVxlanIpDst(rspFirstHop.getIp().getIpv4Address()).setVxlanUdpPort(rspFirstHop.getPort()); } String context = renderedServicePath.getContextMetadata(); if (context == null) { LOG.error("getSfcNshHeader: context is null\n"); } ContextMetadata md = SfcProviderServiceFunctionMetadataAPI.readContextMetadata(context); if (md == null) { LOG.error("getSfcNshHeader: metadata is null\n"); } else { sfcNshHeader.setNshMetaC1(md.getContextHeader1()).setNshMetaC2(md.getContextHeader2()) .setNshMetaC3(md.getContextHeader3()).setNshMetaC4(md.getContextHeader4()); } return sfcNshHeader; }
From source file:com.mycelium.wallet.activity.HdAccountSelectorActivity.java
protected void updateUi() { if (masterseedScanManager.currentAccountState == AccountScanManager.AccountStatus.scanning) { findViewById(R.id.llStatus).setVisibility(View.VISIBLE); if (accounts.size() > 0) { txtStatus.setText(//ww w. ja v a 2 s . co m String.format(getString(R.string.account_found), Iterables.getLast(accounts).name)); findViewById(R.id.llSelectAccount).setVisibility(View.VISIBLE); } } else if (masterseedScanManager.currentAccountState == AccountScanManager.AccountStatus.done) { // DONE findViewById(R.id.llStatus).setVisibility(View.GONE); findViewById(R.id.llSelectAccount).setVisibility(View.VISIBLE); if (accounts.size() == 0) { // no accounts found findViewById(R.id.tvNoAccounts).setVisibility(View.VISIBLE); findViewById(R.id.lvAccounts).setVisibility(View.GONE); } else { findViewById(R.id.tvNoAccounts).setVisibility(View.GONE); findViewById(R.id.lvAccounts).setVisibility(View.VISIBLE); } } accountsAdapter.notifyDataSetChanged(); }
From source file:ch.vorburger.minecraft.command.AnnotatedCommandManager.java
protected List<MethodArg> getMethodArgs(Method method) { // TODO rewrite this in nice Java 8 functional "mapping" style Parameter[] parameters = method.getParameters(); List<MethodArg> args = new ArrayList<>(parameters.length); for (Parameter parameter : parameters) { if (!parameter.isNamePresent()) // https://docs.oracle.com/javase/tutorial/reflect/member/methodparameterreflection.html throw new IllegalStateException( "Needs javac -parameters; or, in Eclipse: 'Store information about method parameters (usable via reflection)' in Window -> Preferences -> Java -> Compiler"); MethodArg arg = new MethodArg(); args.add(arg);// w w w . ja v a 2 s .co m String name = parameter.getName(); arg.name = name; Type type = parameter.getParameterizedType(); if (type instanceof ParameterizedType) { ParameterizedType parameterizedType = (ParameterizedType) type; Type[] actualTypes = parameterizedType.getActualTypeArguments(); Type rawType = parameterizedType.getRawType(); if (Optional.class.isAssignableFrom((Class<?>) rawType)) { arg.optional = true; arg.type = actualTypes[0]; } } if (arg.type == null) { arg.type = type; } } if (method.isVarArgs()) { Iterables.getLast(args).vararg = true; } return args; }
From source file:gov.nih.nci.firebird.test.data.SuperUserBuilder.java
protected SuperUserBuilder(TargetGridResources gridResources, TestDataLoader dataLoader, Iterator<? extends LoginAccount> loginIterator) { super(gridResources, dataLoader, loginIterator); profile.setPerson(getUser().getPerson()); profile.setPrimaryOrganization(/*www. ja v a2 s. co m*/ new PrimaryOrganization(getNesOrganization(), PrimaryOrganizationType.HEALTH_CARE_FACILITY)); getUser().createInvestigatorRole(profile); Set<Organization> sponsors = getSponsorsWithProtocolRegistrationsOrganization(); getUser().addSponsorRepresentativeRole(Iterables.getFirst(sponsors, null)); getUser().addSponsorDelegateRole(Iterables.getLast(sponsors)); }