List of usage examples for com.google.common.base Predicates notNull
@GwtCompatible(serializable = true) public static <T> Predicate<T> notNull()
From source file:com.viadeo.kasper.core.id.DefaultIDTransformer.java
@Override public Map<ID, ID> to(final Format format, final ID firstId, final ID... restIds) { checkNotNull(format);//www . j a va 2s. c o m List<ID> ids = Lists.asList(firstId, restIds); checkArgument(Iterables.all(ids, Predicates.notNull()), "Each specified ids must be not null"); return doConvertAll(format, ids); }
From source file:com.groupon.jenkins.mybuildsview.MyBuildsView.java
public Iterable<OrganizationContainer> getOrgs() { Iterable<OrganizationContainer> orgs = Iterables.transform(getUser().getOrgs(), new Function<String, OrganizationContainer>() { @Override//from w ww . j a va 2s .com public OrganizationContainer apply(@Nullable String orgName) { return (OrganizationContainer) Jenkins.getInstance().getItem(orgName); } }); return Iterables.filter(orgs, Predicates.notNull()); }
From source file:org.jclouds.ec2.compute.suppliers.EC2ImageSupplier.java
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override// ww w .j av a 2 s .c o m public Set<? extends Image> get() { if (amiOwners.length == 0) { logger.debug(">> no owners specified, skipping image parsing"); return ImmutableSet.of(); } else { logger.debug(">> providing images"); Iterable<Entry<String, DescribeImagesOptions>> queries = getDescribeQueriesForOwnersInRegions( regions.get(), amiOwners); Iterable<? extends Image> parsedImages = ImmutableSet .copyOf(filter(transform(describer.apply(queries), parser), Predicates.notNull())); Map<RegionAndName, ? extends Image> imageMap = ImagesToRegionAndIdMap.imagesToMap(parsedImages); cache.get().invalidateAll(); cache.get().asMap().putAll((Map) imageMap); logger.debug("<< images(%d)", imageMap.size()); return Sets.newLinkedHashSet(imageMap.values()); } }
From source file:org.jclouds.openstack.nova.v2_0.compute.functions.NeutronSecurityGroupToSecurityGroup.java
@Override public SecurityGroup apply(@Nullable org.jclouds.openstack.neutron.v2.domain.SecurityGroup group) { SecurityGroupBuilder builder = new SecurityGroupBuilder(); builder.providerId(group.getId());//from w ww. ja v a2 s .c o m builder.ownerId(group.getTenantId()); builder.name(group.getName()); final String regionId = location.getId(); builder.location(location); builder.id(regionId + "/" + group.getId()); if (group.getRules() != null) { builder.ipPermissions(filter(transform(group.getRules(), new Function<Rule, IpPermission>() { @Override public IpPermission apply(Rule from) { if (from.getDirection() == RuleDirection.EGRESS) return null; IpPermission.Builder builder = IpPermission.builder(); if (from.getProtocol() != null) { builder.ipProtocol(IpProtocol.fromValue(from.getProtocol().name())); } else { builder.ipProtocol(IpProtocol.TCP); } if (from.getPortRangeMin() != null) builder.fromPort(from.getPortRangeMin()); if (from.getPortRangeMax() != null) builder.toPort(from.getPortRangeMax()); if (from.getRemoteGroupId() != null) { builder.groupId(regionId + "/" + from.getRemoteGroupId()); } else if (from.getRemoteIpPrefix() != null) { builder.cidrBlock(from.getRemoteIpPrefix()); } return builder.build(); } }), Predicates.notNull())); } return builder.build(); }
From source file:org.polarsys.reqcycle.traceability.storage.vars.VarManager.java
private static Map<String, Variable> getAllVars() { List<IConfigurationElement> elements = Arrays .asList(Platform.getExtensionRegistry().getConfigurationElementsFor(Activator.PLUGIN_ID, EXT_ID)); Iterable<Variable> vars = Iterables .filter(Iterables.transform(elements, new Function<IConfigurationElement, Variable>() { @Override/*from ww w.ja v a 2 s . c om*/ public Variable apply(IConfigurationElement arg0) { try { return (Variable) arg0.createExecutableExtension("instance"); } catch (CoreException e) { } return null; } }), Predicates.notNull()); return Maps.uniqueIndex(vars, new Function<Variable, String>() { @Override public String apply(Variable arg0) { return arg0.getLabel(); } }); }
From source file:io.druid.query.aggregation.cardinality.CardinalityAggregatorFactory.java
private List<DimensionSelector> makeDimensionSelectors(final ColumnSelectorFactory columnFactory) { return Lists.newArrayList( Iterables.filter(Iterables.transform(fieldNames, new Function<String, DimensionSelector>() { @Nullable// www. ja va 2s .c o m @Override public DimensionSelector apply(@Nullable String input) { return columnFactory.makeDimensionSelector(input, null); } }), Predicates.notNull())); }
From source file:org.lenskit.data.entities.AbstractBeanEntity.java
@Override public Collection<Attribute<?>> getAttributes() { return new AbstractCollection<Attribute<?>>() { @Override//www . j a v a 2 s .c o m public Iterator<Attribute<?>> iterator() { return (Iterator) IntStream.range(0, layout.attributes.size()).mapToObj(i -> { Object val = layout.getters.get(i).get(AbstractBeanEntity.this); if (val == null) { return null; } else { return Attribute.create((TypedName) layout.attributes.getAttribute(i), val); } }).filter(Predicates.notNull()).iterator(); } @Override public int size() { return layout.attributes.size(); } }; }
From source file:org.apache.druid.query.topn.TopNQueryEngine.java
public Sequence<Result<TopNResultValue>> query(final TopNQuery query, final StorageAdapter adapter, final @Nullable TopNQueryMetrics queryMetrics) { if (adapter == null) { throw new SegmentMissingException( "Null storage adapter found. Probably trying to issue a query against a segment being memory unmapped."); }//from ww w . ja v a 2 s . c om final List<Interval> queryIntervals = query.getQuerySegmentSpec().getIntervals(); final Filter filter = Filters.convertToCNFFromQueryContext(query, Filters.toFilter(query.getDimensionsFilter())); final Granularity granularity = query.getGranularity(); final TopNMapFn mapFn = getMapFn(query, adapter, queryMetrics); Preconditions.checkArgument(queryIntervals.size() == 1, "Can only handle a single interval, got[%s]", queryIntervals); return Sequences .filter(Sequences.map( adapter.makeCursors(filter, queryIntervals.get(0), query.getVirtualColumns(), granularity, query.isDescending(), queryMetrics), new Function<Cursor, Result<TopNResultValue>>() { @Override public Result<TopNResultValue> apply(Cursor input) { if (queryMetrics != null) { queryMetrics.cursor(input); } return mapFn.apply(input, queryMetrics); } }), Predicates.notNull()); }
From source file:net.shibboleth.idp.profile.interceptor.impl.PopulateProfileInterceptorContext.java
/** * Set the flows available for possible use. * /*from w ww . jav a2 s. c o m*/ * @param flows the flows available for possible use */ public void setAvailableFlows( @Nonnull @NonnullElements final Collection<ProfileInterceptorFlowDescriptor> flows) { ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this); Constraint.isNotNull(flows, "Flow collection cannot be null"); availableFlows = new ArrayList<>(Collections2.filter(flows, Predicates.notNull())); }
From source file:org.locationtech.geogig.storage.memory.HeapGraphDatabase.java
@Override public ImmutableList<ObjectId> getParents(ObjectId commitId) throws IllegalArgumentException { return graph.get(commitId).transform(new Function<Node, ImmutableList<ObjectId>>() { @Override//from w ww.j a v a2 s . com public ImmutableList<ObjectId> apply(Node n) { // transform outgoing nodes to id // filter for null to skip fake root node return new ImmutableList.Builder<ObjectId>() .addAll(filter(transform(n.to(), NODE_TO_ID), Predicates.notNull())).build(); } }).or(ImmutableList.<ObjectId>of()); }