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.github.rinde.rinsim.geom.io.Filters.java

/**
 * @return No filter, everything is included.
 */// w ww.  j a va2 s .  co m
public static Predicate<Connection<?>> noFilter() {
    return Predicates.alwaysTrue();
}

From source file:de.metas.ui.web.handlingunits.HUEditorRowFilters.java

public static Predicate<HUEditorRow> toPredicate(@NonNull final HUEditorRowFilter filter) {
    Predicate<HUEditorRow> predicate = Predicates.alwaysTrue();
    if (filter == HUEditorRowFilter.ALL) {
        return predicate;
    }/*from  www.jav a  2  s .c om*/

    // Filter by row type
    final Select rowType = filter.getSelect();
    if (rowType == Select.ALL) {
        // nothing
    } else if (rowType == Select.ONLY_TOPLEVEL) {
        predicate = predicate.and(HUEditorRow::isTopLevel);
    } else if (rowType == Select.LU) {
        predicate = predicate.and(HUEditorRow::isLU);
    } else if (rowType == Select.TU) {
        predicate = predicate.and(HUEditorRow::isTU);
    } else if (rowType == Select.CU) {
        predicate = predicate.and(HUEditorRow::isCU);
    } else {
        throw new AdempiereException("Unknown: " + rowType);
    }

    // Filter by string filter
    final String stringFilter = filter.getUserInputFilter();
    if (!Check.isEmpty(stringFilter, true)) {
        predicate = predicate.and(row -> row.matchesStringFilter(stringFilter));
    }

    // Exclude M_HU_IDs
    final ImmutableSet<HuId> excludeHUIds = filter.getExcludeHUIds();
    if (!excludeHUIds.isEmpty()) {
        predicate = predicate.and(row -> !excludeHUIds.contains(row.getHuId()));
    }

    // Include HUStatuses
    final ImmutableSet<String> onlyHUStatuses = filter.getOnlyHUStatuses();
    if (!onlyHUStatuses.isEmpty()) {
        predicate = predicate.and(row -> onlyHUStatuses.contains(row.getHUStatus()));
    }

    // Exclude HUStatuses
    final ImmutableSet<String> excludeHUStatuses = filter.getExcludeHUStatuses();
    if (!excludeHUStatuses.isEmpty()) {
        predicate = predicate.and(row -> !excludeHUStatuses.contains(row.getHUStatus()));
    }

    return predicate;
}

From source file:gov.nasa.jpf.constraints.java.ObjectConstraints.java

public static void addToValuation(String name, Object obj, Class<?> realClass, Valuation val) {
    if (realClass.isPrimitive()) {
        addPrimitiveToValuation(name, obj, val);
    } else {/*from  w ww  .j  a  v a 2  s.  c  o  m*/
        addInstanceToValuation(name, obj, Predicates.alwaysTrue(), val, new IdentityHashMap<Object, Boolean>());
    }
}

From source file:io.crate.operation.RowFilter.java

public static Predicate<Row> create(ImplementationSymbolVisitor symbolVisitor, @Nullable Symbol filterSymbol) {
    if (filterSymbol == null) {
        return Predicates.alwaysTrue();
    }//  www .  ja va  2s . com
    return new RowFilter(symbolVisitor, filterSymbol);
}

From source file:eu.lp0.cursus.scoring.scorer.FleetFilter.java

public static Predicate<Pilot> from(final Sex sex) {
    if (sex == null) {
        return Predicates.alwaysTrue();
    }//  ww w  . j  a  va  2s  .co m

    return new Predicate<Pilot>() {
        @Override
        public boolean apply(@Nonnull Pilot pilot) {
            return pilot.getSex() == sex || pilot.getSex() == null;
        }
    };
}

From source file:org.richfaces.cdk.util.MorePredicates.java

