Search in sources :

Example 66 with Predicate

use of com.google.common.base.Predicate in project selenium-tests by Wikia.

the class DeleteDialog method confirmAndWait.

public void confirmAndWait() {
    super.clickConfirm();
    new WebDriverWait(driver, DiscussionsConstants.TIMEOUT).until((Predicate<WebDriver>) input -> postList.stream().allMatch(p -> p.getAttribute("class").contains("is-deleted")));
}
Also used : WebDriver(org.openqa.selenium.WebDriver) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) List(java.util.List) Predicate(com.google.common.base.Predicate) WebDriver(org.openqa.selenium.WebDriver) WebElement(org.openqa.selenium.WebElement) FindBy(org.openqa.selenium.support.FindBy) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait)

Example 67 with Predicate

use of com.google.common.base.Predicate in project core-java by SpineEventEngine.

the class Commands method wereAfter.

/**
     * Creates a predicate for filtering commands created after the passed timestamp.
     */
public static Predicate<Command> wereAfter(final Timestamp from) {
    checkNotNull(from);
    return new Predicate<Command>() {

        @Override
        public boolean apply(@Nullable Command request) {
            checkNotNull(request);
            final Timestamp timestamp = getTimestamp(request);
            return Timestamps2.isLaterThan(timestamp, from);
        }
    };
}
Also used : Timestamp(com.google.protobuf.Timestamp) Nullable(javax.annotation.Nullable) Predicate(com.google.common.base.Predicate)

Example 68 with Predicate

use of com.google.common.base.Predicate in project intellij-community by JetBrains.

the class RepositoryLibrarySupport method addSupport.

public void addSupport(@NotNull Module module, @NotNull final ModifiableRootModel rootModel, @NotNull ModifiableModelsProvider modifiableModelsProvider) {
    LibraryTable.ModifiableModel modifiableModel = modifiableModelsProvider.getLibraryTableModifiableModel(module.getProject());
    Library library = Iterables.find(Arrays.asList(modifiableModel.getLibraries()), new Predicate<Library>() {

        @Override
        public boolean apply(@Nullable Library library) {
            return isLibraryEqualsToSelected(library);
        }
    }, null);
    if (library == null) {
        library = createNewLibrary(module, modifiableModel);
    } else {
        modifiableModelsProvider.disposeLibraryTableModifiableModel(modifiableModel);
    }
    final DependencyScope dependencyScope = LibraryDependencyScopeSuggester.getDefaultScope(library);
    final ModifiableRootModel moduleModifiableModel = modifiableModelsProvider.getModuleModifiableModel(module);
    LibraryOrderEntry foundEntry = (LibraryOrderEntry) Iterables.find(Arrays.asList(moduleModifiableModel.getOrderEntries()), new Predicate<OrderEntry>() {

        @Override
        public boolean apply(@Nullable OrderEntry entry) {
            return entry instanceof LibraryOrderEntry && ((LibraryOrderEntry) entry).getScope() == dependencyScope && isLibraryEqualsToSelected(((LibraryOrderEntry) entry).getLibrary());
        }
    }, null);
    modifiableModelsProvider.disposeModuleModifiableModel(moduleModifiableModel);
    if (foundEntry == null) {
        rootModel.addLibraryEntry(library).setScope(dependencyScope);
    }
}
Also used : LibraryTable(com.intellij.openapi.roots.libraries.LibraryTable) Library(com.intellij.openapi.roots.libraries.Library) Nullable(org.jetbrains.annotations.Nullable) Predicate(com.google.common.base.Predicate)

Example 69 with Predicate

use of com.google.common.base.Predicate in project libresonic by Libresonic.

the class ITunesParser method parsePlaylists.

private List<ITunesPlaylist> parsePlaylists() throws Exception {
    List<ITunesPlaylist> playlists = new ArrayList<ITunesPlaylist>();
    InputStream in = new FileInputStream(iTunesXml);
    try {
        ITunesPlaylist playlist = null;
        XMLStreamReader streamReader = inputFactory.createXMLStreamReader(in);
        while (streamReader.hasNext()) {
            int code = streamReader.next();
            if (code == XMLStreamReader.START_ELEMENT) {
                String key = readKey(streamReader);
                if ("Playlist ID".equals(key)) {
                    playlist = new ITunesPlaylist(readNextTag(streamReader));
                    playlists.add(playlist);
                }
                if (playlist != null) {
                    if ("Name".equals(key)) {
                        playlist.name = readNextTag(streamReader);
                    } else if ("Smart Info".equals(key)) {
                        playlist.smart = true;
                    } else if ("Visible".equals(key)) {
                        playlist.visible = false;
                    } else if ("Distinguished Kind".equals(key)) {
                        playlist.distinguishedKind = readNextTag(streamReader);
                    } else if ("Track ID".equals(key)) {
                        playlist.trackIds.add(readNextTag(streamReader));
                    }
                }
            }
        }
    } finally {
        IOUtils.closeQuietly(in);
    }
    return Lists.newArrayList(Iterables.filter(playlists, new Predicate<ITunesPlaylist>() {

        @Override
        public boolean apply(ITunesPlaylist input) {
            return input.isIncluded();
        }
    }));
}
Also used : XMLStreamReader(javax.xml.stream.XMLStreamReader) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) FileInputStream(java.io.FileInputStream) Predicate(com.google.common.base.Predicate)

