List of usage examples for com.google.common.base Predicates alwaysTrue
@GwtCompatible(serializable = true) public static <T> Predicate<T> alwaysTrue()
From source file:org.apache.brooklyn.enricher.stock.Combiner.java
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override//from ww w. j a v a 2 s . co m public void setEntity(EntityLocal entity) { super.setEntity(entity); this.transformation = (Function<? super Collection<T>, ? extends U>) getRequiredConfig(TRANSFORMATION); this.producer = getConfig(PRODUCER) == null ? entity : getConfig(PRODUCER); this.sourceSensors = (Set) getRequiredConfig(SOURCE_SENSORS); this.targetSensor = (Sensor<U>) getRequiredConfig(TARGET_SENSOR); this.valueFilter = (Predicate<? super T>) (getConfig(VALUE_FILTER) == null ? Predicates.alwaysTrue() : getConfig(VALUE_FILTER)); checkState(sourceSensors.size() > 0, "must specify at least one sourceSensor"); for (Sensor<T> sourceSensor : sourceSensors) { subscriptions().subscribe(producer, sourceSensor, this); } for (Sensor<T> sourceSensor : sourceSensors) { if (sourceSensor instanceof AttributeSensor) { Object value = producer.getAttribute((AttributeSensor<?>) sourceSensor); // TODO Aled didn't you write a convenience to "subscribeAndRunIfSet" ? (-Alex) // Unfortunately not yet! if (value != null) { onEvent(new BasicSensorEvent(sourceSensor, producer, value, -1)); } } } }
From source file:com.eucalyptus.component.ServiceConfigurations.java
public static <T extends ServiceConfiguration> List<ServiceConfiguration> list() throws PersistenceException { Predicate<ServiceConfiguration> alwaysTrue = Predicates.alwaysTrue(); return Lists.newArrayList(filter(alwaysTrue)); }
From source file:lab.meals.Meals.java
private Predicate<Meal> determineFilter(Set<String> ingredients) { Predicate<Meal> filter = Predicates.alwaysTrue(); if (ingredients != null && !ingredients.isEmpty()) { filter = new IngredientFilter(ingredients); }/* w w w. j a v a2s .c o m*/ return filter; }
From source file:org.eclipse.sirius.diagram.ui.tools.internal.actions.layout.AbstractCopyPasteLayoutAction.java
/** * Indicates if the given ddiagram is allowing copy/paste layout. * //from www. j a v a2 s.co m * @param diagram * the diagram to inspect * @return true if the given ddiagram is allowing copy/paste layout actions, * false otherwise */ public static Predicate<DSemanticDecorator> allowsCopyPasteLayout(DDiagram diagram) { // default return value is true (for basic DDiagram that are not handled // by any DiagramDescriptionProvider). Predicate<DSemanticDecorator> result = Predicates.alwaysTrue(); // If an aird has been opened from the Package Explorer View, then // we return false as no diagram is associated to this editor if (diagram == null || diagram.getDescription() == null) { return Predicates.alwaysFalse(); } // If diagram is not null, we search for a possible // DiagramDescriptionProvider handling this type of diagram for (final IDiagramTypeDescriptor diagramTypeDescriptor : DiagramTypeDescriptorRegistry.getInstance() .getAllDiagramTypeDescriptors()) { if (diagramTypeDescriptor.getDiagramDescriptionProvider() .handles(diagram.getDescription().eClass().getEPackage())) { // This DiagramDescriptionProvider may forbid copy/paste layout. final IDiagramDescriptionProvider provider = diagramTypeDescriptor.getDiagramDescriptionProvider(); result = new Predicate<DSemanticDecorator>() { @Override public boolean apply(DSemanticDecorator input) { return provider.allowsCopyPasteLayout(input); } }; break; } } return result; }
From source file:org.eclipse.sirius.diagram.ui.tools.internal.actions.layout.AbstractCopyPasteFormatAction.java
/** * Indicates if the given ddiagram is allowing copy/paste format. * //from w w w . j a v a 2s. c o m * @param diagram * the diagram to inspect * @return true if the given ddiagram is allowing copy/paste format actions, * false otherwise */ public static Predicate<DSemanticDecorator> allowsCopyPasteFormat(DDiagram diagram) { // default return value is true (for basic DDiagram that are not handled // by any DiagramDescriptionProvider). Predicate<DSemanticDecorator> result = Predicates.alwaysTrue(); // If an aird has been opened from the Package Explorer View, then // we return false as no diagram is associated to this editor if (diagram == null || diagram.getDescription() == null) { return Predicates.alwaysFalse(); } // If diagram is not null, we search for a possible // DiagramDescriptionProvider handling this type of diagram for (final IDiagramTypeDescriptor diagramTypeDescriptor : DiagramTypeDescriptorRegistry.getInstance() .getAllDiagramTypeDescriptors()) { if (diagramTypeDescriptor.getDiagramDescriptionProvider() .handles(diagram.getDescription().eClass().getEPackage())) { // This DiagramDescriptionProvider may forbid copy/paste format. final IDiagramDescriptionProvider provider = diagramTypeDescriptor.getDiagramDescriptionProvider(); result = new Predicate<DSemanticDecorator>() { @Override public boolean apply(DSemanticDecorator input) { return provider.allowsCopyPasteFormat(input); } }; break; } } return result; }
From source file:net.automatalib.util.automata.copy.AutomatonLowLevelCopy.java
/** * Copies an {@link Automaton} to a {@link MutableAutomaton} with possibly heterogeneous input alphabets and * state and transition properties. State and transitions will not be filtered. * //from ww w .j av a 2 s. c o m * @param <S1> input automaton state type * @param <I1> input automaton input symbol type * @param <T1> input automaton transition type * @param <S2> output automaton state type * @param <I2> output automaton input symbol type * @param <T2> output automaton transition type * @param <SP2> output automaton state property type * @param <TP2> output automaton transition property type * @param method the copy method to use * @param in the input automaton * @param inputs the inputs to consider * @param out the output automaton * @param inputsMapping the transformation for input symbols * @param spMapping the function for obtaining state properties * @param tpMapping the function for obtaining transition properties * @return a mapping from old to new states */ public static <S1, I1, T1, S2, I2, T2, SP2, TP2> Mapping<S1, S2> rawCopy(AutomatonCopyMethod method, Automaton<S1, ? super I1, T1> in, Collection<? extends I1> inputs, MutableAutomaton<S2, I2, T2, ? super SP2, ? super TP2> out, Function<? super I1, ? extends I2> inputsMapping, Function<? super S1, ? extends SP2> spMapping, Function<? super T1, ? extends TP2> tpMapping) { return rawCopy(method, in, inputs, out, inputsMapping, spMapping, tpMapping, Predicates.alwaysTrue(), TransitionPredicates.alwaysTrue()); }
From source file:com.eucalyptus.autoscaling.common.internal.groups.PersistenceAutoScalingGroups.java
@Override public <T> List<T> listRequiringMonitoring(final Set<MonitoringSelector> selectors, final Function<? super AutoScalingGroup, T> transform) throws AutoScalingMetadataException { final Collection<String> suffixes = selectors.stream() .flatMap(FUtils.chain(MonitoringSelector::suffixes, Collection::stream)) .collect(Collectors.toSet()); final Junction likeAnyOf = Restrictions.disjunction(); for (final String suffix : suffixes) { likeAnyOf.add(Restrictions.ilike("id", "%" + suffix)); }/*from w ww . jav a 2s . c om*/ return persistenceSupport.listByExample(AutoScalingGroup.withOwner(null), Predicates.alwaysTrue(), likeAnyOf, Collections.<String, String>emptyMap(), transform); }
From source file:com.google.caliper.memory.ObjectGraphMeasurer.java
/** * Measures the footprint of the specified object graph. * The object graph is defined by a root object and whatever object can be * reached through that, excluding static fields, {@code Class} objects, * and fields defined in {@code enum}s (all these are considered shared * values, which should not contribute to the cost of any single object * graph)./*from ww w. j a va 2 s . com*/ * * <p>Equivalent to {@code measure(rootObject, Predicates.alwaysTrue())}. * * @param rootObject the root object of the object graph * @return the footprint of the object graph */ public static Footprint measure(Object rootObject) { return measure(rootObject, Predicates.alwaysTrue()); }
From source file:com.eucalyptus.autoscaling.common.internal.instances.PersistenceAutoScalingInstances.java
@Override public <T> List<T> listUnhealthyByGroup(final AutoScalingGroupMetadata group, final Function<? super AutoScalingInstance, T> transform) throws AutoScalingMetadataException { final AutoScalingInstance example = exampleForGroup(group); example.setHealthStatus(HealthStatus.Unhealthy); return persistenceSupport.listByExample(example, Predicates.alwaysTrue(), transform); }
From source file:com.eucalyptus.autoscaling.common.internal.activities.PersistenceScalingActivities.java
@Override public <T> List<T> listByActivityStatusCode(@Nullable final OwnerFullName ownerFullName, @Nonnull final Collection<ActivityStatusCode> statusCodes, @Nonnull final Function<? super ScalingActivity, T> transform) throws AutoScalingMetadataException { final ScalingActivity example = ScalingActivity.withOwner(ownerFullName); final Conjunction conjunction = Restrictions.conjunction(); if (!statusCodes.isEmpty()) { conjunction.add(Restrictions.in("statusCode", statusCodes)); }/*from ww w . j ava2s . c o m*/ return persistenceSupport.listByExample(example, Predicates.alwaysTrue(), conjunction, Collections.<String, String>emptyMap(), transform); }