List of usage examples for com.google.common.base Predicates instanceOf
@GwtIncompatible("Class.isInstance") public static Predicate<Object> instanceOf(Class<?> clazz)
From source file:org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveStatementBase.java
protected final <T> T firstSubstatementOfType(final Class<T> type) { final Optional<? extends EffectiveStatement<?, ?>> possible = Iterables.tryFind(substatements, Predicates.instanceOf(type)); return possible.isPresent() ? type.cast(possible.get()) : null; }
From source file:org.onos.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveStatementBase.java
@SuppressWarnings("unchecked") protected final <S extends SchemaNode> Collection<? extends S> allSchemaNodes(Class<S> type) { Collection<? extends S> result = null; try {/*from www.ja va 2 s . c om*/ result = Collection.class.cast(Collections2.filter(substatements, Predicates.instanceOf(type))); } catch (NoSuchElementException e) { result = Collections.emptyList(); } return result; }
From source file:com.eucalyptus.auth.euare.identity.ws.IdentityClientPipeline.java
private static TrustManager buildDelegatingTrustManager(final List<TrustManager> trustManagers, final Supplier<Boolean> enable) { return new DelegatingX509ExtendedTrustManager(Iterables.transform( Iterables.filter(trustManagers, Predicates.instanceOf(javax.net.ssl.X509ExtendedTrustManager.class)), CollectionUtils.cast(javax.net.ssl.X509ExtendedTrustManager.class)), enable); }
From source file:org.eclipse.sirius.diagram.sequence.ui.tool.internal.edit.validator.AbstractInteractionFrameValidator.java
/** * Constructor.// w w w .j a v a 2 s.c o m * * @param frame * the interaction use or combined fragment which will be * resized. * @param requestQuery * a query on the request targeting the execution. */ public AbstractInteractionFrameValidator(AbstractFrame frame, RequestQuery requestQuery) { this.frame = frame; this.requestQuery = requestQuery; this.valid = false; this.invalidParents = Predicates.or(Predicates.instanceOf(AbstractFrame.class), Predicates.instanceOf(State.class)); }
From source file:org.jclouds.abiquo.compute.functions.VirtualMachineToNodeMetadata.java
@Override public NodeMetadata apply(final VirtualMachine vm) { NodeMetadataBuilder builder = new NodeMetadataBuilder(); builder.ids(vm.getId().toString());// ww w . ja v a2 s. c o m builder.uri(vm.getURI()); builder.name(vm.getNameLabel()); builder.group(vm.getVirtualAppliance().getName()); // TODO: Node credentials still not present in Abiquo template metadata // Will be added in Abiquo 2.4: // http://jira.abiquo.com/browse/ABICLOUDPREMIUM-3647 // Location details VirtualDatacenter vdc = vm.getVirtualDatacenter(); builder.location(virtualDatacenterToLocation.apply(vdc)); // Image details VirtualMachineTemplate template = vm.getTemplate(); Image image = virtualMachineTemplateToImage.apply(template); builder.imageId(image.getId().toString()); builder.operatingSystem(image.getOperatingSystem()); // Hardware details Hardware defaultHardware = virtualMachineTemplateToHardware .apply(new VirtualMachineTemplateInVirtualDatacenter(template, vdc)); Hardware hardware = HardwareBuilder.fromHardware(defaultHardware).ram(vm.getRam()) .processors(Lists.newArrayList(new Processor(vm.getCpu(), VirtualMachineTemplateInVirtualDatacenterToHardware.DEFAULT_CORE_SPEED))) // .build(); builder.hardware(hardware); // Networking configuration Iterable<Ip<?, ?>> nics = vm.listAttachedNics(); builder.privateAddresses(ips(filter(nics, Predicates.instanceOf(PrivateIp.class)))); builder.publicAddresses(ips(filter(nics, Predicates.not(Predicates.instanceOf(PrivateIp.class))))); // Node state VirtualMachineState state = vm.getState(); builder.status(virtualMachineStateToNodeState.apply(state)); builder.backendStatus(state.name()); return builder.build(); }
From source file:org.apache.brooklyn.util.core.task.ValueResolverIterator.java
/** * @return the first resolved value instance of {@code type}. * If none is found return the last element. */// ww w.j a v a 2 s.c o m public Maybe<Object> nextOrLast(Class<?> type) { return nextOrLast(Predicates.instanceOf(type)); }
From source file:com.vmware.appfactory.notification.controller.NotificationApiController.java
/** * Get a consolidated status of all conversison's progress and a list of * alert actions./*from w ww . j a va 2 s . c o m*/ * * @return */ @RequestMapping(value = "/notify/alertAndProgress", method = RequestMethod.GET) public @ResponseBody CaptureTaskSummary getCaptureAndAlertSummary() { long progressTotal = 0; int taskCount = 0; Iterable<TaskState> taskList = _conversionsQueue.getTasks(MetaStatusPredicate.NOT_FINISHED); Iterable<TaskState> captureStates = Iterables.filter(taskList, Predicates.instanceOf(AbstractCaptureState.class)); for (TaskState state : captureStates) { progressTotal += state.getProgress(); taskCount++; } Iterable<TaskState> runningTasks = Iterables.filter(taskList, Predicates.and(MetaStatusPredicate.RUNNING, Predicates.instanceOf(AbstractCaptureState.class))); // Compute the average progress if (taskCount != 0) { progressTotal /= taskCount; } // Create the dto and set the computed values and queued up capture tasks CaptureTaskSummary summary = new CaptureTaskSummary(Iterables.size(runningTasks), (int) progressTotal, getWaitingCaptureTaskCount()); // Set the number of failed and wait-on-user alerts. List<ActionAlert> aaList = getWorkpoolAndImageFailedAlerts(); aaList.addAll(getUserWaitAndFailedAlerts()); aaList.addAll(getFeedFailedAlerts()); aaList.addAll(getLowDiskSpaceAlerts()); // Add the list of action alerts with the latest alert event appearing on top. Collections.sort(aaList); summary.setActionList(aaList); // Return the summary info for display. return summary; }
From source file:edu.harvard.med.screensaver.ui.attachedFiles.AttachedFileSearchResults.java
@Override protected List<? extends TableColumn<Tuple<Integer>, ?>> buildColumns() { List<TableColumn<Tuple<Integer>, ?>> columns = Lists.newArrayList(); if (_attachedFileTypesFilter == null || Iterables.any(_attachedFileTypesFilter, Predicates.instanceOf(UserAttachedFileType.class))) { columns.add(//from www . j a v a 2 s. co m new IntegerTupleColumn<AttachedFile, Integer>( RelationshipPath.from(AttachedFile.class).to(AttachedFile.screeningRoomUser) .toProperty("id"), "Screener ID", "The identifier of the screener to which the file is attached", TableColumn.UNGROUPED) { @Override public Object cellAction(Tuple<Integer> t) { return _userViewer.viewEntity(getAttachedFile(t).getScreeningRoomUser()); } @Override public boolean isCommandLink() { return true; } }); columns.add(new TextTupleColumn<AttachedFile, Integer>( RelationshipPath.from(AttachedFile.class).to(AttachedFile.screeningRoomUser) .toProperty("lastName"), "User Last Name", "The last name of the user to which the file is attached", TableColumn.UNGROUPED)); columns.add(new TextTupleColumn<AttachedFile, Integer>( RelationshipPath.from(AttachedFile.class).to(AttachedFile.screeningRoomUser) .toProperty("firstName"), "User First Name", "The first name of the user to which the file is attached", TableColumn.UNGROUPED)); final PropertyPath<AttachedFile> labHeadLabAffiliationPropertyPath = RelationshipPath .from(AttachedFile.class).to(AttachedFile.screeningRoomUser).to(ScreeningRoomUser.LabHead) .to(LabHead.labAffiliation).toProperty("affiliationName"); columns.add(new TextTupleColumn<AttachedFile, Integer>( RelationshipPath.from(AttachedFile.class).to(AttachedFile.screeningRoomUser) .to(LabHead.labAffiliation).toProperty("affiliationName"), "User Lab Affiliation", "The lab affiliation of the user to which the file is attached", TableColumn.UNGROUPED) { @Override public String getCellValue(Tuple<Integer> tuple) { String cellValue = super.getCellValue(tuple); if (cellValue == null) { cellValue = (String) tuple .getProperty(TupleDataFetcher.makePropertyKey(labHeadLabAffiliationPropertyPath)); } return cellValue; } }); ((TextTupleColumn) Iterables.getLast(columns)).addRelationshipPath(labHeadLabAffiliationPropertyPath); } if (_attachedFileTypesFilter == null || Iterables.any(_attachedFileTypesFilter, Predicates.instanceOf(ScreenAttachedFileType.class))) { columns.add(new TextTupleColumn<AttachedFile, Integer>(AttachedFile.screen.toProperty("facilityId"), "Screen", "The screen to which the file is attached", TableColumn.UNGROUPED) { @Override public Object cellAction(Tuple<Integer> t) { return _screenViewer.viewEntity(getAttachedFile(t).getScreen()); } @Override public boolean isCommandLink() { return true; } }); } if (_attachedFileTypesFilter == null || _attachedFileTypesFilter.size() > 1) { columns.add(new VocabularyTupleColumn<AttachedFile, Integer, AttachedFileType>( RelationshipPath.from(AttachedFile.class).toProperty("fileType"), "Type", "The type of the attached file", TableColumn.UNGROUPED, new VocabularyConverter<AttachedFileType>(_allAttachedFileTypes), _allAttachedFileTypes)); } columns.add(new TextTupleColumn<AttachedFile, Integer>( RelationshipPath.from(AttachedFile.class).toProperty("filename"), "File Name", "The name of the attached file", TableColumn.UNGROUPED) { @Override public Object cellAction(Tuple<Integer> t) { try { return AttachedFiles.doDownloadAttachedFile(getAttachedFile(t), getFacesContext(), _dao); } catch (Exception e) { throw new RuntimeException(e); } } @Override public boolean isCommandLink() { return true; } }); columns.add(new DateTupleColumn<AttachedFile, Integer>( RelationshipPath.from(AttachedFile.class).toProperty("fileDate"), "File Date", "The date of the attached file", TableColumn.UNGROUPED)); return columns; }
From source file:org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveStatementBase.java
protected final <R> R firstSubstatementOfType(final Class<?> type, final Class<R> returnType) { final Optional<? extends EffectiveStatement<?, ?>> possible = Iterables.tryFind(substatements, Predicates.and(Predicates.instanceOf(type), Predicates.instanceOf(returnType))); return possible.isPresent() ? returnType.cast(possible.get()) : null; }
From source file:brooklyn.networking.vclouddirector.PortForwarderVcloudDirector.java
@Override public void inject(Entity owner, List<Location> locations) { subnetTier = (SubnetTier) owner;/*from www. ja va 2s . c o m*/ jcloudsLocation = (JcloudsLocation) Iterables.find(locations, Predicates.instanceOf(JcloudsLocation.class)); getClient(); // force load of client: fail fast if configuration is missing getPortRange(); getNatMicroserviceAutoAllocatesPorts(); }