List of usage examples for com.google.common.base Predicates not
public static <T> Predicate<T> not(Predicate<T> predicate)
From source file:org.caleydo.view.tourguide.internal.compute.AScoreJob.java
protected final static <A, B extends A> Pair<Collection<A>, Collection<B>> partition(Collection<A> in, final Class<B> with) { Collection<B> bs = Lists.newArrayList( Iterables.transform(Iterables.filter(in, Predicates.instanceOf(with)), new Function<A, B>() { @Override//from www. j av a2 s . co m public B apply(A a) { return with.cast(a); } })); Collection<A> as = Collections2.filter(in, Predicates.not(Predicates.instanceOf(with))); return Pair.make(as, bs); }
From source file:org.jclouds.openstack.nova.v1_1.compute.functions.ServerInZoneToNodeMetadata.java
@Override public NodeMetadata apply(ServerInZone serverInZone) { Location zone = locationIndex.get().get(serverInZone.getZone()); checkState(zone != null, "location %s not in locationIndex: %s", serverInZone.getZone(), locationIndex.get());/*from ww w. ja v a2 s . c om*/ Server from = serverInZone.getServer(); NodeMetadataBuilder builder = new NodeMetadataBuilder(); builder.id(serverInZone.slashEncode()); builder.providerId(from.getId()); builder.name(from.getName()); builder.hostname(from.getName()); builder.location(from.getHostId() != null ? new LocationBuilder().scope(LocationScope.HOST).id(from.getHostId()).description(from.getHostId()) .parent(zone).build() : zone); builder.userMetadata(from.getMetadata()); builder.group(nodeNamingConvention.groupInUniqueNameOrNull(from.getName())); builder.imageId(ZoneAndId.fromZoneAndId(serverInZone.getZone(), from.getImage().getId()).slashEncode()); builder.operatingSystem(findOperatingSystemForServerOrNull(serverInZone)); builder.hardware(findHardwareForServerOrNull(serverInZone)); builder.state(from.getStatus().getNodeState()); builder.publicAddresses( filter(transform(filter(from.getAddresses().values(), Predicates.not(isPrivateAddress)), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); builder.privateAddresses(filter(transform(filter(from.getAddresses().values(), isPrivateAddress), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); return builder.build(); }
From source file:com.xebialabs.deployit.ci.JenkinsPackageOptions.java
private List<DeployableView> sortDeployables(List<DeployableView> deployables) { List<DeployableView> result = Lists.newArrayList( Iterables.filter(deployables, Predicates.not(Predicates.instanceOf(EmbeddedView.class)))); List<EmbeddedView> embeddeds = /* double cast: dirty but quick */ (List<EmbeddedView>) (Object) Lists .newArrayList(Iterables.filter(deployables, Predicates.instanceOf(EmbeddedView.class))); // sort the embeddeds on the number of /'s in the parent name Collections.sort(embeddeds, new Comparator<EmbeddedView>() { @Override// ww w. j av a2 s .c o m public int compare(EmbeddedView o1, EmbeddedView o2) { return o1.getParentName().split("/").length - o2.getParentName().split("/").length; } }); result.addAll(embeddeds); return result; }
From source file:org.jetbrains.jet.plugin.references.StandardLibraryReferenceResolver.java
private void ensureInitialized() { synchronized (lock) { if (bindingContext != null) { return; }// w w w . ja v a 2 s.c o m BindingTraceContext context = new BindingTraceContext(); FakeJetNamespaceDescriptor jetNamespace = new FakeJetNamespaceDescriptor(); context.record(BindingContext.FQNAME_TO_NAMESPACE_DESCRIPTOR, KotlinBuiltIns.getInstance().getBuiltInsPackageFqName(), jetNamespace); WritableScopeImpl scope = new WritableScopeImpl(JetScope.EMPTY, jetNamespace, RedeclarationHandler.THROW_EXCEPTION, "Builtin classes scope"); scope.changeLockLevel(WritableScope.LockLevel.BOTH); jetNamespace.setMemberScope(scope); Predicate<JetFile> jetFilesIndependentOfUnit = new Predicate<JetFile>() { @Override public boolean apply(@Nullable JetFile file) { return "Unit.jet".equals(file.getName()); } }; TopDownAnalyzer.processStandardLibraryNamespace(myProject, context, scope, jetNamespace, getJetFiles("jet", jetFilesIndependentOfUnit)); ClassDescriptor tuple0 = context.get(BindingContext.FQNAME_TO_CLASS_DESCRIPTOR, TUPLE0_FQ_NAME); assert tuple0 != null; scope = new WritableScopeImpl(scope, jetNamespace, RedeclarationHandler.THROW_EXCEPTION, "Builtin classes scope: needed to analyze builtins which depend on Unit type alias"); scope.changeLockLevel(WritableScope.LockLevel.BOTH); scope.addClassifierAlias(KotlinBuiltIns.UNIT_ALIAS, tuple0); jetNamespace.setMemberScope(scope); TopDownAnalyzer.processStandardLibraryNamespace(myProject, context, scope, jetNamespace, getJetFiles("jet", Predicates.not(jetFilesIndependentOfUnit))); AnalyzingUtils.throwExceptionOnErrors(context.getBindingContext()); bindingContext = context.getBindingContext(); } }
From source file:com.facebook.buck.swift.SwiftLibraryDescription.java
@Override public boolean hasFlavors(ImmutableSet<Flavor> flavors) { ImmutableSet<Flavor> currentUnsupportedFlavors = ImmutableSet .copyOf(Sets.filter(flavors, Predicates.not(SUPPORTED_FLAVORS::contains))); if (currentUnsupportedFlavors.isEmpty()) { return true; }/* w w w .j a v a 2 s .c om*/ return cxxPlatformFlavorDomain.containsAnyOf(flavors); }
From source file:com.google.cloud.bigtable.dataflowimport.HBaseResultToMutationFn.java
private void processOneColumnFamily(Put put, Collection<Cell> dataCells, Collection<Cell> deleteMarkers) throws IOException { if (deleteMarkers == null) { // No markers for this column family for (Cell cell : dataCells) { put.add(cell);/*w w w . ja v a2 s . co m*/ } return; } else { // Build a filter for live data cells that should be sent to bigtable. // These are cells not marked by any delete markers in this row/family. Predicate<Cell> liveDataCellPredicate = Predicates.not(Predicates .or(Lists.newArrayList(Iterables.transform(deleteMarkers, DATA_CELL_PREDICATE_FACTORY)))); for (Cell cell : dataCells) { if (liveDataCellPredicate.apply(cell)) { put.add(cell); } } } }
From source file:org.apache.brooklyn.entity.database.mysql.MySqlClusterTestHelper.java
public static void test(TestApplication app, Location location, EntitySpec<MySqlCluster> clusterSpec) throws Exception { MySqlCluster cluster = initCluster(app, location, clusterSpec); MySqlNode master = (MySqlNode) cluster.getAttribute(MySqlCluster.FIRST); MySqlNode slave = (MySqlNode) Iterables.find(cluster.getMembers(), Predicates.not(Predicates.<Entity>equalTo(master))); assertEquals(cluster.getMembers().size(), 2); assertEquals(cluster.getAttribute(MySqlCluster.SLAVE_DATASTORE_URL_LIST).size(), 1); assertEquals(cluster.getAttribute(MySqlNode.DATASTORE_URL), master.getAttribute(MySqlNode.DATASTORE_URL)); assertReplication(master, slave);//from ww w.j ava 2 s . c om }
From source file:org.sonar.plugins.flex.FlexSquidSensor.java
@Override public void analyse(Project project, SensorContext context) { this.context = context; Collection<SquidAstVisitor<LexerlessGrammar>> squidChecks = annotationCheckFactory.getChecks(); List<SquidAstVisitor<LexerlessGrammar>> visitors = Lists.newArrayList(squidChecks); visitors.add(new FileLinesVisitor(fileLinesContextFactory, fileSystem)); this.scanner = FlexAstScanner.create(createConfiguration(), visitors.toArray(new SquidAstVisitor[visitors.size()])); Iterable<java.io.File> files = fileSystem.files(mainFilePredicates); scanner.scanFiles(ImmutableList.copyOf(Iterables.filter(files, Predicates.not(MXML_FILTER)))); Collection<SourceCode> squidSourceFiles = scanner.getIndex().search(new QueryByType(SourceFile.class)); save(squidSourceFiles);/* w w w .j ava 2 s. c om*/ }
From source file:org.eclipse.sirius.diagram.editor.properties.sections.tool.createview.CreateViewMappingPropertySection.java
/** * Fetches the list of available values for the feature. * //from www . j av a2 s . c o m * @return The list of available values for the feature. */ protected List<?> getChoiceOfValues() { List<?> values = Collections.emptyList(); List<IItemPropertyDescriptor> propertyDescriptors = getDescriptors(); for (Iterator<IItemPropertyDescriptor> iterator = propertyDescriptors.iterator(); iterator.hasNext();) { IItemPropertyDescriptor propertyDescriptor = iterator.next(); if (((EStructuralFeature) propertyDescriptor.getFeature(eObject)) == getFeature()) values = new ArrayList<Object>(propertyDescriptor.getChoiceOfValues(eObject)); } // Start of user code choice of values if (!values.isEmpty()) { Predicate<Object> predicate = Predicates.or(Predicates.instanceOf(EdgeMapping.class), Predicates.instanceOf(EdgeMappingImport.class)); if (eObject instanceof CreateEdgeView) { values = Lists.newArrayList(Iterables.filter(values, predicate)); } else if (eObject instanceof CreateView) { values = Lists.newArrayList(Iterables.filter(values, Predicates.not(predicate))); } } // End of user code choice of values return values; }
From source file:org.apache.aurora.GuiceUtils.java
/** * Binds an exception trap on all interface methods of all classes bound against an interface. * Individual methods may opt out of trapping by annotating with {@link AllowUnchecked}. * Only void methods are allowed, any non-void interface methods must explicitly opt out. * * @param binder The binder to register an interceptor with. * @param wrapInterface Interface whose methods should be wrapped. * @throws IllegalArgumentException If any of the non-whitelisted interface methods are non-void. *//* www . j a v a 2s .c o m*/ public static void bindExceptionTrap(Binder binder, Class<?> wrapInterface) throws IllegalArgumentException { Set<Method> disallowed = ImmutableSet .copyOf(Iterables.filter(ImmutableList.copyOf(wrapInterface.getMethods()), Predicates.and(Predicates.not(IS_WHITELISTED), Predicates.not(VOID_METHOD)))); Preconditions.checkArgument(disallowed.isEmpty(), "Non-void methods must be explicitly whitelisted with @AllowUnchecked: %s", disallowed); Matcher<Method> matcher = Matchers.not(WHITELIST_MATCHER).and(interfaceMatcher(wrapInterface, false)); binder.bindInterceptor(Matchers.subclassesOf(wrapInterface), matcher, new MethodInterceptor() { @Override public Object invoke(MethodInvocation invocation) throws Throwable { try { return invocation.proceed(); } catch (RuntimeException e) { LOG.warn("Trapped uncaught exception: " + e, e); return null; } } }); }