Example usage for com.google.common.base Predicates alwaysTrue

List of usage examples for com.google.common.base Predicates alwaysTrue

Introduction

In this page you can find the example usage for com.google.common.base Predicates alwaysTrue.

Prototype

@GwtCompatible(serializable = true)
public static <T> Predicate<T> alwaysTrue() 

Source Link

Document

Returns a predicate that always evaluates to true .

Usage

From source file:org.atlasapi.equiv.EquivModule.java

@Bean
public EquivalenceUpdater<Content> contentUpdater() {

    Set<Publisher> musicPublishers = ImmutableSet.of(BBC_MUSIC, YOUTUBE, SPOTIFY, SOUNDCLOUD, RDIO, AMAZON_UK);
    Set<Publisher> roviPublishers = ImmutableSet
            .copyOf(Sets.filter(Publisher.all(), new Predicate<Publisher>() {
                @Override//from w  w w  . j  a  v a  2  s. c o m
                public boolean apply(Publisher input) {
                    return input.key().endsWith("rovicorp.com");
                }
            }));

    //Generally acceptable publishers.
    ImmutableSet<Publisher> acceptablePublishers = ImmutableSet.copyOf(Sets.difference(Publisher.all(),
            Sets.union(
                    ImmutableSet.of(PREVIEW_NETWORKS, BBC_REDUX, RADIO_TIMES, LOVEFILM, NETFLIX, YOUVIEW,
                            YOUVIEW_STAGE, YOUVIEW_BT, YOUVIEW_BT_STAGE),
                    Sets.union(musicPublishers, roviPublishers))));

    EquivalenceUpdater<Item> standardItemUpdater = standardItemUpdater(
            MoreSets.add(acceptablePublishers, LOVEFILM),
            ImmutableSet.of(new TitleMatchingItemScorer(), new SequenceItemScorer())).build();
    EquivalenceUpdater<Container> topLevelContainerUpdater = topLevelContainerUpdater(
            MoreSets.add(acceptablePublishers, LOVEFILM));

    Set<Publisher> nonStandardPublishers = ImmutableSet.copyOf(Sets.union(
            ImmutableSet.of(ITUNES, BBC_REDUX, RADIO_TIMES, FACEBOOK, LOVEFILM, NETFLIX, RTE, YOUVIEW,
                    YOUVIEW_STAGE, YOUVIEW_BT, YOUVIEW_BT_STAGE, TALK_TALK, PA, BT_VOD, BETTY),
            Sets.union(musicPublishers, roviPublishers)));
    final EquivalenceUpdaters updaters = new EquivalenceUpdaters();
    for (Publisher publisher : Iterables.filter(Publisher.all(), not(in(nonStandardPublishers)))) {
        updaters.register(publisher,
                SourceSpecificEquivalenceUpdater.builder(publisher).withItemUpdater(standardItemUpdater)
                        .withTopLevelContainerUpdater(topLevelContainerUpdater)
                        .withNonTopLevelContainerUpdater(NullEquivalenceUpdater.<Container>get()).build());
    }

    updaters.register(RADIO_TIMES,
            SourceSpecificEquivalenceUpdater.builder(RADIO_TIMES).withItemUpdater(rtItemEquivalenceUpdater())
                    .withTopLevelContainerUpdater(NullEquivalenceUpdater.<Container>get())
                    .withNonTopLevelContainerUpdater(NullEquivalenceUpdater.<Container>get()).build());

    registerYouViewUpdaterForPublisher(YOUVIEW,
            Sets.union(Sets.difference(acceptablePublishers, ImmutableSet.of(YOUVIEW_STAGE)),
                    ImmutableSet.of(YOUVIEW)),
            updaters);

    registerYouViewUpdaterForPublisher(YOUVIEW_STAGE,
            Sets.union(Sets.difference(acceptablePublishers, ImmutableSet.of(YOUVIEW)),
                    ImmutableSet.of(YOUVIEW_STAGE)),
            updaters);

    registerYouViewUpdaterForPublisher(YOUVIEW_BT,
            Sets.union(Sets.difference(acceptablePublishers, ImmutableSet.of(YOUVIEW_BT_STAGE)),
                    ImmutableSet.of(YOUVIEW_BT)),
            updaters);

    registerYouViewUpdaterForPublisher(YOUVIEW_BT_STAGE,
            Sets.union(Sets.difference(acceptablePublishers, ImmutableSet.of(YOUVIEW_BT)),
                    ImmutableSet.of(YOUVIEW_BT_STAGE)),
            updaters);

    registerYouViewUpdaterForPublisher(YOUVIEW_SCOTLAND_RADIO,
            Sets.union(Sets.difference(acceptablePublishers, ImmutableSet.of(YOUVIEW_SCOTLAND_RADIO_STAGE)),
                    ImmutableSet.of(YOUVIEW_SCOTLAND_RADIO)),
            updaters);

    registerYouViewUpdaterForPublisher(YOUVIEW_SCOTLAND_RADIO_STAGE,
            Sets.union(Sets.difference(acceptablePublishers, ImmutableSet.of(YOUVIEW_SCOTLAND_RADIO)),
                    ImmutableSet.of(YOUVIEW_SCOTLAND_RADIO_STAGE)),
            updaters);

    Set<Publisher> reduxPublishers = Sets.union(acceptablePublishers, ImmutableSet.of(BBC_REDUX));

    updaters.register(BBC_REDUX,
            SourceSpecificEquivalenceUpdater.builder(BBC_REDUX)
                    .withItemUpdater(broadcastItemEquivalenceUpdater(reduxPublishers, Score.nullScore(),
                            Predicates.alwaysTrue()))
                    .withTopLevelContainerUpdater(broadcastItemContainerEquivalenceUpdater(reduxPublishers))
                    .withNonTopLevelContainerUpdater(NullEquivalenceUpdater.<Container>get()).build());

    updaters.register(BETTY, SourceSpecificEquivalenceUpdater.builder(BETTY)
            .withItemUpdater(aliasIdentifiedBroadcastItemEquivalenceUpdater(ImmutableSet.of(BETTY, YOUVIEW)))
            .withTopLevelContainerUpdater(NullEquivalenceUpdater.<Container>get())
            .withNonTopLevelContainerUpdater(NullEquivalenceUpdater.<Container>get()).build());

    Set<Publisher> facebookAcceptablePublishers = Sets.union(acceptablePublishers, ImmutableSet.of(FACEBOOK));
    updaters.register(FACEBOOK, SourceSpecificEquivalenceUpdater.builder(FACEBOOK)
            .withItemUpdater(NullEquivalenceUpdater.<Item>get())
            .withTopLevelContainerUpdater(facebookContainerEquivalenceUpdater(facebookAcceptablePublishers))
            .withNonTopLevelContainerUpdater(NullEquivalenceUpdater.<Container>get()).build());

    updaters.register(ITUNES,
            SourceSpecificEquivalenceUpdater.builder(ITUNES)
                    .withItemUpdater(vodItemUpdater(acceptablePublishers).build())
                    .withTopLevelContainerUpdater(vodContainerUpdater(acceptablePublishers))
                    .withNonTopLevelContainerUpdater(NullEquivalenceUpdater.<Container>get()).build());

    Set<Publisher> lfPublishers = Sets.union(acceptablePublishers, ImmutableSet.of(LOVEFILM));
    updaters.register(LOVEFILM, SourceSpecificEquivalenceUpdater.builder(LOVEFILM)
            .withItemUpdater(vodItemUpdater(lfPublishers).withScorer(new SeriesSequenceItemScorer()).build())
            .withTopLevelContainerUpdater(vodContainerUpdater(lfPublishers))
            .withNonTopLevelContainerUpdater(NullEquivalenceUpdater.<Container>get()).build());

    Set<Publisher> netflixPublishers = ImmutableSet.of(BBC, NETFLIX);
    updaters.register(NETFLIX,
            SourceSpecificEquivalenceUpdater.builder(NETFLIX)
                    .withItemUpdater(vodItemUpdater(netflixPublishers).build())
                    .withTopLevelContainerUpdater(vodContainerUpdater(netflixPublishers))
                    .withNonTopLevelContainerUpdater(NullEquivalenceUpdater.<Container>get()).build());

    Set<Publisher> rtePublishers = ImmutableSet.of(PA);
    updaters.register(RTE,
            SourceSpecificEquivalenceUpdater.builder(RTE)
                    .withTopLevelContainerUpdater(vodContainerUpdater(rtePublishers))
                    .withItemUpdater(NullEquivalenceUpdater.<Item>get())
                    .withNonTopLevelContainerUpdater(NullEquivalenceUpdater.<Container>get()).build());

    updaters.register(TALK_TALK,
            SourceSpecificEquivalenceUpdater.builder(TALK_TALK)
                    .withItemUpdater(vodItemUpdater(acceptablePublishers).build())
                    .withTopLevelContainerUpdater(vodContainerUpdater(acceptablePublishers))
                    .withNonTopLevelContainerUpdater(vodSeriesUpdater(acceptablePublishers)).build());

    Set<Publisher> btVodPublishers = ImmutableSet.of(PA);
    updaters.register(BT_VOD, SourceSpecificEquivalenceUpdater.builder(BT_VOD)
            .withItemUpdater(vodItemUpdater(btVodPublishers).withScorer(new SeriesSequenceItemScorer()).build())
            .withTopLevelContainerUpdater(vodContainerUpdater(btVodPublishers))
            .withNonTopLevelContainerUpdater(vodSeriesUpdater(btVodPublishers)).build());

    Set<Publisher> itunesAndMusicPublishers = Sets.union(musicPublishers, ImmutableSet.of(ITUNES));
    ContentEquivalenceUpdater<Item> muiscPublisherUpdater = ContentEquivalenceUpdater.<Item>builder()
            .withGenerator(new TitleSearchGenerator<Item>(searchResolver, Song.class, itunesAndMusicPublishers,
                    new SongTitleTransform(), 100))
            .withScorer(new CrewMemberScorer(new SongCrewMemberExtractor()))
            .withCombiner(new NullScoreAwareAveragingCombiner<Item>()).withFilter(AlwaysTrueFilter.<Item>get())
            .withExtractor(new MusicEquivalenceExtractor())
            .withHandler(new BroadcastingEquivalenceResultHandler<Item>(ImmutableList.of(
                    EpisodeFilteringEquivalenceResultHandler.relaxed(
                            new LookupWritingEquivalenceHandler<Item>(lookupWriter, itunesAndMusicPublishers),
                            equivSummaryStore),
                    new ResultWritingEquivalenceHandler<Item>(equivalenceResultStore()),
                    new EquivalenceSummaryWritingHandler<Item>(equivSummaryStore))))
            .build();

    for (Publisher publisher : musicPublishers) {
        updaters.register(publisher,
                SourceSpecificEquivalenceUpdater.builder(publisher).withItemUpdater(muiscPublisherUpdater)
                        .withTopLevelContainerUpdater(NullEquivalenceUpdater.<Container>get())
                        .withNonTopLevelContainerUpdater(NullEquivalenceUpdater.<Container>get()).build());
    }

    ImmutableSet<Publisher> roviMatchPublishers = ImmutableSet.of(Publisher.BBC, Publisher.PA,
            Publisher.YOUVIEW, Publisher.BBC_NITRO, Publisher.BBC_REDUX, Publisher.ITV, Publisher.C4,
            Publisher.C4_PMLSD, Publisher.C4_PMLSD_P06, Publisher.FIVE);
    updaters.register(Publisher.ROVI_EN_GB, roviUpdater(Publisher.ROVI_EN_GB, roviMatchPublishers));
    updaters.register(Publisher.ROVI_EN_US, roviUpdater(Publisher.ROVI_EN_US, roviMatchPublishers));

    return updaters;
}

