List of usage examples for com.google.common.base Predicates and
public static <T> Predicate<T> and(Predicate<? super T> first, Predicate<? super T> second)
From source file:org.jetbrains.k2js.analyze.AnalyzerFacadeForJS.java
@NotNull public static AnalyzeExhaust analyzeBodiesInFiles(@NotNull Predicate<PsiFile> filesToAnalyzeCompletely, @NotNull Config config, @NotNull BindingTrace traceContext, @NotNull BodiesResolveContext bodiesResolveContext, @NotNull ModuleConfiguration configuration) { Predicate<PsiFile> completely = Predicates.and(notLibFiles(config.getLibFiles()), filesToAnalyzeCompletely); return AnalyzerFacadeForEverything.analyzeBodiesInFilesWithJavaIntegration(config.getProject(), Collections.<AnalyzerScriptParameter>emptyList(), completely, traceContext, bodiesResolveContext, configuration);//from w w w . j a v a2 s .com }
From source file:com.flowlogix.security.cdi.ShiroSessionScopeContext.java
public <T> void onDestroy(Session session) { List<String> attrNames = FluentIterable.from(session.getAttributeKeys()) .transform(new Function<Object, String>() { @Override// www. j ava 2s . c o m public String apply(Object f) { return f instanceof String ? (String) f : null; } }).filter(Predicates.and(Predicates.notNull(), Predicates.contains(bpPattern))).toList(); for (String attrName : attrNames) { @SuppressWarnings("unchecked") ScopeInst<T> scopeInst = (ScopeInst<T>) session.getAttribute(attrName); if (scopeInst != null) { scopeInst.bean.destroy(scopeInst.instance, scopeInst.context); } } }
From source file:eu.esdihumboldt.hale.ui.io.source.URLSourceURIFieldEditor.java
/** * Set the allowed content types and enable the history button if * applicable.// w w w . j ava 2 s. c o m * * @param types the supported content types */ public void setContentTypes(Set<IContentType> types) { RecentResources rr = PlatformUI.getWorkbench().getService(RecentResources.class); if (rr != null) { Predicate<URI> selectUris = new Predicate<URI>() { @Override public boolean apply(URI uri) { // exclude files return !"file".equals(uri.getScheme()); } }; if (filter != null) { selectUris = Predicates.and(selectUris, filter); } final List<Pair<URI, IContentType>> locations = rr.getRecent(types, selectUris); if (!locations.isEmpty()) { historyButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Menu filesMenu = new Menu(historyButton); for (Pair<URI, IContentType> pair : locations) { final URI location = pair.getFirst(); final IContentType contentType = pair.getSecond(); try { MenuItem item = new MenuItem(filesMenu, SWT.PUSH); item.setText(RecentProjectsMenu.shorten(location.toString(), 80, 20)); item.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { getTextControl().setText(location.toString()); getTextControl().setFocus(); valueChanged(); onHistorySelected(location, contentType); } }); } catch (Exception e1) { // ignore } } Point histLoc = historyButton.getParent().toDisplay(historyButton.getLocation()); filesMenu.setLocation(histLoc.x, histLoc.y + historyButton.getSize().y); filesMenu.setVisible(true); } }); historyButton.setEnabled(true); } } }
From source file:org.apache.brooklyn.entity.nosql.couchbase.CouchbaseSyncGatewaySshDriver.java
@Override public void launch() { Entity cbNode = entity.getConfig(CouchbaseSyncGateway.COUCHBASE_SERVER); Entities.waitForServiceUp(cbNode, Duration.ONE_HOUR); DependentConfiguration.waitInTaskForAttributeReady(cbNode, CouchbaseCluster.IS_CLUSTER_INITIALIZED, Predicates.equalTo(true));/*from ww w . java 2 s. c o m*/ // Even once the bucket has published its API URL, it can still take a couple of seconds for it to become available Time.sleep(10 * 1000); if (cbNode instanceof CouchbaseCluster) { // in_cluster now applies even to a node in a cluster of size 1 Optional<Entity> cbClusterNode = Iterables.tryFind(cbNode.getAttribute(CouchbaseCluster.GROUP_MEMBERS), Predicates.and(Predicates.instanceOf(CouchbaseNode.class), EntityPredicates.attributeEqualTo(CouchbaseNode.IS_IN_CLUSTER, Boolean.TRUE))); if (!cbClusterNode.isPresent()) { throw new IllegalArgumentException( format("The cluster %s does not contain any suitable Couchbase nodes to connect to..", cbNode.getId())); } cbNode = cbClusterNode.get(); } String hostname = cbNode.getAttribute(CouchbaseNode.HOSTNAME); String webPort = cbNode.getAttribute(CouchbaseNode.COUCHBASE_WEB_ADMIN_PORT).toString(); String username = cbNode.getConfig(CouchbaseNode.COUCHBASE_ADMIN_USERNAME); String password = cbNode.getConfig(CouchbaseNode.COUCHBASE_ADMIN_PASSWORD); String bucketName = entity.getConfig(CouchbaseSyncGateway.COUCHBASE_SERVER_BUCKET); String pool = entity.getConfig(CouchbaseSyncGateway.COUCHBASE_SERVER_POOL); String pretty = entity.getConfig(CouchbaseSyncGateway.PRETTY) ? "-pretty" : ""; String verbose = entity.getConfig(CouchbaseSyncGateway.VERBOSE) ? "-verbose" : ""; String adminRestApiPort = entity.getConfig(CouchbaseSyncGateway.ADMIN_REST_API_PORT).iterator().next() .toString(); String syncRestApiPort = entity.getConfig(CouchbaseSyncGateway.SYNC_REST_API_PORT).iterator().next() .toString(); String serverWebAdminUrl = format("http://%s:%s@%s:%s", username, password, hostname, webPort); String options = format( "-url %s -bucket %s -adminInterface 0.0.0.0:%s -interface 0.0.0.0:%s -pool %s %s %s", serverWebAdminUrl, bucketName, adminRestApiPort, syncRestApiPort, pool, pretty, verbose); newScript(ImmutableMap.of("usePidFile", true), LAUNCHING).body .append(format("/opt/couchbase-sync-gateway/bin/sync_gateway %s ", options) + "> out.log 2> err.log < /dev/null &") .failOnNonZeroResultCode().execute(); }
From source file:com.google.security.zynamics.binnavi.Gui.GraphWindows.types.PointerTypePanel.java
private void createControls() { setLayout(new BorderLayout()); final JPanel contentPanel = new JPanel(); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); add(contentPanel, BorderLayout.CENTER); final GridBagLayout gbl_m_contentPanel = new GridBagLayout(); gbl_m_contentPanel.columnWidths = new int[] { 0, 0, 0 }; gbl_m_contentPanel.rowHeights = new int[] { 0, 0, 0, 0, 0 }; gbl_m_contentPanel.columnWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE }; gbl_m_contentPanel.rowWeights = new double[] { 0.0, 0.0, 1.0, 0.0, Double.MIN_VALUE }; contentPanel.setLayout(gbl_m_contentPanel); final JLabel lblBaseType = new JLabel("Base type:"); final GridBagConstraints gbc_lblBaseType = new GridBagConstraints(); gbc_lblBaseType.anchor = GridBagConstraints.WEST; gbc_lblBaseType.insets = new Insets(0, 0, 5, 5); gbc_lblBaseType.gridx = 0;/*from w w w. j a v a 2s . com*/ gbc_lblBaseType.gridy = 0; contentPanel.add(lblBaseType, gbc_lblBaseType); baseTypes = new TypeComboBox(new TypeListModel(typeManager.getTypes(), Predicates.and(new TypeListModel.ArrayTypesFilter(), new TypeListModel.PrototypesFilter()))); baseTypes.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { updatePreview(); } }); final GridBagConstraints gbc_baseTypes = new GridBagConstraints(); gbc_baseTypes.insets = new Insets(0, 0, 5, 0); gbc_baseTypes.fill = GridBagConstraints.HORIZONTAL; gbc_baseTypes.gridx = 1; gbc_baseTypes.gridy = 0; contentPanel.add(baseTypes, gbc_baseTypes); final JLabel lblNewLabel_1 = new JLabel("Pointer level:"); final GridBagConstraints gbc_lblNewLabel_1 = new GridBagConstraints(); gbc_lblNewLabel_1.anchor = GridBagConstraints.EAST; gbc_lblNewLabel_1.insets = new Insets(0, 0, 5, 5); gbc_lblNewLabel_1.gridx = 0; gbc_lblNewLabel_1.gridy = 1; contentPanel.add(lblNewLabel_1, gbc_lblNewLabel_1); pointerLevel = new JSpinner(new SpinnerNumberModel(1, 1, 10, 1)); pointerLevel.addChangeListener(new ChangeListener() { @Override public void stateChanged(final ChangeEvent e) { updatePreview(); } }); final GridBagConstraints gbc_m_pointerLevel = new GridBagConstraints(); gbc_m_pointerLevel.anchor = GridBagConstraints.WEST; gbc_m_pointerLevel.insets = new Insets(0, 0, 5, 0); gbc_m_pointerLevel.gridx = 1; gbc_m_pointerLevel.gridy = 1; contentPanel.add(pointerLevel, gbc_m_pointerLevel); final JLabel lblPreview = new JLabel("Preview:"); final GridBagConstraints gbc_lblPreview = new GridBagConstraints(); gbc_lblPreview.insets = new Insets(0, 0, 5, 5); gbc_lblPreview.gridx = 0; gbc_lblPreview.gridy = 2; contentPanel.add(lblPreview, gbc_lblPreview); preview = new JTextArea(); preview.setEditable(false); final GridBagConstraints gbc_preview = new GridBagConstraints(); gbc_preview.insets = new Insets(0, 0, 5, 0); gbc_preview.fill = GridBagConstraints.BOTH; gbc_preview.gridx = 1; gbc_preview.gridy = 2; contentPanel.add(preview, gbc_preview); }
From source file:org.apache.brooklyn.core.location.dynamic.clocker.StubInfrastructureImpl.java
@Override public void init() { super.init(); ConfigToAttributes.apply(this); EntitySpec<?> dockerHostSpec = EntitySpec.create(StubHost.class) .configure(StubHost.DOCKER_INFRASTRUCTURE, this).configure(SoftwareProcess.CHILDREN_STARTABLE_MODE, SoftwareProcess.ChildStartableMode.BACKGROUND_LATE); DynamicCluster hosts = addChild(EntitySpec.create(DynamicCluster.class) .configure(Cluster.INITIAL_SIZE, config().get(DOCKER_HOST_CLUSTER_MIN_SIZE)) .configure(DynamicCluster.QUARANTINE_FAILED_ENTITIES, true) .configure(DynamicCluster.MEMBER_SPEC, dockerHostSpec) .configure(DynamicCluster.RUNNING_QUORUM_CHECK, QuorumChecks.atLeastOneUnlessEmpty()) .configure(DynamicCluster.UP_QUORUM_CHECK, QuorumChecks.atLeastOneUnlessEmpty()) .displayName("Docker Hosts")); DynamicGroup fabric = addChild(EntitySpec.create(DynamicGroup.class) .configure(DynamicGroup.ENTITY_FILTER, Predicates.and(Predicates.instanceOf(StubContainer.class), EntityPredicates.attributeEqualTo(StubContainer.DOCKER_INFRASTRUCTURE, this))) .configure(DynamicGroup.MEMBER_DELEGATE_CHILDREN, true).displayName("All Docker Containers")); DynamicMultiGroup buckets = addChild(EntitySpec.create(DynamicMultiGroup.class) .configure(DynamicMultiGroup.ENTITY_FILTER, StubUtils.sameInfrastructure(this)) .configure(DynamicMultiGroup.RESCAN_INTERVAL, 15L) .configure(DynamicMultiGroup.BUCKET_FUNCTION, new Function<Entity, String>() { @Override// w w w. jav a 2 s .c om public String apply(@Nullable Entity input) { return input.getApplication().getDisplayName() + ":" + input.getApplicationId(); } }) .configure(DynamicMultiGroup.BUCKET_SPEC, EntitySpec.create(BasicGroup.class).configure(BasicGroup.MEMBER_DELEGATE_CHILDREN, true)) .displayName("Docker Applications")); sensors().set(DOCKER_HOST_CLUSTER, hosts); sensors().set(DOCKER_CONTAINER_FABRIC, fabric); sensors().set(DOCKER_APPLICATIONS, buckets); }
From source file:io.crate.metadata.doc.DocSchemaInfo.java
private static Predicate<String> createSchemaNamePredicate(final String schemaName) { return Predicates.and(Predicates.notNull(), new Predicate<String>() { @Override//from w ww . j a v a2s. com public boolean apply(String input) { Matcher matcher = Schemas.SCHEMA_PATTERN.matcher(input); if (matcher.matches()) { return matcher.group(1).equals(schemaName); } else { return Schemas.DEFAULT_SCHEMA_NAME.equals(schemaName); } } }); }
From source file:com.eucalyptus.cloud.CloudMetadatas.java
public static <T extends CloudMetadata> Predicate<T> filterPrivilegesByOwningAccount( final Collection<String> requestedIdentifiers) { return Predicates.and(filterByOwningAccount(requestedIdentifiers), RestrictedTypes.filterPrivileged()); }
From source file:forge.game.GameFormat.java
private Predicate<PaperCard> buildFilterPrinted() { final Predicate<PaperCard> banNames = Predicates.not(IPaperCard.Predicates.names(this.bannedCardNames_ro)); if (this.allowedSetCodes_ro.isEmpty()) { return banNames; }/* w w w.java 2 s . c o m*/ return Predicates.and(banNames, IPaperCard.Predicates.printedInSets(this.allowedSetCodes_ro, true)); }
From source file:com.eucalyptus.tags.Filter.java
/** * Combine filters.//from w w w. ja va 2s. co m * * @param filter The filter to combine with * @return The new filter */ public Filter and(final Filter filter) { final Map<String, String> aliases = Maps.newHashMap(); aliases.putAll(this.aliases); aliases.putAll(filter.aliases); final Junction and = Restrictions.conjunction(); and.add(this.criterion); and.add(filter.criterion); return new Filter(aliases, and, Predicates.and(this.predicate, filter.predicate), this.filteringOnTags || filter.filteringOnTags); }