List of usage examples for com.google.common.base Predicates isNull
@GwtCompatible(serializable = true) public static <T> Predicate<T> isNull()
From source file:edu.umn.msi.tropix.client.directory.impl.UserIterableImpl.java
public Iterator<GridUser> iterator() { final Collection<GridUser> users = new LinkedList<GridUser>(); final Multimap<String, Person> persons = personSupplier.get(); for (String institution : persons.keySet()) { Iterables.addAll(users,// w ww.java 2 s.co m Iterables.filter( Collections2.transform(persons.get(institution), new PersonFunction(institution)), Predicates.not(Predicates.isNull()))); } for (final GridUser user : users) { gridUserMap.put(user.getGridId(), user); } return users.iterator(); }
From source file:com.google.devtools.build.android.aapt2.StaticLibrary.java
public static Collection<String> toAssetPaths(List<StaticLibrary> libraries) { return libraries.stream().map(StaticLibrary::asAssetPathStrings).filter(Predicates.isNull()) .flatMap(List::stream).map(Object::toString).collect(toImmutableList()); }
From source file:org.decisiondeck.jlp.LpVariable.java
/** * Builds a variable of the given category and with the provided references. * // w w w . j ava 2s .c o m * @param category * not <code>null</code>. * @param references * not <code>null</code>, no <code>null</code> reference inside. May be empty. */ public LpVariable(T category, Object... references) { Preconditions.checkNotNull(category); Preconditions.checkNotNull(references); final List<Object> asList = Arrays.asList(references); final boolean hasNull = Iterables.any(asList, Predicates.isNull()); if (hasNull) { throw new NullPointerException("Given references contain a null reference."); } m_category = category; m_refs = Collections.unmodifiableList(asList); }
From source file:uk.co.unclealex.executable.generator.scan.ExecutableAnnotationInformationFinderImpl.java
/** * Find all {@link Executable} annotations in a list of classes. * /* ww w .ja v a 2s . c o m*/ * @param clazz * The class to search. * @return A list of all found methods that have an {@link Executable} * annotation. * @throws ExecutableScanException * Thrown if there is an error with {@link Executable} annotations * for the given class. */ protected List<ExecutableAnnotationInformation> findExecutableAnnotationInformation(Class<?> clazz) throws ExecutableScanException { Predicate<Method> isAnnotatedPredicate = Predicates.compose(Predicates.not(Predicates.isNull()), new ExecutableAnnotationFunction()); List<Method> annotatedMethods = Lists .newArrayList(Iterables.filter(Arrays.asList(clazz.getDeclaredMethods()), isAnnotatedPredicate)); List<ExecutableAnnotationInformation> executableAnnotationInformations = Lists.newArrayList(); if (!annotatedMethods.isEmpty()) { if (clazz.getEnclosingClass() != null || clazz.isInterface()) { throw new NotTopLevelClassExecutableScanException(clazz); } for (Method annotatedMethod : annotatedMethods) { ExecutableAnnotationInformation executableAnnotationInformation = generateExecutableAnnotationInformation( clazz, annotatedMethod); executableAnnotationInformations.add(executableAnnotationInformation); } } return executableAnnotationInformations; }
From source file:eu.interedition.web.metadata.DublinCoreMetadata.java
public boolean isEmpty() { return Iterables.all(Lists.newArrayList(title, creator, subject, description, publisher, contributor, date, type, format, identifier, source, language), Predicates.isNull()); }
From source file:org.eclipse.wb.internal.swing.model.bean.AbstractActionInfo.java
private List<Property> createProperties() throws Exception { CreationSupport creationSupport = getCreationSupport(); // no additional properties available if (!(creationSupport instanceof IActionSupport)) { return Lists.newArrayList(); }/* www . j av a2s . c om*/ // create properties List<Property> properties = Lists.newArrayList(); properties.add(createStringProperty("name", "NAME")); properties.add(createStringProperty("short description", "SHORT_DESCRIPTION")); properties.add(createStringProperty("long description", "LONG_DESCRIPTION")); properties.add(createIconProperty("small icon", "SMALL_ICON")); properties.add(createStringProperty("action command", "ACTION_COMMAND_KEY")); properties.add(createProperty("accelerator", "ACCELERATOR_KEY", null, KeyStrokePropertyEditor.INSTANCE)); properties .add(createProperty("mnemonic", "MNEMONIC_KEY", null, DisplayedMnemonicKeyPropertyEditor.INSTANCE)); if (SystemUtils.JAVA_VERSION_FLOAT >= 1.6) { properties.add(createProperty("displayed mnemonic index", "DISPLAYED_MNEMONIC_INDEX_KEY", IntegerConverter.INSTANCE, IntegerPropertyEditor.INSTANCE)); properties.add(createIconProperty("large icon", "LARGE_ICON_KEY")); } // remove null-s Iterables.removeIf(properties, Predicates.isNull()); return properties; }
From source file:com.eucalyptus.reporting.modules.backend.DescribeSensorsListener.java
@Override public void fireEvent(final Hertz event) { if (!Bootstrap.isOperational() || !BootstrapArgs.isCloudController() || !event.isAsserted(DEFAULT_POLL_INTERVAL_MINS)) { return;//from w w w . j av a 2s . c o m } else { if (DEFAULT_POLL_INTERVAL_MINS >= 1) { COLLECTION_INTERVAL_TIME_MS = ((int) TimeUnit.MINUTES.toMillis(DEFAULT_POLL_INTERVAL_MINS) / 2); } else { COLLECTION_INTERVAL_TIME_MS = 0; } if (COLLECTION_INTERVAL_TIME_MS == 0 || HISTORY_SIZE > 15 || HISTORY_SIZE < 1) { LOG.debug("The instance usage report is disabled"); } else if (COLLECTION_INTERVAL_TIME_MS <= MAX_WRITE_INTERVAL_MS) { try { if (event.isAsserted(TimeUnit.MINUTES.toSeconds(DEFAULT_POLL_INTERVAL_MINS))) { if (Bootstrap.isFinished() && Hosts.isCoordinator()) { if (busy.compareAndSet(false, true)) { Threads.lookup(Reporting.class).limitTo(REPORTING_NUM_THREADS) .submit(new Callable<Object>() { @Override public Object call() throws Exception { try { List<VmInstance> instList = VmInstances.list(VmState.RUNNING); List<String> instIdList = Lists.newArrayList(); for (final VmInstance inst : instList) { instIdList.add(inst.getInstanceId()); } Iterable<List<String>> processInts = Iterables .paddedPartition(instIdList, SENSOR_QUERY_BATCH_SIZE); for (final ServiceConfiguration ccConfig : Topology .enabledServices(ClusterController.class)) { for (List<String> instIds : processInts) { ArrayList<String> instanceIds = Lists .newArrayList(instIds); Iterables.removeIf(instanceIds, Predicates.isNull()); // LOG.info("DecribeSensorCallback about to be sent"); /** * Here this is hijacking the sensor callback in order to control the thread of execution used when invoking the */ final DescribeSensorCallback msgCallback = new DescribeSensorCallback( HISTORY_SIZE, COLLECTION_INTERVAL_TIME_MS, instanceIds) { @Override public void fireException(Throwable e) { } @Override public void fire(DescribeSensorsResponse msg) { } }; /** * Here we actually get the future reference to the result and, from this thread, invoke .fire(). */ Future<DescribeSensorsResponse> ret = AsyncRequests .newRequest(msgCallback).dispatch(ccConfig); try { new DescribeSensorCallback(HISTORY_SIZE, COLLECTION_INTERVAL_TIME_MS, instanceIds) .fire(ret.get()); // LOG.info("DecribeSensorCallback has been successfully executed"); } catch (Exception e) { Exceptions.maybeInterrupted(e); } } } } finally { /** * Only and finally set the busy bit back to false. */ busy.set(false); } return null; } }); } } } } catch (Exception ex) { LOG.error("Unable to listen for describe sensors events", ex); } } else { LOG.error("DEFAULT_POLL_INTERVAL_MINS : " + DEFAULT_POLL_INTERVAL_MINS + " must be less than 1440 minutes"); } } }
From source file:net.derquinse.common.meta.MetaProperty.java
/** * Returns a predicate that evaluates to {@code true} if the property value is null. */// w w w . j a v a 2 s .c o m public final Predicate<C> isNull() { return compose(Predicates.isNull()); }
From source file:org.grouplens.lenskit.eval.script.ConfigMethodInvoker.java
/** * Find a method that should be invoked multiple times, if the argument is iterable. The * argument may be iterated multiple times. * * @param self The configurable object./*from ww w . j av a2 s.co m*/ * @param name The method name. * @param args The arguments. * @return A thunk that will invoke the method. */ private Supplier<Object> findMultiMethod(final Object self, String name, final Object[] args) { if (args.length != 1) return null; // the argument is a list final Object arg = args[0]; if (!(arg instanceof Iterable)) { return null; } final Iterable<?> objects = (Iterable<?>) arg; Supplier<Object> result = null; for (final Method method : getOneArgMethods(self, name)) { Class ptype = method.getParameterTypes()[0]; boolean good = Iterables.all(objects, Predicates.or(Predicates.isNull(), Predicates.instanceOf(ptype))); if (good) { if (result != null) { throw new RuntimeException("multiple compatible methods named " + name); } else { result = new Supplier<Object>() { @Override public Object get() { for (Object obj : objects) { try { method.invoke(self, obj); } catch (IllegalAccessException e) { throw Throwables.propagate(e); } catch (InvocationTargetException e) { if (e.getCause() != null) { throw Throwables.propagate(e); } } } return null; } }; } } } return result; }
From source file:eu.europa.ec.fisheries.uvms.rules.service.bean.MDRCacheServiceBean.java
@Override public boolean combinationExistsInConversionFactorList(List<FLUXLocation> specifiedFLUXLocations, List<CodeType> appliedAAPProcessTypeCodes, CodeType speciesCode) { // clean lists from nulls Iterables.removeIf(specifiedFLUXLocations, Predicates.isNull()); Iterables.removeIf(appliedAAPProcessTypeCodes, Predicates.isNull()); // country column String country = StringUtils.EMPTY; if (CollectionUtils.isNotEmpty(specifiedFLUXLocations)) { for (FLUXLocation location : specifiedFLUXLocations) { final IDType locId = location.getID(); if (locId != null && ("TERRITORY".equals(locId.getSchemeID()) || "MANAGEMENT_AREA".equals(locId.getSchemeID()))) { country = locId.getValue(); }/*ww w . ja va 2s. com*/ } } if (isPresentInMDRList("MEMBER_STATE", country)) { country = "XEU"; } // presentation, state columns String presentation = StringUtils.EMPTY; String state = StringUtils.EMPTY; if (CollectionUtils.isNotEmpty(appliedAAPProcessTypeCodes)) { for (CodeType presPreserv : appliedAAPProcessTypeCodes) { if ("FISH_PRESENTATION".equals(presPreserv.getListId())) { presentation = presPreserv.getValue(); } if ("FISH_PRESERVATION".equals(presPreserv.getListId())) { state = presPreserv.getValue(); } } } List<ObjectRepresentation> finalList = null; if (!(StringUtils.isBlank(country) || StringUtils.isBlank(presentation) || StringUtils.isBlank(state))) { List<ObjectRepresentation> entry = cache.getEntry(MDRAcronymType.CONVERSION_FACTOR); List<ObjectRepresentation> filtered_1_list = filterEntriesByColumn(entry, "placesCode", country); List<ObjectRepresentation> filtered_2_list = filterEntriesByColumn(filtered_1_list, "species", speciesCode != null ? speciesCode.getValue() : StringUtils.EMPTY); List<ObjectRepresentation> filtered_3_list = filterEntriesByColumn(filtered_2_list, "presentation", presentation); finalList = filterEntriesByColumn(filtered_3_list, "state", state); } return CollectionUtils.isNotEmpty(finalList); }