From source file:org.jenkinsci.plugins.workflow.pipelinegraphanalysis.StatusAndTiming.java

/**
 * Helper, prints flow graph in some detail - now a common utility so others don't have to reinvent it
 * @param run//  ww  w .j  a v a  2s.co m
 * @param showTiming
 * @param showActions
 */
@Restricted(DoNotUse.class)
public static void printNodes(@Nonnull WorkflowRun run, boolean showTiming, boolean showActions) {
    long runStartTime = run.getStartTimeInMillis();
    FlowExecution exec = run.getExecution();
    if (exec == null) {
        return;
    }
    DepthFirstScanner scanner = new DepthFirstScanner();
    List<FlowNode> sorted = scanner.filteredNodes(exec.getCurrentHeads(), (Predicate) Predicates.alwaysTrue());
    Collections.sort(sorted, new Comparator<FlowNode>() {
        @Override
        public int compare(FlowNode node1, FlowNode node2) {
            int node1Iota = parseIota(node1);
            int node2Iota = parseIota(node2);

            if (node1Iota < node2Iota) {
                return -1;
            } else if (node1Iota > node2Iota) {
                return 1;
            }
            return 0;
        }

        private int parseIota(FlowNode node) {
            try {
                return Integer.parseInt(node.getId());
            } catch (NumberFormatException e) {
                return 0;
            }
        }
    });
    System.out.println("Node dump follows, format:");
    System.out.println(
            "[ID]{parent,ids}(millisSinceStartOfRun) flowNodeClassName stepDisplayName [st=startId if a block end node]");
    System.out.println("Action format: ");
    System.out.println("\t- actionClassName actionDisplayName");
    System.out.println(
            "------------------------------------------------------------------------------------------");
    for (FlowNode node : sorted) {
        StringBuilder formatted = new StringBuilder();
        formatted.append('[').append(node.getId()).append(']');
        formatted.append('{').append(StringUtils.join(node.getParentIds(), ',')).append('}');
        if (showTiming) {
            formatted.append('(');
            if (node.getAction(TimingAction.class) != null) {
                formatted.append(TimingAction.getStartTime(node) - runStartTime);
            } else {
                formatted.append("N/A");
            }
            formatted.append(')');
        }
        formatted.append(node.getClass().getSimpleName()).append(' ').append(node.getDisplayName());
        if (node instanceof BlockEndNode) {
            formatted.append("  [st=").append(((BlockEndNode) node).getStartNode().getId()).append(']');
        }
        if (showActions) {
            for (Action a : node.getActions()) {
                if (!(a instanceof TimingAction)) {
                    formatted.append("\n  -").append(a.getClass().getSimpleName()).append(' ')
                            .append(a.getDisplayName());
                }
            }
        }
        System.out.println(formatted);
    }
    System.out.println(
            "------------------------------------------------------------------------------------------");
}

