List of usage examples for com.google.common.base Predicates alwaysTrue
@GwtCompatible(serializable = true) public static <T> Predicate<T> alwaysTrue()
From source file:org.linagora.linshare.core.domain.vo.ThreadMemberVo.java
public static Predicate<ThreadMemberVo> hasRole(final ThreadRoles role) { if (role == null) return Predicates.alwaysTrue(); return new Predicate<ThreadMemberVo>() { @Override/*from w w w .j a v a 2 s. c om*/ public boolean apply(ThreadMemberVo input) { switch (role) { case ADMIN: return input.admin; case NORMAL: return input.canUpload && !input.admin; case RESTRICTED: return !(input.canUpload || input.admin); default: /* NOT REACHED */ return true; } } }; }
From source file:com.sri.ai.grinder.library.Associative.java
@Override public Expression rewriteAfterBookkeeping(Expression expression, final RewritingProcess process) { Expression functor = expression.getFunctor(); if (operators.contains(functor)) { Predicate<Expression> alwaysTrue = Predicates.alwaysTrue(); Expression result = Associative.associateWhenSureOperatorIsAssociative(expression, alwaysTrue); return result; }/* w ww.j ava 2s .c o m*/ return expression; }
From source file:org.apache.isis.core.metamodel.postprocessors.param.ActionCollectionParameterDefaultsAndChoicesPostProcessor.java
@Override public void postProcess(final ObjectSpecification objectSpecification) { // all the actions of this type final List<ActionType> actionTypes = inferActionTypes(); List<ObjectAction> objectActions = objectSpecification.getObjectActions(actionTypes, Contributed.INCLUDED, Predicates.alwaysTrue()); // and all the collections of this type final List<OneToManyAssociation> collections = objectSpecification.getCollections(Contributed.INCLUDED); // for each collection, ... for (final OneToManyAssociation collection : collections) { // ... see if any of its actions has a collection parameter of the same type ///*from w ww.j a v a 2 s . co m*/ // eg Order#getItems() and Order#removeItems(List<OrderItem>) // final ObjectSpecification specification = collection.getSpecification(); final ObjectActionParameter.Predicates.CollectionParameter whetherCollectionParamOfType = new ObjectActionParameter.Predicates.CollectionParameter( specification); final ObjectActionParameter.Predicates.ScalarParameter whetherScalarParamOfType = new ObjectActionParameter.Predicates.ScalarParameter( specification); final ImmutableList<ObjectAction> actionsAssociatedWithCollection = FluentIterable.from(objectActions) .filter(ObjectAction.Predicates.associatedWith(collection)).toList(); for (final ObjectAction action : actionsAssociatedWithCollection) { final List<ObjectActionParameter> parameters = action.getParameters(); final ImmutableList<ObjectActionParameter> compatibleCollectionParams = FluentIterable .from(parameters).filter(whetherCollectionParamOfType).toList(); final ImmutableList<ObjectActionParameter> compatibleScalarParams = FluentIterable.from(parameters) .filter(whetherScalarParamOfType).toList(); // for collection parameters, install an defaults facet (if there isn't one already) // this will cause the UI to render the collection with toggleboxes // with a thread-local used to provide the selected objects for (final ObjectActionParameter collectionParam : compatibleCollectionParams) { addDefaultsFacetIfNoneAlready(collectionParam); } // for compatible collection parameters, install a choices facet (if there isn't one already) // using the associated collection for its values for (final ObjectActionParameter collectionParam : compatibleCollectionParams) { addChoicesFacetIfNoneAlready(collection, collectionParam); } // similarly for compatible scalar parameters, install a choices facet (if there isn't one already) // using the associated collection for its values. for (final ObjectActionParameter scalarParam : compatibleScalarParams) { addChoicesFacetIfNoneAlready(collection, scalarParam); } } } }
From source file:com.blacklocus.qs.aws.sqs.AmazonSQSPrioritizedMessageProvider.java
/** * Create a new MessageProvider instance. * * @param sqs AmazonSQS instance to use for communicating with AWS * @param queuePrefix the prefix to use when searching for queues * @param updateIntervalMs time in milliseconds between when new queues should be checked *///from w w w .j a v a 2 s.c o m public AmazonSQSPrioritizedMessageProvider(AmazonSQS sqs, String queuePrefix, long updateIntervalMs) { this.sqs = sqs; this.queuePrefix = queuePrefix; this.updateIntervalNs = TimeUnit.MILLISECONDS.toNanos(updateIntervalMs); this.include = Predicates.alwaysTrue(); this.queueComparator = DEFAULT_QUEUE_COMPARATOR; this.messageProviders = Lists.newArrayList(); // ensure first next() causes an updateAvailableQueues() this.lastNanoTime = currentNanoTime() - updateIntervalNs - 1; }
From source file:org.apache.brooklyn.location.jclouds.BailOutJcloudsLocation.java
public void tryObtain(Map<?, ?> flags) { tryObtainAndCheck(flags, Predicates.alwaysTrue()); }
From source file:org.caleydo.core.event.EventListenerManager.java
/** * Filter all methods of the listener object for <code> * * @ListenTo void xxx(<? extends AEvent> event); </code> * * and register an event listener for calling this method * * @param listener/*www. jav a2 s. c o m*/ * @param eventSpace * if {@link ListenTo#restrictToEventSpace()} or {@link ListenTo#restrictExclusiveToEventSpace()} is used * the eventSpace to set */ public final <T> T register(T listener, String eventSpace) { return register(listener, eventSpace, Predicates.alwaysTrue()); }
From source file:com.google.javascript.jscomp.InlineVariables.java
private Predicate<Var> getFilterForMode() { switch (mode) { case ALL:/* w ww .j a va2 s . co m*/ return Predicates.alwaysTrue(); case LOCALS_ONLY: return new IdentifyLocals(); case CONSTANTS_ONLY: return new IdentifyConstants(); default: throw new IllegalStateException(); } }
From source file:org.spongepowered.common.entity.ai.target.SpongeFindNearestAttackableTargetAIBuilder.java
@SuppressWarnings("unchecked") @Override/*from w w w .j a va 2s .c om*/ public FindNearestAttackableTargetAITask build(Creature owner) { Preconditions.checkNotNull(owner); Preconditions.checkNotNull(this.targetClass); return (FindNearestAttackableTargetAITask) new EntityAINearestAttackableTarget<>((EntityCreature) owner, (Class<? extends EntityLivingBase>) this.targetClass, this.chance, this.checkSight, this.onlyNearby, this.predicate == null ? Predicates.alwaysTrue() : GuavaJavaUtils.asGuavaPredicate((Predicate<Entity>) (Predicate<?>) this.predicate)); }
From source file:org.eclipse.xtext.ui.editor.findrefs.ReferenceQueryExecutor.java
protected Predicate<IReferenceDescription> getFilter(EObject primaryTarget) { return Predicates.alwaysTrue(); }
From source file:org.terasology.classMetadata.ClassMetadata.java
/** * Scans the class this metadata describes, adding all fields to the class' metadata. * * @param copyStrategyLibrary The library of copy strategies * @param factory The reflection provider *///from w w w . j a va 2s .c om private void addFields(CopyStrategyLibrary copyStrategyLibrary, ReflectFactory factory) { for (Field field : ReflectionUtils.getAllFields(clazz, Predicates.alwaysTrue())) { if (Modifier.isTransient(field.getModifiers()) || Modifier.isStatic(field.getModifiers())) { continue; } CopyStrategy<?> copyStrategy = copyStrategyLibrary.getStrategy(field.getGenericType()); try { FIELD metadata = createField(field, copyStrategy, factory); if (metadata != null) { fields.put(metadata.getName().toLowerCase(Locale.ENGLISH), metadata); } } catch (InaccessibleFieldException e) { logger.error("Could not create metadata for field '{}' of type '{}', may be private.'", field, clazz); } } }