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.criterion.SignatureValidationConfigurationCriterion.java
/** * Constructor.//from w w w . j a va 2s . co m * * @param configurations varargs array of configuration instances */ public SignatureValidationConfigurationCriterion( @Nonnull @NonnullElements @NotEmpty SignatureValidationConfiguration... configurations) { Constraint.isNotNull(configurations, "List of configurations cannot be null"); configs = new ArrayList<>(Collections2.filter(Arrays.asList(configurations), Predicates.notNull())); Constraint.isGreaterThanOrEqual(1, configs.size(), "At least one configuration is required"); }
From source file:net.shibboleth.idp.consent.storage.impl.CollectionSerializer.java
/** {@inheritDoc} */ @Override/*from w w w . j a v a 2 s . c o m*/ @Nonnull @NotEmpty public String serialize(@Nonnull final Collection<String> instance) throws IOException { Constraint.isNotNull(instance, "Storage indexes cannot be null"); final Collection<String> filteredInstance = Collections2.filter(instance, Predicates.notNull()); final StringWriter sink = new StringWriter(128); final JsonGenerator gen = generatorFactory.createGenerator(sink); gen.writeStartArray(); for (final String element : filteredInstance) { gen.write(element); } gen.writeEnd(); gen.close(); final String serialized = sink.toString(); log.debug("Serialized '{}' as '{}'", instance, serialized); return serialized; }
From source file:jnetention.NObject.java
public Iterator<String> iterateTags(boolean includeObjectValues) { Iterator<String> i = value.keySet().iterator(); if (includeObjectValues) { i = concat(i,/*from w ww. j ava 2 s . c o m*/ filter(transform(value.entries().iterator(), new Function<Map.Entry<String, Object>, String>() { @Override public String apply(Map.Entry<String, Object> e) { Object v = e.getValue(); if (v instanceof Ref) return ((Ref) v).object; return null; } }), Predicates.notNull())); } return i; }
From source file:org.opensaml.messaging.handler.impl.BasicMessageHandlerChain.java
/** * Set the list of message handler chain members. * /*from w w w .j a v a 2 s.c om*/ * <p> * The supplied list is copied before being stored. Later modifications to * the originally supplied list will not be reflected in the handler chain membership. * </p> * * @param handlers the list of message handler members */ public void setHandlers(@Nullable @NonnullElements final List<MessageHandler<MessageType>> handlers) { if (handlers != null) { ArrayList<MessageHandler<MessageType>> newMembers = new ArrayList<>(); newMembers.addAll(Collections2.filter(handlers, Predicates.notNull())); members = newMembers; } else { members = Collections.EMPTY_LIST; } }
From source file:com.isotrol.impe3.palette.content.loader.ManyByFieldComponent.java
@Override void load(ContentCriteria criteria) { final List<Content> list = Lists.newArrayListWithCapacity(10); if (config != null) { for (String v : Iterables.filter( Arrays.asList(config.fieldValue(), config.fieldValue2(), config.fieldValue3(), config.fieldValue4(), config.fieldValue5(), config.fieldValue6(), config.fieldValue7(), config.fieldValue8(), config.fieldValue9(), config.fieldValue10()), Predicates.notNull())) { final Content c = loadContent(criteria, v); if (c != null) { list.add(c);//from w ww . ja v a 2s. com } } } contents = new ContentListingPage(list.size(), null, list); }
From source file:org.opensaml.xmlsec.impl.WhitelistBlacklistConfigurationCriterion.java
/** * Constructor./*from w w w . ja v a 2s . c om*/ * * @param configurations varargs array of configuration instances */ public WhitelistBlacklistConfigurationCriterion( @Nonnull @NonnullElements @NotEmpty WhitelistBlacklistConfiguration... configurations) { Constraint.isNotNull(configurations, "List of configurations may not be null"); configs = new ArrayList<>(Collections2.filter(Arrays.asList(configurations), Predicates.notNull())); Constraint.isGreaterThanOrEqual(1, configs.size(), "At least one configuration is required"); }
From source file:org.apache.brooklyn.test.EntityTestUtils.java
public static <T> T assertAttributeEventuallyNonNull(Map<?, ?> flags, final Entity entity, final AttributeSensor<T> attribute) { return assertAttributeEventually(flags, entity, attribute, Predicates.notNull()); }
From source file:org.carrot2.core.ControllerUtils.java
/** * Perform all life cycle actions after processing is completed. *//* w w w . ja v a 2s . co m*/ @SuppressWarnings("unchecked") public static void afterProcessing(IProcessingComponent processingComponent, Map<String, Object> attributes) { try { processingComponent.afterProcessing(); final Map<String, Object> outputAttributesWithNulls = Maps.newHashMap(); // Check if we need to do binding. if (processingComponent.getClass().getAnnotation(Bindable.class) != null) { AttributeBinder.get(processingComponent, outputAttributesWithNulls, Output.class, Processing.class); } attributes.putAll(Maps.filterValues(outputAttributesWithNulls, Predicates.notNull())); } catch (final InstantiationException e) { throw new ProcessingException("Attribute binding failed", e); } }
From source file:net.shibboleth.idp.consent.logic.impl.PreferExplicitOrderComparator.java
/** * Constructor./*from w w w. j a va2 s . c o m*/ * * @param order the desired order, null and empty strings are ignored, duplicates are removed */ public PreferExplicitOrderComparator(@Nullable @NullableElements final List<String> order) { if (order == null) { explicitOrder = Collections.emptyList(); } else { // trimmed explicitOrder = Lists.transform(order, TrimOrNullStringFunction.INSTANCE); // non-null explicitOrder = ImmutableList.copyOf(Iterables.filter(explicitOrder, Predicates.notNull())); // no duplicates explicitOrder = ImmutableSet.copyOf(explicitOrder).asList(); explicitOrdering = Ordering.explicit(explicitOrder); } }
From source file:com.metamx.druid.query.ChainedExecutionQueryRunner.java
public ChainedExecutionQueryRunner(ExecutorService exec, Ordering<T> ordering, Iterable<QueryRunner<T>> queryables) { this.exec = exec; this.ordering = ordering; this.queryables = Iterables.unmodifiableIterable(Iterables.filter(queryables, Predicates.notNull())); }