From source file:org.apache.brooklyn.core.objs.ConstraintSerialization.java

private <T> Predicate<?> and(Iterable<Predicate<? super T>> preds) {
    Iterator<Predicate<? super T>> pi = preds.iterator();
    if (!pi.hasNext())
        return Predicates.alwaysTrue();
    Predicate<?> first = pi.next();
    if (!pi.hasNext())
        return first;
    return Predicates.and(preds);
}

From source file:org.apache.aurora.scheduler.thrift.ReadOnlySchedulerImpl.java

private Map<IJobKey, IJobConfiguration> getJobs(Optional<String> ownerRole,
        Multimap<IJobKey, IScheduledTask> tasks) {

    // We need to synthesize the JobConfiguration from the the current tasks because the
    // ImmediateJobManager doesn't store jobs directly and ImmediateJobManager#getJobs always
    // returns an empty Collection.
    Map<IJobKey, IJobConfiguration> jobs = Maps.newHashMap();

    jobs.putAll(Maps.transformEntries(tasks.asMap(), (jobKey, tasks1) -> {

        // Pick the latest transitioned task for each immediate job since the job can be in the
        // middle of an update or some shards have been selectively created.
        TaskConfig mostRecentTaskConfig = Tasks.getLatestActiveTask(tasks1).getAssignedTask().getTask()
                .newBuilder();//w w w. j a  v  a2s .  c o  m

        return IJobConfiguration.build(
                new JobConfiguration().setKey(jobKey.newBuilder()).setOwner(mostRecentTaskConfig.getOwner())
                        .setTaskConfig(mostRecentTaskConfig).setInstanceCount(tasks1.size()));
    }));

    // Get cron jobs directly from the manager. Do this after querying the task store so the real
    // template JobConfiguration for a cron job will overwrite the synthesized one that could have
    // been created above.
    Predicate<IJobConfiguration> configFilter = ownerRole.isPresent()
            ? Predicates.compose(Predicates.equalTo(ownerRole.get()), JobKeys::getRole)
            : Predicates.alwaysTrue();
    jobs.putAll(Maps.uniqueIndex(FluentIterable.from(Storage.Util.fetchCronJobs(storage)).filter(configFilter),
            IJobConfiguration::getKey));

    return jobs;
}

