List of usage examples for com.google.common.collect Iterables get
public static <T> T get(Iterable<T> iterable, int position)
From source file:org.eclipse.sirius.diagram.ui.tools.internal.actions.repair.AbstractDiagramElementState.java
/** * {@inheritDoc}/* w w w .java2 s. com*/ */ @Override public void storeElementState(EObject target, DiagramElementMapping mapping, D element) { customizableToCustomizedFeatures.clear(); isVisible = element.isVisible(); // handle isHidden DDiagramElementQuery dDiagramElementQuery = new DDiagramElementQuery(element); isHidden = dDiagramElementQuery.isHidden(); isLabelHidden = dDiagramElementQuery.isLabelHidden(); storeFold(element); // Will now cross reference to find the GMF nodes referencing this // element. final Iterator<Map.Entry<EObject, Collection<Setting>>> referencesIterator = crossReferencer.entrySet() .iterator(); while (referencesIterator.hasNext()) { final Map.Entry<EObject, Collection<Setting>> reference = referencesIterator.next(); if (reference.getKey().equals(element)) { final List<Setting> valueList = (List<Setting>) reference.getValue(); for (int i = 0; i < valueList.size(); i++) { final EStructuralFeature.Setting nextNodeSetting = valueList.get(i); // Can only be Node or Edge. ClassCastExceptions here // indicates a change in DiagramCrossReferencer if (nextNodeSetting.getEObject() instanceof Node) { nodes.add((Node) nextNodeSetting.getEObject()); } else { edges.add((Edge) nextNodeSetting.getEObject()); } } } } final Style ownedStyle = element.getStyle(); if (ownedStyle != null) { storeStyleCustomizations(ownedStyle); } Iterable<AbsoluteBoundsFilter> flags = Iterables.filter(element.getGraphicalFilters(), AbsoluteBoundsFilter.class); if (!Iterables.isEmpty(flags)) { Iterables.addAll(boundsFilters, flags); } // If DDiagramElement is bordered node and is collapsed, the stored size // should be the expanded one. The size will be collapsed by the refresh // after restore. Predicate<Object> predicate = new Predicate<Object>() { @Override public boolean apply(Object input) { if (input instanceof CollapseFilter) { if (((CollapseFilter) input).eIsSet(DiagramPackage.eINSTANCE.getCollapseFilter_Height()) && ((CollapseFilter) input) .eIsSet(DiagramPackage.eINSTANCE.getCollapseFilter_Width())) { return true; } } return false; } }; // if the node is collapsed, we save its expanded bounds. Iterable<GraphicalFilter> elementCollapseFilters = Iterables.filter(element.getGraphicalFilters(), predicate); if (!Iterables.isEmpty(elementCollapseFilters)) { GraphicalFilter graphicalFilter = Iterables.get(elementCollapseFilters, 0); if (graphicalFilter instanceof CollapseFilter) { expandedDimension = new Dimension(((CollapseFilter) graphicalFilter).getWidth(), ((CollapseFilter) graphicalFilter).getHeight()); } } }
From source file:org.obeonetwork.m2doc.generator.TableClientProcessor.java
/** * Fill a newly created word table with the data from an MTable. * //from ww w. ja v a2s .c om * @param table * The newly created word table * @param mtable * The MTable that describes the data and styles to insert */ private void fillTable(XWPFTable table, MTable mtable) { XWPFTableRow headerRow = table.getRow(0); initializeEmptyTableCell(headerRow.getCell(0), null, null); Iterable<? extends MColumn> mcolumns = mtable.getColumns(); for (MColumn mcol : mcolumns) { XWPFTableCell cell; cell = headerRow.addNewTableCell(); initializeEmptyTableCell(cell, null, null); setCellContent(cell, mcol.getLabel(), null); } for (MRow mrow : mtable.getRows()) { XWPFTableRow row = table.createRow(); List<XWPFTableCell> cells = row.getTableCells(); for (int i = 0; i < cells.size(); i++) { XWPFTableCell cell = cells.get(i); // Make sure empty cells are empty and have the right style if (i > 0) { initializeEmptyTableCell(cell, mrow, Iterables.get(mtable.getColumns(), i - 1)); } else { initializeEmptyTableCell(cell, null, null); } } XWPFTableCell cell0 = row.getCell(0); setCellContent(cell0, mrow.getLabel(), null); for (MCell mcell : mrow.getCells()) { MColumn mcol = mcell.getColumn(); if (mcol != null) { XWPFTableCell cell = row.getCell(Iterables.indexOf(mcolumns, Predicates.equalTo(mcol)) + 1); setCellContent(cell, mcell.getLabel(), mcell.getStyle()); } } } }
From source file:org.jclouds.vcloud.director.v1_5.compute.strategy.VCloudDirectorComputeServiceAdapter.java
@Override public NodeAndInitialCredentials<Vm> createNodeWithGroupEncodedIntoName(String group, String name, Template template) {/*from w ww. j ava 2 s . c o m*/ checkNotNull(template, "template was null"); checkNotNull(template.getOptions(), "template options was null"); String imageId = checkNotNull(template.getImage().getId(), "template image id must not be null"); String locationId = checkNotNull(template.getLocation().getId(), "template location id must not be null"); final String hardwareId = checkNotNull(template.getHardware().getId(), "template image id must not be null"); VCloudDirectorTemplateOptions templateOptions = VCloudDirectorTemplateOptions.class .cast(template.getOptions()); Vdc vdc = getVdc(locationId); final Reference networkReference; if (template.getOptions().getNetworks().isEmpty()) { Org org = getOrgForSession(); Network.FenceMode fenceMode = Network.FenceMode.NAT_ROUTED; Optional<Network> optionalNetwork = tryFindNetworkInVDCWithFenceMode(api, vdc, fenceMode); if (!optionalNetwork.isPresent()) { throw new IllegalStateException( "Can't find a network with fence mode: " + fenceMode + "in org " + org.getFullName()); } networkReference = Reference.builder().href(optionalNetwork.get().getHref()) .name(optionalNetwork.get().getName()).build(); } else { String networkName = Iterables.getOnlyElement(template.getOptions().getNetworks()); networkReference = tryFindNetworkInVDC(vdc, networkName); } VAppTemplate vAppTemplate = api.getVAppTemplateApi().get(imageId); Set<Vm> vms = getAvailableVMsFromVAppTemplate(vAppTemplate); // TODO now get the first vm to be added to vApp, what if more? Vm toAddVm = Iterables.get(vms, 0); // customize toAddVm GuestCustomizationSection guestCustomizationSection = api.getVmApi() .getGuestCustomizationSection(toAddVm.getHref()); guestCustomizationSection = guestCustomizationSection.toBuilder().resetPasswordRequired(false).build(); Statement guestCustomizationScript = ((VCloudDirectorTemplateOptions) (template.getOptions())) .getGuestCustomizationScript(); if (guestCustomizationScript != null) { guestCustomizationSection = guestCustomizationSection.toBuilder() // TODO differentiate on guestOS .customizationScript(guestCustomizationScript.render(OsFamily.WINDOWS)).build(); } SourcedCompositionItemParam vmItem = createVmItem(toAddVm, networkReference.getName(), guestCustomizationSection); ComposeVAppParams compositionParams = ComposeVAppParams.builder().name(name) .instantiationParams(instantiationParams(vdc, networkReference)) .sourcedItems(ImmutableList.of(vmItem)).build(); VApp vApp = api.getVdcApi().composeVApp(vdc.getId(), compositionParams); Task compositionTask = Iterables.getFirst(vApp.getTasks(), null); logger.debug(">> awaiting vApp(%s) deployment", vApp.getId()); boolean vAppDeployed = waitForTask(compositionTask, timeouts.nodeRunning); logger.trace("<< vApp(%s) deployment completed(%s)", vApp.getId(), vAppDeployed); if (!vAppDeployed) { // TODO Destroy node? But don't have VM id yet. final String message = format("vApp(%s, %s) not composed within %d ms (task %s).", name, vApp.getId(), timeouts.nodeRunning, compositionTask.getHref()); logger.warn(message); throw new IllegalStateException(message); } if (!vApp.getTasks().isEmpty()) { for (Task task : vApp.getTasks()) { logger.debug(">> awaiting vApp(%s) composition", vApp.getId()); boolean vAppReady = waitForTask(task, timeouts.nodeRunning); logger.trace("<< vApp(%s) composition completed(%s)", vApp.getId(), vAppReady); if (!vAppReady) { // TODO Destroy node? But don't have VM id yet. final String message = format("vApp(%s, %s) post-compose not ready within %d ms (task %s).", name, vApp.getId(), timeouts.nodeRunning, task.getHref()); logger.warn(message); throw new IllegalStateException(message); } } } URI vAppHref = checkNotNull(vApp.getHref(), format("vApp %s must not have a null href", vApp.getId())); VApp composedVApp = api.getVAppApi().get(vAppHref); VAppChildren children = checkNotNull(composedVApp.getChildren(), format("composedVApp %s must not have null children", composedVApp.getId())); Vm vm = Iterables.getOnlyElement(children.getVms()); if (!vm.getTasks().isEmpty()) { for (Task task : vm.getTasks()) { logger.debug(">> awaiting vm(%s) deployment", vApp.getId()); boolean vmReady = waitForTask(task, timeouts.nodeRunning); logger.trace("<< vApp(%s) deployment completed(%s)", vApp.getId(), vmReady); if (!vmReady) { final String message = format( "vApp(%s, %s) post-compose VM(%s) not ready within %d ms (task %s), so it will be destroyed", name, vApp.getId(), vm.getHref(), timeouts.nodeRunning, task.getHref()); logger.warn(message); destroyNode(vm.getId()); throw new IllegalStateException(message); } } } // Configure VirtualHardware on a VM Optional<Hardware> hardwareOptional = Iterables.tryFind(listHardwareProfiles(), new Predicate<Hardware>() { @Override public boolean apply(Hardware input) { return input.getId().equals(hardwareId); } }); // virtualCpus and memory templateOptions get the precedence over the default values given by hardwareId Integer virtualCpus = templateOptions.getVirtualCpus() == null ? getCoresFromHardware(hardwareOptional) : templateOptions.getVirtualCpus(); Integer ram = templateOptions.getMemory() == null ? getRamFromHardware(hardwareOptional) : templateOptions.getMemory(); Integer disk = templateOptions.getDisk(); if (virtualCpus == null || ram == null) { String msg; if (hardwareOptional.isPresent()) { msg = format( "vCPUs and RAM stats not available in hardware %s, and not configured in template options", hardwareId); } else { msg = format( "vCPUs and RAM stats not available - no hardware matching id %s, and not configured in template options; destroying VM", hardwareId); } logger.error(msg + "; destroying VM and failing"); destroyNode(vm.getId()); throw new IllegalStateException(msg); } VirtualHardwareSection virtualHardwareSection = api.getVmApi().getVirtualHardwareSection(vm.getHref()); Predicate<ResourceAllocationSettingData> processorPredicate = resourceTypeEquals( ResourceAllocationSettingData.ResourceType.PROCESSOR); virtualHardwareSection = updateVirtualHardwareSection(virtualHardwareSection, processorPredicate, virtualCpus + " virtual CPU(s)", BigInteger.valueOf(virtualCpus.intValue())); Predicate<ResourceAllocationSettingData> memoryPredicate = resourceTypeEquals( ResourceAllocationSettingData.ResourceType.MEMORY); virtualHardwareSection = updateVirtualHardwareSection(virtualHardwareSection, memoryPredicate, ram + " MB of memory", BigInteger.valueOf(ram.intValue())); if (disk != null) { Predicate<ResourceAllocationSettingData> diskPredicate = resourceTypeEquals( ResourceAllocationSettingData.ResourceType.DISK_DRIVE); Predicate<ResourceAllocationSettingData> elementPredicate = elementNameEquals("Hard disk 1"); virtualHardwareSection = updateVirtualHardwareSectionDisk(virtualHardwareSection, Predicates.and(diskPredicate, elementPredicate), BigInteger.valueOf(disk.intValue())); } // NOTE this is not efficient but the vCD API v1.5 don't support editing hardware sections during provisioning Task editVirtualHardwareSectionTask = api.getVmApi().editVirtualHardwareSection(vm.getHref(), virtualHardwareSection); logger.debug(">> awaiting vm(%s) to be edited", vm.getId()); boolean vmEdited = waitForTask(editVirtualHardwareSectionTask, timeouts.nodeRunning); logger.trace("<< vApp(%s) to be edited completed(%s)", vm.getId(), vmEdited); if (!vmEdited) { final String message = format( "vApp(%s, %s) VM(%s) edit not completed within %d ms (task %s); destroying VM", name, vApp.getId(), vm.getHref(), timeouts.nodeRunning, editVirtualHardwareSectionTask.getHref()); logger.warn(message); destroyNode(vm.getId()); throw new IllegalStateException(message); } Task deployTask = api.getVAppApi().deploy(vApp.getHref(), DeployVAppParams.builder().powerOn().build()); logger.debug(">> awaiting vApp(%s) to be powered on", vApp.getId()); boolean vAppPoweredOn = waitForTask(deployTask, timeouts.nodeRunning); logger.trace("<< vApp(%s) to be powered on completed(%s)", vApp.getId(), vAppPoweredOn); if (!vAppPoweredOn) { final String message = format( "vApp(%s, %s) power-on not completed within %d ms (task %s); destroying VM", name, vApp.getId(), timeouts.nodeRunning, deployTask.getHref()); logger.warn(message); destroyNode(vm.getId()); throw new IllegalStateException(message); } // Reload the VM; the act of "deploy" can change things like the password in the guest customization composedVApp = api.getVAppApi().get(vAppHref); children = checkNotNull(composedVApp.getChildren(), format("composedVApp %s must not have null children", composedVApp.getId())); vm = Iterables.getOnlyElement(children.getVms()); // Infer the login credentials from the VM, defaulting to "root" user LoginCredentials defaultCredentials = VCloudDirectorComputeUtils.getCredentialsFrom(vm); LoginCredentials.Builder credsBuilder; if (defaultCredentials == null) { credsBuilder = LoginCredentials.builder().user("root"); } else { credsBuilder = defaultCredentials.toBuilder(); if (defaultCredentials.getUser() == null) { credsBuilder.user("root"); } } // If login overrides are supplied in TemplateOptions, always prefer those. String overriddenLoginUser = template.getOptions().getLoginUser(); String overriddenLoginPassword = template.getOptions().getLoginPassword(); String overriddenLoginPrivateKey = template.getOptions().getLoginPrivateKey(); if (overriddenLoginUser != null) { credsBuilder.user(overriddenLoginUser); } if (overriddenLoginPassword != null) { credsBuilder.password(overriddenLoginPassword); } if (overriddenLoginPrivateKey != null) { credsBuilder.privateKey(overriddenLoginPrivateKey); } return new NodeAndInitialCredentials<Vm>(vm, vm.getId(), credsBuilder.build()); }
From source file:com.facebook.buck.cxx.CxxSourceRuleFactory.java
/** * @return the preprocessed file name for the given source name. *//*from ww w.ja v a 2s .c om*/ private String getPreprocessOutputName(CxxSource.Type type, String name) { CxxSource.Type outputType = CxxSourceTypes.getPreprocessorOutputType(type); return getOutputName(name) + "." + Iterables.get(outputType.getExtensions(), 0); }
From source file:com.facebook.buck.android.PreDexMerge.java
private void addStepsForSplitDex(ImmutableList.Builder<Step> steps, BuildContext context, BuildableContext buildableContext) { // Collect all of the DexWithClasses objects to use for merging. ImmutableList<DexWithClasses> dexFilesToMerge = FluentIterable.from(preDexDeps) .transform(DexWithClasses.TO_DEX_WITH_CLASSES).filter(Predicates.notNull()).toList(); final SplitDexPaths paths = new SplitDexPaths(); final ImmutableSet<Path> secondaryDexDirectories = ImmutableSet.of(paths.metadataDir, paths.jarfilesDir); // Do not clear existing directory which might contain secondary dex files that are not // re-merged (since their contents did not change). steps.add(new MkdirStep(paths.jarfilesSubdir)); steps.add(new MkdirStep(paths.successDir)); steps.add(new MakeCleanDirectoryStep(paths.metadataSubdir)); steps.add(new MakeCleanDirectoryStep(paths.scratchDir)); buildableContext.addMetadata(SECONDARY_DEX_DIRECTORIES_KEY, Iterables.transform(secondaryDexDirectories, Functions.toStringFunction())); buildableContext.recordArtifact(primaryDexPath); buildableContext.recordArtifactsInDirectory(paths.jarfilesSubdir); buildableContext.recordArtifactsInDirectory(paths.metadataSubdir); buildableContext.recordArtifactsInDirectory(paths.successDir); PreDexedFilesSorter preDexedFilesSorter = new PreDexedFilesSorter(uberRDotJava.getRDotJavaDexWithClasses(), dexFilesToMerge, dexSplitMode.getPrimaryDexPatterns(), paths.scratchDir, dexSplitMode.getLinearAllocHardLimit(), dexSplitMode.getDexStore(), paths.jarfilesSubdir); final PreDexedFilesSorter.Result sortResult = preDexedFilesSorter.sortIntoPrimaryAndSecondaryDexes(context, steps);/*from www .j av a 2 s.c om*/ steps.add(new SmartDexingStep(primaryDexPath, Suppliers.ofInstance(sortResult.primaryDexInputs), Optional.of(paths.jarfilesSubdir), Optional.of(Suppliers.ofInstance(sortResult.secondaryOutputToInputs)), sortResult.dexInputHashesProvider, paths.successDir, /* numThreads */ Optional.<Integer>absent(), AndroidBinary.DX_MERGE_OPTIONS)); // Record the primary dex SHA1 so exopackage apks can use it to compute their ABI keys. // Single dex apks cannot be exopackages, so they will never need ABI keys. steps.add(new RecordFileSha1Step(primaryDexPath, PRIMARY_DEX_HASH_KEY, buildableContext)); steps.add(new AbstractExecutionStep("write_metadata_txt") { @Override public int execute(ExecutionContext executionContext) { ProjectFilesystem filesystem = executionContext.getProjectFilesystem(); Map<Path, DexWithClasses> metadataTxtEntries = sortResult.metadataTxtDexEntries; List<String> lines = Lists.newArrayListWithCapacity(metadataTxtEntries.size()); try { for (Map.Entry<Path, DexWithClasses> entry : metadataTxtEntries.entrySet()) { Path pathToSecondaryDex = entry.getKey(); String containedClass = Iterables.get(entry.getValue().getClassNames(), 0); containedClass = containedClass.replace('/', '.'); String hash = filesystem.computeSha1(pathToSecondaryDex); lines.add( String.format("%s %s %s", pathToSecondaryDex.getFileName(), hash, containedClass)); } filesystem.writeLinesToPath(lines, paths.metadataFile); } catch (IOException e) { executionContext.logError(e, "Failed when writing metadata.txt multi-dex."); return 1; } return 0; } }); }
From source file:com.palantir.atlasdb.sweep.BackgroundSweeper.java
private Optional<String> getTableToSweep(Set<String> unsweptTables, List<SweepPriorityRowResult> results) { if (!unsweptTables.isEmpty()) { return Optional.of(Iterables.get(unsweptTables, 0)); }/*w ww. ja v a2 s .co m*/ double maxPriority = 0.0; String tableName = null; for (SweepPriorityRowResult result : results) { double priority = getSweepPriority(result); if (priority > maxPriority) { maxPriority = priority; tableName = result.getRowName().getFullTableName(); } } return Optional.fromNullable(tableName); }
From source file:com.facebook.buck.android.PreDexMergeStep.java
@Override public int execute(ExecutionContext context) { int primaryDexSize = 0; List<DexWithClasses> primaryDexContents = Lists.newArrayList(); // R.class files should always be in the primary dex. if (dexWithClassesForRDotJava.isPresent()) { primaryDexSize += dexWithClassesForRDotJava.get().getSizeEstimate(); primaryDexContents.add(dexWithClassesForRDotJava.get()); }//from w ww . ja va 2 s.c om // Bucket each DexWithClasses into the appropriate dex file. List<List<DexWithClasses>> secondaryDexesContents = Lists.newArrayList(); List<DexWithClasses> currentSecondaryDexContents = null; int currentSecondaryDexSize = 0; for (DexWithClasses dexWithClasses : dexFilesToMerge) { if (mustBeInPrimaryDex(dexWithClasses)) { // Case 1: Entry must be in the primary dex. primaryDexSize += dexWithClasses.getSizeEstimate(); if (primaryDexSize > linearAllocHardLimit) { context.postEvent(LogEvent.severe( "DexWithClasses %s with cost %s puts the linear alloc estimate for the primary dex " + "at %s, exceeding the maximum of %s.", dexWithClasses.getPathToDexFile(), dexWithClasses.getSizeEstimate(), primaryDexSize, linearAllocHardLimit)); return 1; } primaryDexContents.add(dexWithClasses); } else { // Case 2: Entry must go in a secondary dex. // If the individual DexWithClasses exceeds the limit for a secondary dex, then we have done // something horribly wrong. if (dexWithClasses.getSizeEstimate() > linearAllocHardLimit) { context.postEvent(LogEvent.severe( "DexWithClasses %s with cost %s exceeds the max cost %s for a secondary dex file.", dexWithClasses.getPathToDexFile(), dexWithClasses.getSizeEstimate(), linearAllocHardLimit)); return 1; } // If there is no current secondary dex, or dexWithClasses would put the current secondary // dex over the cost threshold, then create a new secondary dex and initialize it with a // canary. if (currentSecondaryDexContents == null || dexWithClasses.getSizeEstimate() + currentSecondaryDexSize > linearAllocHardLimit) { DexWithClasses canary; try { canary = createCanary(secondaryDexesContents.size() + 1, context); } catch (IOException e) { context.logError(e, "Failed to create canary for secondary dex."); return 1; } currentSecondaryDexContents = Lists.newArrayList(canary); currentSecondaryDexSize = canary.getSizeEstimate(); secondaryDexesContents.add(currentSecondaryDexContents); } // Now add the contributions from the dexWithClasses entry. currentSecondaryDexContents.add(dexWithClasses); currentSecondaryDexSize += dexWithClasses.getSizeEstimate(); } } // Create a list of steps to do the dexing: these will be run in parallel. // There will always be at least one step for the primary classes.dex file. List<Step> dxSteps = Lists.newArrayList(); dxSteps.add(createDxStep(primaryDexPath, primaryDexContents)); // Keep track of where the secondary dex files are written for writing metadata.txt later. String pattern = "secondary-%d" + dexStore.getExtension(); Map<Integer, Path> indexToPathToSecondaryDex = Maps.newHashMap(); // Create the steps do dex the secondary dexes. for (int index = 0; index < secondaryDexesContents.size(); index++) { String name = String.format(pattern, index + 1); Path pathToSecondaryDex = Paths.get(secondaryDexJarFilesDir, name); indexToPathToSecondaryDex.put(index, pathToSecondaryDex); List<DexWithClasses> secondaryDex = secondaryDexesContents.get(index); dxSteps.add(SmartDexingStep.createDxStepForDxPseudoRule(Iterables.transform(secondaryDex, TO_PATH), pathToSecondaryDex.toString(), DX_MERGE_OPTIONS)); } // Run the dexing steps in parallel. StepRunner stepRunner = createStepRunner(context); try { stepRunner.runStepsInParallelAndWait(dxSteps); } catch (StepFailedException e) { context.logError(e, "Failed when dx-merging for multi-dex."); return 1; } finally { stepRunner.getListeningExecutorService().shutdownNow(); } // Generate the metadata.txt file. try { ProjectFilesystem projectFilesystem = context.getProjectFilesystem(); List<String> lines = Lists.newArrayListWithCapacity(secondaryDexesContents.size()); for (int index = 0; index < secondaryDexesContents.size(); index++) { Path pathToSecondaryDex = indexToPathToSecondaryDex.get(index); DexWithClasses dexWithClasses = Iterables.get(secondaryDexesContents.get(index), 0); String containedClass = Iterables.get(dexWithClasses.getClassNames(), 0); containedClass = containedClass.replace('/', '.'); String hash = projectFilesystem.computeSha1(pathToSecondaryDex); lines.add(String.format("%s %s %s", pathToSecondaryDex.getFileName(), hash, containedClass)); } projectFilesystem.writeLinesToPath(lines, secondaryDexMetadataTxt); } catch (IOException e) { context.logError(e, "Failed when writing metadata.txt multi-dex."); return 1; } return 0; }
From source file:org.opendaylight.yangtools.yang.data.impl.codec.SchemaTracker.java
public AugmentationSchema startAugmentationNode(final AugmentationIdentifier identifier) { LOG.debug("Enter augmentation {}", identifier); Object parent = getParent();// w w w .j a v a2 s.c om Preconditions.checkArgument(parent instanceof AugmentationTarget, "Augmentation not allowed under %s", parent); if (parent instanceof ChoiceSchemaNode) { final QName name = Iterables.get(identifier.getPossibleChildNames(), 0); parent = findCaseByChild((ChoiceSchemaNode) parent, name); } Preconditions.checkArgument(parent instanceof DataNodeContainer, "Augmentation allowed only in DataNodeContainer", parent); final AugmentationSchema schema = SchemaUtils.findSchemaForAugment((AugmentationTarget) parent, identifier.getPossibleChildNames()); final HashSet<DataSchemaNode> realChildSchemas = new HashSet<>(); for (final DataSchemaNode child : schema.getChildNodes()) { realChildSchemas.add(((DataNodeContainer) parent).getDataChildByName(child.getQName())); } final AugmentationSchema resolvedSchema = new EffectiveAugmentationSchema(schema, realChildSchemas); schemaStack.push(resolvedSchema); return resolvedSchema; }
From source file:com.vilt.minium.impl.BaseWebElementsImpl.java
@Override public WebElement get(int index) { return Iterables.get(this, index); }
From source file:org.opendaylight.sxp.util.filtering.SxpBindingFilter.java
/** * Creates Sxp filter that merges all specified filters into one filter, * Generated filter pass only if all sub-filters passes. Filter data may be missing due * to merge process.//ww w.ja va 2 s .co m * * @param values Sxp filters logic that will be merged * @return Sxp filters with unified logic */ public static SxpBindingFilter<?, ? extends SxpFilterFields> mergeFilters( final Collection<SxpBindingFilter<?, ? extends SxpFilterFields>> values) { if (values == null || values.isEmpty()) { return null; } if (values.size() == 1) return Iterables.get(values, 0); StringBuilder builder = new StringBuilder().append("MultiGroup[ "); values.stream().map(SxpBindingFilter::getIdentifier).sorted().forEach(g -> builder.append(g).append(" ")); //noinspection unchecked return new SxpBindingFilter(builder.append("]").toString()) { protected boolean filter(FilterEntries filterEntries, SxpBindingFields binding) { for (SxpBindingFilter filter : values) { if (filter.apply(binding)) return true; } return false; } }; }