List of usage examples for com.google.common.base Predicates alwaysTrue
@GwtCompatible(serializable = true) public static <T> Predicate<T> alwaysTrue()
From source file:edu.uci.ics.jung.visualization.picking.ShapePickSupport.java
/** * Quick test to allow optimization of <code>getFilteredVertices()</code>. * @return <code>true</code> if there is an active vertex filtering * mechanism for this visualization, <code>false</code> otherwise */// www . j a v a2s . c o m protected boolean verticesAreFiltered() { Predicate<Context<Graph<V, E>, V>> vertexIncludePredicate = vv.getRenderContext() .getVertexIncludePredicate(); return vertexIncludePredicate != null && vertexIncludePredicate.equals(Predicates.alwaysTrue()) == false; }
From source file:com.eucalyptus.autoscaling.AutoScalingService.java
public DescribeAutoScalingGroupsResponseType describeAutoScalingGroups( final DescribeAutoScalingGroupsType request) throws EucalyptusCloudException { final DescribeAutoScalingGroupsResponseType reply = request.getReply(); //TODO: MaxRecords / NextToken support for DescribeAutoScalingGroups final Context ctx = Contexts.lookup(); final boolean showAll = request.autoScalingGroupNames().remove("verbose"); final OwnerFullName ownerFullName = ctx.hasAdministrativePrivileges() && showAll ? null : ctx.getUserFullName().asAccountFullName(); final Predicate<AutoScalingGroupMetadata> requestedAndAccessible = AutoScalingMetadatas .filterPrivilegesByIdOrArn(AutoScalingGroupMetadata.class, request.autoScalingGroupNames()); try {/*from w w w . j a v a 2 s.c o m*/ final List<AutoScalingGroupType> results = reply.getDescribeAutoScalingGroupsResult() .getAutoScalingGroups().getMember(); results.addAll(autoScalingGroups.list(ownerFullName, requestedAndAccessible, TypeMappers.lookup(AutoScalingGroup.class, AutoScalingGroupType.class))); final Map<String, List<Tag>> tagsMap = TagSupport.forResourceClass(AutoScalingGroup.class) .getResourceTagMap(ctx.getUserFullName().asAccountFullName(), Iterables.transform(results, AutoScalingGroupType.groupName()), Predicates.alwaysTrue()); for (final AutoScalingGroupType type : results) { final TagDescriptionList tags = new TagDescriptionList(); Tags.addFromTags(tags.getMember(), TagDescription.class, tagsMap.get(type.getAutoScalingGroupName())); if (!tags.getMember().isEmpty()) { type.setTags(tags); } } } catch (Exception e) { handleException(e); } return reply; }
From source file:net.automatalib.util.ts.copy.TSCopy.java
/** * Copies a {@link UniversalAutomaton} with compatible input alphabets and properties. States and transitions * will not be filtered.//www . j av a 2 s.c o m * * @param method the traversal method to use * @param in the input transition system * @param limit the traversal limit, a value less than 0 means no limit * @param inputs the inputs to consider * @param out the output automaton * @return a mapping from old to new states. */ public static <S1, I, T1, SP, TP, S2, T2> Mapping<S1, S2> copy(TSTraversalMethod method, UniversalTransitionSystem<S1, ? super I, T1, ? extends SP, ? extends TP> in, int limit, Collection<? extends I> inputs, MutableAutomaton<S2, I, T2, ? super SP, ? super TP> out) { return copy(method, in, limit, inputs, out, Predicates.alwaysTrue(), TransitionPredicates.alwaysTrue()); }
From source file:edu.uci.ics.jung.visualization.picking.ShapePickSupport.java
/** * Quick test to allow optimization of <code>getFilteredEdges()</code>. * @return <code>true</code> if there is an active edge filtering * mechanism for this visualization, <code>false</code> otherwise *//*from w w w. j av a 2 s .c o m*/ protected boolean edgesAreFiltered() { Predicate<Context<Graph<V, E>, E>> edgeIncludePredicate = vv.getRenderContext().getEdgeIncludePredicate(); return edgeIncludePredicate != null && edgeIncludePredicate.equals(Predicates.alwaysTrue()) == false; }
From source file:com.isotrol.impe3.pms.core.obj.ConnectorsObject.java
/** * Transforms the object to a protocol buffer message with no filter. * @return The PB message.//from ww w . j a va 2s.c o m */ public final ConnectorsPB toPB(FileManager fileManager) { return toPB(fileManager, Predicates.alwaysTrue()); }
From source file:org.apache.brooklyn.core.objs.ConstraintSerialization.java
private void collectPredicateListFromJson(Object o, Collection<Predicate<?>> result) { if (o instanceof Collection) { ((Collection<?>) o).stream().forEach(i -> collectPredicateListFromJson(i, result)); return;//w w w . j a va 2s . c o m } Predicate<?> p = toPredicateFromJson(o); if (Predicates.alwaysTrue().equals(p)) { // no point in keeping this one return; } result.add(p); }
From source file:org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.groups.BasicDifferenceGroupImpl.java
/** * Build the sub tree of the given {@link Match}. * /*from w w w .java2 s . c om*/ * @param parentMatch * the parent of the given Match. * @param match * the given Match. * @return the sub tree of the given Match. */ public List<TreeNode> buildSubTree(Match parentMatch, Match match) { final List<TreeNode> ret = Lists.newArrayList(); boolean isContainment = false; // Manage containment reference changes if (parentMatch != null) { Collection<Diff> containmentChanges = filter(parentMatch.getDifferences(), containmentReferenceForMatch(match)); if (!containmentChanges.isEmpty()) { isContainment = true; for (Diff diff : containmentChanges) { ret.add(wrap(diff)); EList<Diff> refines = diff.getRefines(); for (Diff refine : refines) { Diff mainDiff = refine.getPrimeRefining(); if (mainDiff != null && mainDiff == diff && !extensionDiffProcessed.contains(refine)) { TreeNode buildSubTree2 = buildSubTree(refine); if (buildSubTree2 != null) { ret.add(buildSubTree2); extensionDiffProcessed.add(refine); } } } } } } if (ret.isEmpty() && !matchWithLeftAndRightInDifferentContainer(match)) { ret.add(wrap(match)); } Collection<TreeNode> toRemove = Lists.newArrayList(); for (TreeNode treeNode : ret) { boolean hasDiff = false; boolean hasNonEmptySubMatch = false; Set<Match> alreadyProcessedSubMatch = newHashSet(); // Manage non-containment changes for (Diff diff : filter(match.getDifferences(), and(filter, not(or(containmentReferenceChange(), resourceAttachmentChange()))))) { if (diff.getPrimeRefining() != null && !extensionDiffProcessed.contains(diff)) { continue; } hasDiff = true; TreeNode buildSubTree = buildSubTree(diff); if (buildSubTree != null) { treeNode.getChildren().add(buildSubTree); } } // Manage sub matches for (Match subMatch : match.getSubmatches()) { if (!alreadyProcessedSubMatch.contains(subMatch)) { List<TreeNode> buildSubTree = buildSubTree(match, subMatch); if (!buildSubTree.isEmpty()) { hasNonEmptySubMatch = true; treeNode.getChildren().addAll(buildSubTree); } } } // Manage move changes for (Diff diff : filter(match.getDifferences(), and(filter, containmentMoveReferenceChange()))) { if (!containsChildrenWithDataEqualsToDiff(treeNode, diff)) { TreeNode buildSubTree = buildSubTree(diff); if (buildSubTree != null) { hasDiff = true; treeNode.getChildren().add(buildSubTree); List<TreeNode> matchSubTree = buildSubTree((Match) null, comparison.getMatch(((ReferenceChange) diff).getValue())); for (TreeNode matchSubTreeNode : matchSubTree) { buildSubTree.getChildren().addAll(matchSubTreeNode.getChildren()); } } } } if (!(isContainment || hasDiff || hasNonEmptySubMatch || filter.equals(Predicates.alwaysTrue()))) { toRemove.add(treeNode); } else if (!isContainment && isMatchWithOnlyResourceAttachmentChanges(match)) { toRemove.add(treeNode); } else { for (IDifferenceGroupExtender ext : registry.getExtenders()) { if (ext.handle(treeNode)) { ext.addChildren(treeNode); } } } } ret.removeAll(toRemove); return ret; }
From source file:com.eucalyptus.autoscaling.backend.AutoScalingBackendService.java
public DescribeAutoScalingGroupsResponseType describeAutoScalingGroups( final DescribeAutoScalingGroupsType request) throws EucalyptusCloudException { final DescribeAutoScalingGroupsResponseType reply = request.getReply(); //TODO: MaxRecords / NextToken support for DescribeAutoScalingGroups final Context ctx = Contexts.lookup(); final boolean showAll = request.autoScalingGroupNames().remove("verbose"); final OwnerFullName ownerFullName = ctx.isAdministrator() && showAll ? null : ctx.getUserFullName().asAccountFullName(); final Predicate<AutoScalingGroupMetadata> requestedAndAccessible = AutoScalingMetadatas .filterPrivilegesByIdOrArn(AutoScalingGroupMetadata.class, request.autoScalingGroupNames()); try {/*from w w w .j a va 2 s . co m*/ final List<AutoScalingGroupType> results = reply.getDescribeAutoScalingGroupsResult() .getAutoScalingGroups().getMember(); results.addAll(autoScalingGroups.list(ownerFullName, requestedAndAccessible, TypeMappers.lookup(AutoScalingGroup.class, AutoScalingGroupType.class))); final Map<String, List<Tag>> tagsMap = TagSupport.forResourceClass(AutoScalingGroup.class) .getResourceTagMap(ctx.getUserFullName().asAccountFullName(), Iterables.transform(results, AutoScalingGroupType.groupName()), Predicates.alwaysTrue()); for (final AutoScalingGroupType type : results) { final TagDescriptionList tags = new TagDescriptionList(); Tags.addFromTags(tags.getMember(), TagDescription.class, tagsMap.get(type.getAutoScalingGroupName())); if (!tags.getMember().isEmpty()) { type.setTags(tags); } } } catch (Exception e) { handleException(e); } return reply; }
From source file:com.palantir.atlasdb.keyvalue.impl.TieredKeyValueService.java
/** * Returns a predicate accepting only row results with row names less than or equal to the given * page token (or greater than or equal if isReversed). *///from w ww.ja v a 2s .com private Predicate<RowResult<Value>> getLimitingPredicate(final byte[] pageToken, final boolean isReversed, boolean moreAvailable) { if (!moreAvailable) { return Predicates.alwaysTrue(); } return new Predicate<RowResult<Value>>() { @Override public boolean apply(RowResult<Value> rowResult) { return compare(rowResult.getRowName(), pageToken, isReversed) <= 0; } }; }
From source file:net.automatalib.util.automata.copy.AutomatonLowLevelCopy.java
/** * Copies a {@link UniversalAutomaton} with possibly heterogeneous input alphabets, but compatible properties. States and * transitions will not be filtered// www . j a v a 2s .c o m * * @param <S1> input automaton state type * @param <I1> input automaton input symbol type * @param <T1> input automaton transition type * @param <SP> state property type * @param <TP> transition property type * @param <S2> output automaton state type * @param <I2> output automaton input symbol type * @param <T2> output automaton transition 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 a mapping from inputs in the input automaton to inputs in the output automaton * @return a mapping from old to new states */ public static <S1, I1, T1, SP, TP, S2, I2, T2> Mapping<S1, S2> copy(AutomatonCopyMethod method, UniversalAutomaton<S1, ? super I1, T1, ? extends SP, ? extends TP> in, Collection<? extends I1> inputs, MutableAutomaton<S2, I2, T2, ? super SP, ? super TP> out, Function<? super I1, ? extends I2> inputsMapping) { return copy(method, in, inputs, out, inputsMapping, Predicates.alwaysTrue(), TransitionPredicates.alwaysTrue()); }