public static <S, D> Predicate<D> none(Iterable<S> options, Function<S, Predicate<D>> function) {
    if (options == null || Iterables.isEmpty(options)) {
        return Predicates.alwaysTrue();
    }/*www .jav a 2 s  . c  o  m*/

    Predicate<D> compositePredicate = Predicates.or(Iterables.transform(options, function));
    return Predicates.not(compositePredicate);
}

From source file:io.usethesource.criterion.FootprintUtils.java

public static String measureAndReport(final Object objectToMeasure, final String className, DataType dataType,
        Archetype archetype, boolean supportsStagedMutability, int size, int run,
        MemoryFootprintPreset preset) {//from   w ww . ja v a2 s . c o  m
    final Predicate<Object> predicate;

    switch (preset) {
    case DATA_STRUCTURE_OVERHEAD:
        predicate = Predicates.not(Predicates.instanceOf(JmhValue.class));
        break;
    case RETAINED_SIZE:
        predicate = Predicates.alwaysTrue();
        break;
    default:
        throw new IllegalStateException();
    }

    // System.out.println(GraphLayout.parseInstance(objectToMeasure).totalSize());

    long memoryInBytes = objectexplorer.MemoryMeasurer.measureBytes(objectToMeasure, predicate);

    Footprint memoryFootprint = objectexplorer.ObjectGraphMeasurer.measure(objectToMeasure, predicate);

    final String statString = String.format("%d\t %60s\t[%s]\t %s", memoryInBytes, className, dataType,
            memoryFootprint);
    System.out.println(statString);

    final String statFileString = String.format("%d,%d,%s,%s,%s,%b,%d,%d,%d", size, run, className, dataType,
            archetype, supportsStagedMutability, memoryInBytes, memoryFootprint.getObjects(),
            memoryFootprint.getReferences());

    return statFileString;
}

From source file:r.lang.CollectionUtils.java

public static Predicate<SEXP> modePredicate(String mode) {
    if (mode.equals("any")) {
        return Predicates.alwaysTrue();
    } else if (mode.equals("function")) {
        return IS_FUNCTION;
    } else {/*w  w w . ja  va  2  s  . co m*/
        throw new EvalException(" mode '%s' as a predicate is implemented.", mode);
    }
}

From source file:nl.cwi.swat.jmh_dscg_benchmarks.FootprintUtils.java

public static String measureAndReport(final Object objectToMeasure, final String className, DataType dataType,
        Archetype archetype, boolean supportsStagedMutability, int size, int run,
        MemoryFootprintPreset preset) {/*w  w  w  . j a v a  2 s  . c  o  m*/
    final Predicate<Object> predicate;

    switch (preset) {
    case DATA_STRUCTURE_OVERHEAD:
        predicate = Predicates.not(Predicates.instanceOf(org.eclipse.imp.pdb.facts.IValue.class));
        break;
    case RETAINED_SIZE:
        predicate = Predicates.alwaysTrue();
        break;
    default:
        throw new IllegalStateException();
    }

    // System.out.println(GraphLayout.parseInstance(objectToMeasure).totalSize());

    long memoryInBytes = objectexplorer.MemoryMeasurer.measureBytes(objectToMeasure, predicate);

    Footprint memoryFootprint = objectexplorer.ObjectGraphMeasurer.measure(objectToMeasure, predicate);

    final String statString = String.format("%d\t %60s\t[%s]\t %s", memoryInBytes, className, dataType,
            memoryFootprint);
    System.out.println(statString);

    final String statFileString = String.format("%d,%d,%s,%s,%s,%b,%d,%d,%d", size, run, className, dataType,
            archetype, supportsStagedMutability, memoryInBytes, memoryFootprint.getObjects(),
            memoryFootprint.getReferences());

    return statFileString;
}

From source file:brooklyn.rest.testing.mocks.EverythingGroupImpl.java

public EverythingGroupImpl() {
    super();
    setConfig(ENTITY_FILTER, Predicates.alwaysTrue());
}