From source file:net.automatalib.util.automata.copy.AutomatonLowLevelCopy.java

/**
 * Copies a {@link UniversalAutomaton} with compatible input alphabets and properties. States and transitions
 * will not be filtered.//from www.j a  v a 2 s.  c om
 * 
 * @param <S1> input automaton state type
 * @param <I> 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 <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
 * @return a mapping from old to new states.
 */
public static <S1, I, T1, SP, TP, S2, T2> Mapping<S1, S2> copy(AutomatonCopyMethod method,
        UniversalAutomaton<S1, ? super I, T1, ? extends SP, ? extends TP> in, Collection<? extends I> inputs,
        MutableAutomaton<S2, I, T2, ? super SP, ? super TP> out) {
    return copy(method, in, inputs, out, Predicates.alwaysTrue(), TransitionPredicates.alwaysTrue());
}

From source file:net.sourceforge.fenixedu.presentationTier.Action.candidacy.secondCycle.SecondCycleCandidacyProcessDA.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  ww  w.  j av a 2s .  c om*/
        return new Predicate<IndividualCandidacyProcess>() {
            @Override
            public boolean apply(IndividualCandidacyProcess process) {
                return ((SecondCycleIndividualCandidacyProcess) process).getCandidacy().getSelectedDegreesSet()
                        .contains(selectedDegree);
            }
        };
    }
}

