List of usage examples for com.google.common.base Predicates notNull
@GwtCompatible(serializable = true) public static <T> Predicate<T> notNull()
From source file:org.opensaml.xmlsec.impl.BasicEncryptionConfiguration.java
/** * Set the key transport encryption credentials to use. * // ww w. j a v a 2 s. co m * @param credentials the list of key transport encryption credentials */ public void setKeyTransportEncryptionCredentials(@Nullable final List<Credential> credentials) { if (credentials == null) { keyTransportEncryptionCredentials = Collections.emptyList(); return; } keyTransportEncryptionCredentials = new ArrayList<>(Collections2.filter(credentials, Predicates.notNull())); }
From source file:google.registry.model.contact.ContactResource.java
/** * Postal info for the contact./*from ww w . j a v a2s.co m*/ * * <p>The XML marshalling expects the {@link PostalInfo} objects in a list, but we can't actually * persist them to datastore that way because Objectify can't handle collections of embedded * objects that themselves contain collections, and there's a list of streets inside. This method * transforms the persisted format to the XML format for marshalling. */ @XmlElement(name = "postalInfo") public ImmutableList<PostalInfo> getPostalInfosAsList() { return FluentIterable.from(Lists.newArrayList(localizedPostalInfo, internationalizedPostalInfo)) .filter(Predicates.notNull()).toList(); }
From source file:org.eclipse.xtext.xtext.ecoreInference.Xtext2EcoreTransformer.java
public List<EPackage> getGeneratedPackages() { final List<EPackage> result = new ArrayList<EPackage>(); final ResourceSet resourceSet = grammar.eResource().getResourceSet(); if (resourceSet == null) throw new NullPointerException("resourceSet may not be null"); Iterables.addAll(result,//from www. ja va 2 s .c om Iterables.filter(Iterables.transform( Iterables.filter(grammar.getMetamodelDeclarations(), GeneratedMetamodel.class), new Function<AbstractMetamodelDeclaration, EPackage>() { @Override public EPackage apply(AbstractMetamodelDeclaration param) { EPackage pack = (EPackage) param.eGet( XtextPackage.Literals.ABSTRACT_METAMODEL_DECLARATION__EPACKAGE, false); if (pack != null && !pack.eIsProxy()) { return pack; } return null; } }), Predicates.notNull())); return getPackagesSortedByName(result); }
From source file:eu.itesla_project.graph.UndirectedGraphImpl.java
@Override public Iterable<V> getVerticesObj() { return FluentIterable.from(vertices).filter(Predicates.notNull()).transform(Vertex::getObject); }
From source file:org.opensaml.security.x509.impl.BasicX509CredentialNameEvaluator.java
/** * Set the set of types of subject alternative names to process. * /*from w ww . j a v a 2s .c o m*/ * Name types are represented using the constant OID tag name values defined in {@link X509Support}. * * * @param nameTypes the new set of alt name identifiers */ public void setSubjectAltNameTypes(@Nullable final Set<Integer> nameTypes) { if (nameTypes == null) { subjectAltNameTypes = Collections.emptySet(); } else { subjectAltNameTypes = new HashSet<>(Collections2.filter(nameTypes, Predicates.notNull())); } }
From source file:org.splevo.ui.vpexplorer.explorer.ExplorerMediator.java
private Iterable<Object> preprocessSelectedObjects(Iterable<Object> selectedObjects) { final VariationPointModel currentVPM = getCurrentVPM(); if (currentVPM == null) { return selectedObjects; }//ww w . ja v a 2 s .c om Iterable<VariationPoint> selectedVPs = Iterables.filter(selectedObjects, VariationPoint.class); Iterable<VariationPoint> mappedVPs = Iterables.transform(selectedVPs, new Function<VariationPoint, VariationPoint>() { private VariationPointModel getParentVPM(VariationPoint vpm) { EObject parent = vpm.eContainer(); while (parent != null && !(parent instanceof VariationPointModel)) { parent = parent.eContainer(); } return (VariationPointModel) parent; } @Override public VariationPoint apply(VariationPoint arg0) { if (getParentVPM(arg0) == currentVPM) { return arg0; } Optional<VariationPoint> vp = ILinkableNavigatorHelper.find(arg0, currentVPM); if (vp.isPresent()) { return vp.get(); } return null; } }); Iterable<VariationPoint> selectedAndAvailableVPs = Iterables.filter(mappedVPs, Predicates.notNull()); Set<Object> noVPObjects = Sets.difference(Sets.newHashSet(selectedObjects), Sets.newHashSet(selectedVPs)); return Iterables.concat(noVPObjects, selectedAndAvailableVPs); }
From source file:ru.crazyproger.plugins.webtoper.nls.codeinsight.NlsLineMarkerProvider.java
private Collection<NlsFileImpl> getReferencingFiles(NlsFileImpl currentFile) { Iterable<PsiReference> references = SearchUtils.findAllReferences(currentFile); Collection<NlsFileImpl> directChilds = transform(Lists.<PsiReference>newArrayList(references), new Reference2ContainedFileFunction()); return filter(directChilds, Predicates.notNull()); }
From source file:net.shibboleth.idp.relyingparty.RelyingPartyConfiguration.java
/** * Set the profile configurations for this relying party. * /* w w w .j a v a 2 s. c o m*/ * @param configs the configurations to set */ public void setProfileConfigurations(@Nonnull @NonnullElements final Collection<ProfileConfiguration> configs) { ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this); Constraint.isNotNull(configs, "ProfileConfiguration collection cannot be null"); profileConfigurations = new HashMap<>(); for (ProfileConfiguration config : Collections2.filter(configs, Predicates.notNull())) { final String trimmedId = Constraint.isNotNull(StringSupport.trimOrNull(config.getId()), "ID of profile configuration class " + config.getClass().getName() + " cannot be null"); profileConfigurations.put(trimmedId, config); } }
From source file:org.jclouds.glesys.compute.functions.ServerDetailsToNodeMetadata.java
@Override public NodeMetadata apply(ServerDetails from) { NodeMetadataBuilder builder = new NodeMetadataBuilder(); builder.ids(from.getId() + ""); builder.name(from.getHostname());//from ww w .ja va 2 s . com builder.hostname(from.getHostname()); Location location = FluentIterable.from(locations.get()).firstMatch(idEquals(from.getDatacenter())) .orNull(); checkState(location != null, "no location matched ServerDetails %s", from); builder.group(nodeNamingConvention.groupInUniqueNameOrNull(from.getHostname())); // TODO: get glesys to stop stripping out equals and commas! if (!isNullOrEmpty(from.getDescription()) && from.getDescription().matches("^[0-9A-Fa-f]+$")) { String decoded = new String(base16().lowerCase().decode(from.getDescription()), UTF_8); addMetadataAndParseTagsFromCommaDelimitedValue(builder, Splitter.on('\n').withKeyValueSeparator("=").split(decoded)); } builder.imageId(from.getTemplateName() + ""); builder.operatingSystem(parseOperatingSystem(from)); builder.hardware(new HardwareBuilder().ids(from.getId() + "").ram(from.getMemorySizeMB()) .processors(ImmutableList.of(new Processor(from.getCpuCores(), 1.0))) .volumes(ImmutableList.<Volume>of(new VolumeImpl((float) from.getDiskSizeGB(), true, true))) .hypervisor(from.getPlatform()).build()); builder.status(serverStateToNodeStatus.get(from.getState())); Iterable<String> addresses = Iterables .filter(Iterables.transform(from.getIps(), new Function<Ip, String>() { @Override public String apply(Ip arg0) { return Strings.emptyToNull(arg0.getIp()); } }), Predicates.notNull()); builder.publicAddresses(Iterables.filter(addresses, Predicates.not(IsPrivateIPAddress.INSTANCE))); builder.privateAddresses(Iterables.filter(addresses, IsPrivateIPAddress.INSTANCE)); return builder.build(); }
From source file:org.opentestsystem.authoring.testauth.publish.PublisherUtil.java
protected static Identifier buildIdentifier(final String name, final String label, final String version) { String xmlLabel = StringEscapeUtils.escapeXml(label); final List<String> fields = Lists .newArrayList(Iterables.filter(Lists.newArrayList(StringUtils.trimToNull(name), StringUtils.trimToNull(xmlLabel), StringUtils.trimToNull(version)), Predicates.notNull())); return new Identifier(StringUtils.join(fields.toArray(), "-"), name, xmlLabel, version); }