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:com.replaymod.replaystudio.collection.PacketList.java

/**
 * Creates a new list containing the specified packet data.
 * @param from Iterable of packet data/*from  w  w  w .j av a2 s  . c  om*/
 * @throws java.lang.IllegalArgumentException If the iterable contains packets in an invalid order.
 */
public PacketList(Iterable<PacketData> from) {
    this(from, Predicates.alwaysTrue());
}

From source file:com.eucalyptus.entities.AbstractPersistentSupport.java

public <T> T lookupByName(@Nullable final OwnerFullName ownerFullName, final String name,
        final Function<? super AP, T> transform) throws PE {
    return lookupByName(ownerFullName, name, Predicates.alwaysTrue(), transform);
}

From source file:nl.mvdr.umvc3replayanalyser.model.predicate.MatchReplayPredicate.java

/**
 * Constructor.//www.  j a va2 s.  c  o  m
 * 
 * @param prefix
 *            prefix to be matched to the player's gamertag; may not be null
 * @param character1
 *            character 1
 * @param assist1
 *            assist type for character 1
 * @param character2
 *            character 2
 * @param assist2
 *            assist type for character 2
 * @param character3
 *            character 3
 * @param assist3
 *            assist type for character 3
 * @param maintainCharacterOrder
 *            whether character order needs to be respected when matching against a team
 * @param side
 *            side; may not be null
 */
public MatchReplayPredicate(String prefix, Umvc3Character character1, AssistType assist1,
        Umvc3Character character2, AssistType assist2, Umvc3Character character3, AssistType assist3,
        boolean maintainCharacterOrder, @NonNull Side side) {
    super();

    if ("".equals(prefix)) {
        this.playerPredicate = Predicates.alwaysTrue();
    } else {
        this.playerPredicate = new GamertagPrefixPlayerPredicate(prefix);
    }

    if (character1 == null && character2 == null && character3 == null) {
        this.teamPredicate = Predicates.alwaysTrue();
    } else {
        this.teamPredicate = new MatchTeamPredicate(character1, assist1, character2, assist2, character3,
                assist3, maintainCharacterOrder);
    }
    this.side = side;
}

From source file:com.rockhoppertech.music.examples.Guava.java

public static void composed() {
    MIDITrack track = MIDITrackBuilder.create().noteString("C D E F G").sequential().build();

    AddFunction function = new AddFunction(1);
    Predicate<MIDINote> p = Predicates.compose(Predicates.alwaysTrue(), function);
    ImmutableList<MIDINote> notes = FluentIterable.from(track).filter(p).toList();
    for (MIDINote note : notes) {
        System.err.println(note);
    }/* ww w. j av  a2s  .c om*/

    track = MIDITrackBuilder.create().noteString("C D E F G").sequential().build();
    p = new PitchGreaterThanPredicate(Pitch.E5);
    notes = FluentIterable.from(track).filter(p).toList();
    System.err.println("gt");
    for (MIDINote note : notes) {
        System.err.println(note);
    }

    track = MIDITrackBuilder.create().noteString("C D E F G").sequential().build();
    PitchFunction pf = new PitchFunction(Operation.ADD, 1);
    p = Predicates.compose(new PitchGreaterThanPredicate(Pitch.E5), pf);
    notes = FluentIterable.from(track).filter(p).toList();
    System.err.println("gt add");
    for (MIDINote note : notes) {
        System.err.println(note);
    }

    Function<Timed, Timed> startAndDur = Functions.compose(new DurationFunction(Operation.SET, Duration.S),
            new StartTimeFunction(Operation.ADD, 1d));
    track = MIDITrackBuilder.create().noteString("C D E F G").sequential().build();
    // they are actually MIDINotes
    ImmutableList<Timed> times = FluentIterable.from(track).transform(startAndDur).toList();
    System.err.println("start and dur");
    for (Timed note : times) {
        System.err.println(note);
    }

}

From source file:org.apache.druid.storage.cassandra.CassandraDataSegmentPuller.java

FileUtils.FileCopyResult getSegmentFiles(final String key, final File outDir) throws SegmentLoadingException {
    log.info("Pulling index from C* at path[%s] to outDir[%s]", key, outDir);
    try {//from  w  ww.jav a 2 s .com
        org.apache.commons.io.FileUtils.forceMkdir(outDir);
    } catch (IOException e) {
        throw new SegmentLoadingException(e, "");
    }

    long startTime = System.currentTimeMillis();
    final File tmpFile = new File(outDir, "index.zip");
    log.info("Pulling to temporary local cache [%s]", tmpFile.getAbsolutePath());

    final FileUtils.FileCopyResult localResult;
    try {
        localResult = RetryUtils.retry(() -> {
            try (OutputStream os = new FileOutputStream(tmpFile)) {
                ChunkedStorage.newReader(indexStorage, key, os).withBatchSize(BATCH_SIZE)
                        .withConcurrencyLevel(CONCURRENCY).call();
            }
            return new FileUtils.FileCopyResult(tmpFile);
        }, Predicates.alwaysTrue(), 10);
    } catch (Exception e) {
        throw new SegmentLoadingException(e, "Unable to copy key [%s] to file [%s]", key,
                tmpFile.getAbsolutePath());
    }
    try {
        final FileUtils.FileCopyResult result = CompressionUtils.unzip(tmpFile, outDir);
        log.info("Pull of file[%s] completed in %,d millis (%s bytes)", key,
                System.currentTimeMillis() - startTime, result.size());
        return result;
    } catch (Exception e) {
        try {
            org.apache.commons.io.FileUtils.deleteDirectory(outDir);
        } catch (IOException e1) {
            log.error(e1, "Error clearing segment directory [%s]", outDir.getAbsolutePath());
            e.addSuppressed(e1);
        }
        throw new SegmentLoadingException(e, e.getMessage());
    } finally {
        if (!tmpFile.delete()) {
            log.warn("Could not delete cache file at [%s]", tmpFile.getAbsolutePath());
        }
    }
}

