List of usage examples for com.google.common.base Predicates notNull
@GwtCompatible(serializable = true) public static <T> Predicate<T> notNull()
From source file:org.jetbrains.kotlin.idea.caches.KotlinGotoSymbolContributor.java
@NotNull @Override// w ww. j a va2s . com public NavigationItem[] getItemsByName(String name, String pattern, Project project, boolean includeNonProjectItems) { GlobalSearchScope baseScope = includeNonProjectItems ? GlobalSearchScope.allScope(project) : GlobalSearchScope.projectScope(project); GlobalSearchScope noLibrarySourceScope = KotlinSourceFilterScope.kotlinSourceAndClassFiles(baseScope, project); Collection<? extends NavigationItem> functions = KotlinFunctionShortNameIndex.getInstance().get(name, project, noLibrarySourceScope); Collection<? extends NavigationItem> properties = KotlinPropertyShortNameIndex.getInstance().get(name, project, noLibrarySourceScope); List<NavigationItem> items = new ArrayList<NavigationItem>( Collections2.filter(functions, Predicates.notNull())); items.addAll(properties); return ArrayUtil.toObjectArray(items, NavigationItem.class); }
From source file:com.example.listsync.ListRepository.java
private List<CheckItem> fromStringList(List<String> download) { return Lists.newArrayList(Iterables.filter(Lists.transform(download, new Function<String, CheckItem>() { @Override/*from w w w.j av a 2 s.co m*/ public CheckItem apply(String input) { return CheckItem.fromString(input); } }), Predicates.notNull())); }
From source file:net.shibboleth.idp.consent.logic.impl.AttributeValuesHashFunction.java
/** {@inheritDoc} */ @Override// www. ja v a2 s .c o m @Nullable public String apply(@Nullable @NullableElements final Collection<IdPAttributeValue<?>> input) { if (input == null) { return null; } final Collection<IdPAttributeValue<?>> filteredInput = Collections2.filter(input, Predicates.notNull()); if (filteredInput.isEmpty()) { return null; } try { final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); final ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream); for (final IdPAttributeValue value : filteredInput) { if (value instanceof ScopedStringAttributeValue) { objectOutputStream.writeObject(((ScopedStringAttributeValue) value).getValue() + '@' + ((ScopedStringAttributeValue) value).getScope()); } else if (value instanceof XMLObjectAttributeValue) { if (value.getValue() instanceof NameIDType) { objectOutputStream.writeObject(((NameIDType) value.getValue()).getValue()); } else { try { objectOutputStream.writeObject(SerializeSupport.nodeToString( XMLObjectSupport.marshall(((XMLObjectAttributeValue) value).getValue()))); } catch (final MarshallingException e) { log.error("Error while marshalling XMLObject value", e); return null; } } } else if (value.getValue() != null) { objectOutputStream.writeObject(value.getValue()); } } objectOutputStream.flush(); objectOutputStream.close(); byteArrayOutputStream.close(); return CodecUtil.b64(HashUtil.sha256(byteArrayOutputStream.toByteArray())); } catch (final IOException e) { log.error("Error while converting attribute values into a byte array", e); return null; } }
From source file:org.eclipse.xtext.builder.impl.javasupport.ProjectClasspathChangeListener.java
@Override public void elementChanged(ElementChangedEvent event) { if (workspace != null && workspace.isAutoBuilding()) { try {//from w w w .jav a 2s . c o m if (event.getDelta() != null) { Set<IJavaProject> javaProjects = getJavaProjectsWithClasspathChange(event.getDelta()); if (!javaProjects.isEmpty()) { Set<IProject> projects = Sets.newHashSet(Iterables .filter(Iterables.transform(javaProjects, new Function<IJavaProject, IProject>() { @Override public IProject apply(IJavaProject from) { return from.getProject(); } }), Predicates.notNull())); dirtyStateManager.notifyListeners(new CoarseGrainedChangeEvent()); buildManager.scheduleBuildIfNecessary(projects, IBuildFlag.FORGET_BUILD_STATE_ONLY); } } } catch (WrappedException e) { log.error(e.getCause().getMessage(), e.getCause()); } catch (RuntimeException e) { log.error(e.getMessage(), e); } } }
From source file:gg.uhc.uhc.modules.team.TeamPMCommand.java
@Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (!(sender instanceof Player)) { sender.sendMessage(messages.getRaw("players only")); return true; }// ww w . ja va 2 s .c o m if (args.length == 0) { sender.sendMessage(messages.getRaw("no message")); return true; } Team team = module.getScoreboard().getPlayerTeam((OfflinePlayer) sender); if (team == null) { sender.sendMessage(messages.getRaw("not in team")); return true; } Iterable<Player> online = Iterables.filter( Iterables.transform(team.getPlayers(), FunctionalUtil.ONLINE_VERSION), Predicates.notNull()); Map<String, String> context = ImmutableMap.<String, String>builder().put("team prefix", team.getPrefix()) .put("team display name", team.getDisplayName()).put("team name", team.getName()) .put("sender", sender.getName()).put("message", Joiner.on(" ").join(args)).build(); String message = messages.evalTemplate("message format", context); for (Player player : online) { player.sendMessage(message); } return true; }
From source file:org.axdt.avm.scoping.AvmElementScope.java
@Override protected Iterable<IEObjectDescription> getAllLocalElements() { return Iterables.filter(getCandidates(), Predicates.notNull()); }
From source file:net.derquinse.common.orm.Entities.java
/** Clears the target set and inserts every non-null element from the source iterable. */ public static <T> void pushSet(Set<T> target, Iterable<? extends T> source) { checkNotNull(target);/*from w ww .java 2 s .co m*/ target.clear(); if (source != null) { Iterables.addAll(target, Iterables.filter(source, Predicates.notNull())); } }
From source file:org.opensaml.xmlsec.signature.support.impl.ChainingSignatureTrustEngine.java
/** * Constructor. //from w w w. j av a 2 s . c o m * * @param chain the list of trust engines in the chain */ public ChainingSignatureTrustEngine(@Nonnull @NonnullElements final List<SignatureTrustEngine> chain) { Constraint.isNotNull(chain, "SignatureTrustEngine list cannot be null"); engines = new ArrayList<>(Collections2.filter(chain, Predicates.notNull())); }
From source file:org.richfaces.cdk.resource.scan.impl.reflections.ReflectionsExt.java
public Collection<Class<?>> getMarkedClasses() { Map<String, Multimap<String, String>> storeMap = getStore().getStoreMap(); Multimap<String, String> scannerMMap = storeMap.get(MarkerResourcesScanner.class.getName()); if (scannerMMap == null) { return Collections.emptySet(); }/*from www . ja va2s . c o m*/ return Collections2.filter( Collections2.transform(scannerMMap.get(MarkerResourcesScanner.STORE_KEY), CLASS_FOR_NAME), Predicates.notNull()); }
From source file:br.com.objectos.jabuticava.debs.CaracteristicaParser.java
public Caracteristica get() { ParsedLines lines = file.onTabs().notEscaped().notQuoted().encodedWith(Encoding.ISO_8859_1) .skipFirstLines(3).withConverter(CaracteristicaSituacao.class, CaracteristicaSituacao.CONVERTER) .withConverter(Double.class, new DoubleConverter()) .withConverter(LocalDate.class, new LocalDateCsvConverter("dd/MM/yyyy")) .withConverter(DATA_VENCIMENTO, new DataVencimento()).withConverter(DATA_SAIDA, new DataOpcional()) .withConverter(SERIE, SerieConverter.INSTANCE).withConverter(EMISSAO, EmissaoConverter.INSTANCE) .getLines();//from ww w . jav a 2 s.co m Iterable<Record> registros; registros = Iterables.transform(lines, new ToRecord()); Iterable<Record> naoNulos; naoNulos = Iterables.filter(registros, Predicates.notNull()); return new Caracteristica(text, data, naoNulos); }