From source file:org.locationtech.geogig.geotools.data.reader.FeatureReaderBuilder.java

private Predicate<Bounded> resolveNodeRefFilter() {
    Predicate<Bounded> predicate = Predicates.alwaysTrue();
    final boolean ignore = Boolean.getBoolean("geogig.ignorescreenmap");
    if (screenMap != null && !ignore) {
        predicate = new ScreenMapPredicate(screenMap);
    }/* w w  w.  jav a 2s.  c o  m*/
    return predicate;
}

From source file:brooklyn.location.jclouds.JcloudsLocation.java

protected MachineMetadata getMachineMetadata(ComputeMetadata node) {
    if (node == null)
        return null;
    return new BasicMachineMetadata(node.getId(), node.getName(),
            ((node instanceof NodeMetadata)
                    ? Iterators.tryFind(((NodeMetadata) node).getPublicAddresses().iterator(),
                            Predicates.alwaysTrue()).orNull()
                    : null),//w  ww  .ja va  2  s.  c  om
            ((node instanceof NodeMetadata) ? ((NodeMetadata) node).getStatus() == Status.RUNNING : null),
            node);
}

From source file:org.fenixedu.academic.ui.struts.action.candidacy.degreeChange.DegreeChangeCandidacyProcessDA.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 a2 s. c  o  m*/
        return new Predicate<IndividualCandidacyProcess>() {
            @Override
            public boolean apply(IndividualCandidacyProcess process) {
                return ((DegreeChangeIndividualCandidacyProcess) process).getCandidacy()
                        .getSelectedDegree() == selectedDegree;
            }
        };
    }
}

From source file:io.crate.test.integration.CrateTestCluster.java

/**
 * Returns a reference to the given nodes instances of the given class &gt;T&lt;
 *//*from   ww  w  .  j a  v  a  2  s . c  om*/
public synchronized <T> T getInstance(Class<T> clazz, final String node) {
    final Predicate<CrateTestCluster.NodeAndClient> predicate;
    if (node != null) {
        predicate = new Predicate<CrateTestCluster.NodeAndClient>() {
            public boolean apply(NodeAndClient nodeAndClient) {
                return node.equals(nodeAndClient.name);
            }
        };
    } else {
        predicate = Predicates.alwaysTrue();
    }
    NodeAndClient randomNodeAndClient = getRandomNodeAndClient(predicate);
    assert randomNodeAndClient != null;
    return getInstanceFromNode(clazz, randomNodeAndClient.node);
}