From source file:com.anathema_roguelike.main.utilities.Utils.java

public static <T> Collection<Class<? extends T>> getSubclasses(Class<T> superclass) {
    return getSubclasses(superclass, false, false, Predicates.alwaysTrue());
}

From source file:net.shibboleth.idp.profile.spring.relyingparty.saml.impl.AllowDelegationPredicateFactoryBean.java

/** {@inheritDoc} */
public Predicate<ProfileRequestContext> getObject() throws Exception {
    if (allowDelegationPredicate != null) {
        if (allowDelegation != null) {
            log.warn("Attribute 'allowDelegation' is being ignored in favor of 'allowDelegationPredicateRef'");
        }//from www . jav  a2s.  co  m
        return allowDelegationPredicate;
    } else if (allowDelegation != null) {
        if (allowDelegation) {
            return Predicates.alwaysTrue();
        } else {
            return Predicates.alwaysFalse();
        }
    } else {
        return Predicates.alwaysFalse();
    }
}

From source file:org.apache.isis.viewer.wicket.ui.components.collection.AssociatedWithActionsHelper.java

public List<ObjectAction> getAssociatedActions(final IsisSessionFactory isisSessionFactory) {

    if (collectionModel.isStandalone()) {
        return Collections.emptyList();
    }//from ww w  .j av a2s.c o  m
    final OneToManyAssociation collection = collectionModel.getCollectionMemento()
            .getCollection(isisSessionFactory.getSpecificationLoader());

    final ObjectSpecification objectSpec = getObjectSpecification(isisSessionFactory);

    final List<ActionType> actionTypes = inferActionTypes(isisSessionFactory);
    List<ObjectAction> objectActions = objectSpec.getObjectActions(actionTypes, Contributed.INCLUDED,
            Predicates.alwaysTrue());

    return FluentIterable.from(objectActions)
            .filter(ObjectAction.Predicates.associatedWithAndWithCollectionParameterFor(collection)).toList();
}

From source file:de.metas.ui.web.order.pricingconditions.view.PricingConditionsViewFilters.java

public static Predicate<PricingConditionsRow> isEditableRowOrMatching(final DocumentFiltersList filters) {
    if (filters.isEmpty()) {
        return Predicates.alwaysTrue();
    }//w  w w.  ja v  a  2 s. c om

    final boolean showCustomers = filters.getParamValueAsBoolean(FILTERID_IsCustomer, PARAM_IsCustomer, false);
    final boolean showVendors = filters.getParamValueAsBoolean(FILTERID_IsVendor, PARAM_IsVendor, false);
    final boolean showAll = !showCustomers && !showVendors;
    if (showAll) {
        return Predicates.alwaysTrue();
    }

    return row -> row.isEditable() || ((showCustomers && row.isCustomer()) || (showVendors && row.isVendor()));
}

From source file:io.usethesource.criterion.profiler.MemoryFootprintProfiler.java

/**
 * Run this code after a benchmark iteration finished
 *
 * @param benchmarkParams benchmark parameters used for current launch
 * @param iterationParams iteration parameters used for current launch
 * @param result iteration result//from w  w  w .  j a v a 2  s.c  o  m
 * @return profiler results
 */
@Override
public Collection<? extends Result<ProfilerResult>> afterIteration(BenchmarkParams benchmarkParams,
        IterationParams iterationParams, IterationResult result) {

    try {
        final String benchmarkClassName = benchmarkToClassName(benchmarkParams.getBenchmark());
        final Method factoryMethod = factoryMethod(benchmarkClassName);

        final JmhValue wrappedObject = (JmhValue) factoryMethod.invoke(null,
                initializeArguments(benchmarkParams));
        final Object objectToMeasure = wrappedObject.unwrap();

        final Predicate<Object> predicateDataStructureOverhead = Predicates
                .not(Predicates.instanceOf(JmhValue.class));
        final Predicate<Object> predicateRetainedSize = Predicates.alwaysTrue();

        final List<ProfilerResult> profilerResults = new ArrayList<>();

        /**
         * Traverse object graph for measuring memory footprint (in bytes).
         */
        long memoryInBytes = objectexplorer.MemoryMeasurer.measureBytes(objectToMeasure,
                predicateDataStructureOverhead);

        // NOTE: non-standard constructor for passing ResultRole.PRIMARY
        final ProfilerResult memoryResult = new ProfilerResult(ResultRole.PRIMARY, "memory", memoryInBytes,
                UNIT_BYTES, POLICY);

        // hack: substitute results
        result.resetResults();
        result.addResult(memoryResult);

        //      /**
        //       * Traverse object graph for measuring field statistics.
        //       */
        //      final Footprint statistic = objectexplorer.ObjectGraphMeasurer
        //          .measure(objectToMeasure, predicateDataStructureOverhead);
        //
        //      final ProfilerResult objectsResult =
        //          new ProfilerResult("objects", statistic.getObjects(), UNIT_COUNT, POLICY);
        //      profilerResults.add(objectsResult);
        //
        //      final ProfilerResult referencesResult =
        //          new ProfilerResult("references", statistic.getReferences(), UNIT_COUNT, POLICY);
        //      profilerResults.add(referencesResult);
        //
        //      final ProfilerResult primitivesResult =
        //          new ProfilerResult("primitives", statistic.getPrimitives().size(), UNIT_COUNT, POLICY);
        //      profilerResults.add(primitivesResult);

        return profilerResults;
    } catch (Exception e) {
        e.printStackTrace();
        return Arrays.asList();
    }
}