Example 70 with Predicate

use of com.google.common.base.Predicate in project aic-expresso by aic-sri-international.

the class Compilation method compile.

/**
	 * Compiles an expression to a normalized (decision-tree-like) expression.
	 * @param inputExpression
	 * @param mapFromVariableNameToTypeName
	 * @param mapFromCategoricalTypeNameToSizeString
	 * @param additionalTypes
	 * @param solverListener if not null, invoked on solver used for compilation, before and after compilation starts; returned solver on 'before' invocation is used (it may be the same one used as argument, of course).
	 * @return
	 */
public static Expression compile(Expression inputExpression, Theory theory, Map<String, String> mapFromVariableNameToTypeName, Map<String, String> mapFromUniquelyNamedConstantToTypeName, Map<String, String> mapFromCategoricalTypeNameToSizeString, Collection<Type> additionalTypes, Function<MultiIndexQuantifierEliminator, MultiIndexQuantifierEliminator> solverListener) {
    // the group actually does not matter, because we are not going to have any indices.
    AssociativeCommutativeGroup group = new Max();
    // The solver for the parameters above.
    MultiIndexQuantifierEliminator solver = new SGDPLLT();
    if (solverListener != null) {
        solver = solverListener.apply(solver);
    }
    // We use the Prolog convention of small-letter initials for constants, but we need an exception for the random variables.
    Predicate<Expression> isPrologConstant = new PrologConstantPredicate();
    Predicate<Expression> isUniquelyNamedConstantPredicate = e -> isPrologConstant.apply(e) && !mapFromVariableNameToTypeName.containsKey(e);
    Map<String, String> mapFromSymbolNameToTypeName = new LinkedHashMap<>(mapFromVariableNameToTypeName);
    mapFromSymbolNameToTypeName.putAll(mapFromUniquelyNamedConstantToTypeName);
    // Solve the problem.
    // no indices; we want to keep all variables
    List<Expression> indices = Util.list();
    Expression result = solver.solve(group, inputExpression, indices, mapFromSymbolNameToTypeName, mapFromCategoricalTypeNameToSizeString, additionalTypes, isUniquelyNamedConstantPredicate, theory);
    if (solverListener != null) {
        solverListener.apply(null);
    }
    return result;
}
Also used : Type(com.sri.ai.expresso.api.Type) MultiIndexQuantifierEliminator(com.sri.ai.grinder.sgdpllt.api.MultiIndexQuantifierEliminator) SGDPLLT(com.sri.ai.grinder.sgdpllt.core.solver.SGDPLLT) Collection(java.util.Collection) Expression(com.sri.ai.expresso.api.Expression) Function(java.util.function.Function) Theory(com.sri.ai.grinder.sgdpllt.api.Theory) LinkedHashMap(java.util.LinkedHashMap) List(java.util.List) Predicate(com.google.common.base.Predicate) Max(com.sri.ai.grinder.sgdpllt.group.Max) Map(java.util.Map) Util(com.sri.ai.util.Util) AssociativeCommutativeGroup(com.sri.ai.grinder.sgdpllt.group.AssociativeCommutativeGroup) PrologConstantPredicate(com.sri.ai.grinder.core.PrologConstantPredicate) MultiIndexQuantifierEliminator(com.sri.ai.grinder.sgdpllt.api.MultiIndexQuantifierEliminator) Max(com.sri.ai.grinder.sgdpllt.group.Max) SGDPLLT(com.sri.ai.grinder.sgdpllt.core.solver.SGDPLLT) PrologConstantPredicate(com.sri.ai.grinder.core.PrologConstantPredicate) Expression(com.sri.ai.expresso.api.Expression) AssociativeCommutativeGroup(com.sri.ai.grinder.sgdpllt.group.AssociativeCommutativeGroup) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

Predicate (com.google.common.base.Predicate)217 List (java.util.List)37 Test (org.junit.Test)37 ArrayList (java.util.ArrayList)34 Nullable (javax.annotation.Nullable)33 Map (java.util.Map)24 UUID (java.util.UUID)21 IOException (java.io.IOException)20 File (java.io.File)18 HashMap (java.util.HashMap)15 Set (java.util.Set)14 Test (org.testng.annotations.Test)14 ImmutableList (com.google.common.collect.ImmutableList)13 Collection (java.util.Collection)11 DateTime (org.joda.time.DateTime)9 BigDecimal (java.math.BigDecimal)8 Path (javax.ws.rs.Path)8 Expression (com.sri.ai.expresso.api.Expression)7 Util (com.sri.ai.util.Util)7 XtextResource (org.eclipse.xtext.resource.XtextResource)7