List of usage examples for com.google.common.base Predicates alwaysTrue
@GwtCompatible(serializable = true) public static <T> Predicate<T> alwaysTrue()
From source file:xml.entity.select.DefaultSelector.java
@Override public DSL.Select createSelect(final ImmutableElement element) { return new DSL.Select() { @Override/*from www .j av a 2 s . c om*/ public NodeSelection from(final String path) { final Path parsed = DefaultSelector.this.pathParser.parse(path); final Predicate<ImmutableElement> expr = Predicates.alwaysTrue(); return new NodeSelectImpl(DefaultSelector.this, element, parsed, expr); } }; }
From source file:xml.entity.select.DefaultSelector.java
@Override @Nonnull//w w w.ja v a 2 s . co m public DSL.Insert createInsert(@Nonnull final ImmutableElement element) { return new Insert() { @Override public InsertInto into(final String path) { final Path parse = DefaultSelector.this.pathParser.parse(path); final ImmutableList<ImmutableElement> nodes = ImmutableList.of(); final Predicate<ImmutableElement> expr = Predicates.alwaysTrue(); return new InsertIntoImpl(element, parse, nodes, expr, ExpectedMatches.any()); } }; }
From source file:net.automatalib.util.ts.copy.TSCopy.java
/** * Copies a {@link UniversalAutomaton} with possibly heterogeneous input alphabets, but compatible properties. States and * transitions will not be filtered//from www .j a v a2 s .com * * @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 * @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(TSTraversalMethod method, UniversalTransitionSystem<S1, ? super I1, T1, ? extends SP, ? extends TP> in, int limit, Collection<? extends I1> inputs, MutableAutomaton<S2, I2, T2, ? super SP, ? super TP> out, Function<? super I1, ? extends I2> inputsMapping) { return copy(method, in, limit, inputs, out, inputsMapping, Predicates.alwaysTrue(), TransitionPredicates.alwaysTrue()); }
From source file:net.automatalib.util.automata.copy.AutomatonLowLevelCopy.java
/** * Copies a {@link UniversalAutomaton} to a {@link MutableAutomaton} with compatible input alphabets, but possibly heterogeneous * properties. States and transitions will not be filtered. * //from ww w.ja v a2s.c o m * @param <S1> input automaton state type * @param <I> input symbol type * @param <T1> input automaton transition type * @param <SP1> input automaton state property type * @param <TP1> input automaton transition property type * @param <S2> output automaton state 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 spTransform the transformation for state properties * @param tpTransform the transformation for transition properties * @return a mapping from old to new states */ public static <S1, I, T1, SP1, TP1, S2, I2, T2, SP2, TP2> Mapping<S1, S2> copy(AutomatonCopyMethod method, UniversalAutomaton<S1, ? super I, T1, ? extends SP1, ? extends TP1> in, Collection<? extends I> inputs, MutableAutomaton<S2, I, T2, ? super SP2, ? super TP2> out, Function<? super SP1, ? extends SP2> spTransform, Function<? super TP1, ? extends TP2> tpTransform) { return copy(method, in, inputs, out, spTransform, tpTransform, Predicates.alwaysTrue(), TransitionPredicates.alwaysTrue()); }
From source file:net.sourceforge.fenixedu.presentationTier.Action.candidacy.erasmus.ErasmusCandidacyProcessDA.java
@Override protected Predicate<IndividualCandidacyProcess> getChildProcessSelectionPredicate( final CandidacyProcess process, HttpServletRequest request) { final Degree selectedDegree = getChooseDegreeBean(request).getDegree(); final MobilityProgram mobilityProgram = getChooseMobilityProgramBean(request).getMobilityProgram(); if (selectedDegree == null) { if (mobilityProgram == null) { return Predicates.alwaysTrue(); } else {//from www. j a v a 2s . co m return new Predicate<IndividualCandidacyProcess>() { @Override public boolean apply(IndividualCandidacyProcess process) { return ((MobilityIndividualApplicationProcess) process).getMobilityProgram() .equals(mobilityProgram); } }; } } else { return new Predicate<IndividualCandidacyProcess>() { @Override public boolean apply(IndividualCandidacyProcess process) { MobilityIndividualApplicationProcess mobilityProcess = (MobilityIndividualApplicationProcess) process; if (mobilityProgram != null && !mobilityProcess.getMobilityProgram().equals(mobilityProgram)) { return false; } return ((MobilityIndividualApplicationProcess) process).getCandidacy() .getSelectedDegree() == selectedDegree; } }; } }
From source file:xml.entity.select.DefaultSelector.java
@Override @Nonnull/*from www . j a v a 2s. c o m*/ public DSL.Update createUpdate(@Nonnull final ImmutableElement element) { return new Update() { @Override @Nonnull public NodeUpdate from(final String path) { final Path parsed = DefaultSelector.this.pathParser.parse(path); final Predicate<ImmutableElement> alwaysTrue = Predicates.alwaysTrue(); final ImmutableList<UpdateOperation> ops = ImmutableList.of(); return new NodeUpdateImpl(element, parsed, alwaysTrue, ops, ExpectedMatches.any()); } }; }
From source file:xml.entity.select.DefaultSelector.java
@Override @Nonnull//from w w w . jav a 2s . c om public DSL.Delete createDelete(@Nonnull final ImmutableElement element) { return new Delete() { @Override public NodeDelete from(final String path) { final Path parsed = DefaultSelector.this.pathParser.parse(path); final Predicate<ImmutableElement> expr = Predicates.alwaysTrue(); return new NodeDeleteImpl(element, parsed, expr, ExpectedMatches.any()); } }; }
From source file:forge.quest.BoosterUtils.java
/** * parseReward - used internally to parse individual items in a challenge reward definition. * @param s//w w w . j ava 2s. com * String, the reward to parse * @return List<CardPrinted> */ private static List<InventoryItem> parseReward(final String s) { String[] temp = s.split(" "); List<InventoryItem> rewards = new ArrayList<>(); // last word starts with 'rare' ignore case if (temp.length > 1 && temp[temp.length - 1].regionMatches(true, 0, "rare", 0, 4)) { // Type 1: 'n [color] rares' final int qty = Integer.parseInt(temp[0]); List<Predicate<PaperCard>> preds = new ArrayList<>(); preds.add(IPaperCard.Predicates.Presets.IS_RARE_OR_MYTHIC); // Determine rarity if (temp.length > 2) { Predicate<CardRules> cr = parseRulesLimitation(temp[1]); //noinspection RedundantCast if (Predicates.alwaysTrue() != (Object) cr) { // guava has a single instance for always-const predicates preds.add(Predicates.compose(cr, PaperCard.FN_GET_RULES)); } } if (FModel.getQuest().getFormat() != null) { preds.add(FModel.getQuest().getFormat().getFilterPrinted()); } PrintSheet ps = new PrintSheet("Quest rewards"); Predicate<PaperCard> predicate = preds.size() == 1 ? preds.get(0) : Predicates.and(preds); ps.addAll(Iterables.filter(FModel.getMagicDb().getCommonCards().getAllCards(), predicate)); rewards.addAll(ps.random(qty, true)); } else if (temp.length == 2 && temp[0].equalsIgnoreCase("duplicate") && temp[1].equalsIgnoreCase("card")) { // Type 2: a duplicate card of the players choice rewards.add(new QuestRewardCardDuplicate()); } else if (temp.length >= 2 && temp[0].equalsIgnoreCase("chosen") && temp[1].equalsIgnoreCase("card")) { // Type 3: a duplicate card of the players choice rewards.add(new QuestRewardCardFiltered(temp)); } else if (temp.length >= 3 && temp[0].equalsIgnoreCase("booster") && temp[1].equalsIgnoreCase("pack")) { // Type 4: a predetermined extra booster pack rewards.add(BoosterPack.FN_FROM_SET.apply(FModel.getMagicDb().getEditions().get(temp[2]))); } else if (temp.length >= 3 && temp[0].equalsIgnoreCase("tournament") && temp[1].equalsIgnoreCase("pack")) { // Type 5: a predetermined extra tournament ("starter") pack rewards.add(TournamentPack.FN_FROM_SET.apply(FModel.getMagicDb().getEditions().get(temp[2]))); } else if (temp.length > 0) { // default: assume we are asking for a single copy of a specific card final PaperCard specific = FModel.getMagicDb().getCommonCards().getCard(s); if (specific != null) { rewards.add(specific); } } // Return the duplicate, a specified card, or an empty list return rewards; }
From source file:org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.groups.impl.BasicDifferenceGroupImpl.java
/** * Build the sub tree of the given {@link Match}. * /*ww w .j av a 2 s .com*/ * @param match * the given Match. * @param containment * true if the current level represents a containment diff, false otherwise. * @param side * the accepted side(s) for children of current level. * @return the sub tree of the given Match. */ protected List<TreeNode> buildSubTree(Match match, boolean containment, ChildrenSide side) { final List<TreeNode> ret = Lists.newArrayList(); final Set<TreeNode> nodeChildren = newLinkedHashSet(); final Set<Match> matchOfValues = newLinkedHashSet(); final TreeNode matchTreeNode = wrap(match); if (!containment) { ret.add(matchTreeNode); } boolean hasDiff = false; for (Diff diff : filter(match.getDifferences(), and(filter, compatibleSide(side)))) { if (CONTAINMENT_REFERENCE_CHANGE.apply(diff)) { hasDiff = true; final TreeNode node; if (containment) { node = wrap(diff); ret.add(node); } else { node = buildSubTree(diff); nodeChildren.add(node); } Match matchOfValue = match.getComparison().getMatch(((ReferenceChange) diff).getValue()); if (matchOfValue != null) { matchOfValues.add(matchOfValue); node.getChildren().addAll(buildSubTree(matchOfValue, true, DIFF_TO_SIDE.apply(diff))); } if (containment) { ret.addAll(manageRefines(diff, side)); } else { nodeChildren.addAll(manageRefines(diff, side)); } } else if (!(diff instanceof ResourceAttachmentChange)) { if (diff.getPrimeRefining() != null && extensionDiffProcessed.contains(diff)) { continue; } hasDiff = true; if (containment) { ret.add(wrap(diff)); } else { nodeChildren.add(buildSubTree(diff)); } } } Collection<TreeNode> toRemove = Lists.newArrayList(); for (TreeNode treeNode : ret) { boolean hasNonEmptySubMatch = false; // SubMatches first for (Match subMatch : Sets.difference(newLinkedHashSet(match.getSubmatches()), matchOfValues)) { List<TreeNode> buildSubTree = buildSubTree(subMatch, containment, ChildrenSide.BOTH); if (!buildSubTree.isEmpty()) { hasNonEmptySubMatch = true; treeNode.getChildren().addAll(buildSubTree); } } // Differences last treeNode.getChildren().addAll(nodeChildren); if (!(containment || hasDiff || hasNonEmptySubMatch || filter.equals(Predicates.alwaysTrue()))) { toRemove.add(treeNode); } else if (!containment && isMatchWithOnlyResourceAttachmentChanges(match)) { toRemove.add(treeNode); } else if (isMatchWithProxyData(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:net.sourceforge.fenixedu.presentationTier.Action.candidacy.graduatedPerson.DegreeCandidacyForGraduatedPersonProcessDA.java
@Override protected Predicate<IndividualCandidacyProcess> getChildProcessSelectionPredicate( final CandidacyProcess process, HttpServletRequest request) { final Degree selectedDegree = getChooseDegreeBean(request).getDegree(); if (selectedDegree == null) { return Predicates.alwaysTrue(); } else {/*from w ww. j a v a 2 s.co m*/ return new Predicate<IndividualCandidacyProcess>() { @Override public boolean apply(IndividualCandidacyProcess process) { return ((DegreeCandidacyForGraduatedPersonIndividualProcess) process).getCandidacy() .getSelectedDegree() == selectedDegree; } }; } }