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.jclouds.trmk.vcloud_0_8.config.DefaultVCloudReferencesModule.java

@Provides
@Singleton
@org.jclouds.trmk.vcloud_0_8.endpoints.VDC
protected Predicate<ReferenceType> provideDefaultVDCSelector(Injector i) {
    return Predicates.alwaysTrue();
}

From source file:io.crate.analyze.CopyStatementAnalyzer.java

public CopyFromAnalyzedStatement convertCopyFrom(CopyFrom node, Analysis analysis) {
    DocTableInfo tableInfo = analysisMetaData.schemas()
            .getWritableTable(TableIdent.of(node.table(), analysis.parameterContext().defaultSchema()));
    DocTableRelation tableRelation = new DocTableRelation(tableInfo);
    Operation.blockedRaiseException(tableInfo, Operation.INSERT);

    String partitionIdent = null;
    if (!node.table().partitionProperties().isEmpty()) {
        partitionIdent = PartitionPropertiesAnalyzer.toPartitionIdent(tableInfo,
                node.table().partitionProperties(), analysis.parameterContext().parameters());
    }/*  w  w  w.ja  va  2s .  c  om*/

    Context context = new Context(analysisMetaData, analysis.parameterContext(), analysis.statementContext(),
            tableRelation, Operation.INSERT);
    Predicate<DiscoveryNode> nodeFilters = Predicates.alwaysTrue();
    Settings settings = Settings.EMPTY;
    if (node.genericProperties().isPresent()) {
        // copy map as items are removed. The GenericProperties map is cached in the query cache and removing
        // items would cause subsequent queries that hit the cache to have different genericProperties
        Map<String, Expression> properties = new HashMap<>(node.genericProperties().get().properties());
        nodeFilters = discoveryNodePredicate(analysis.parameterContext().parameters(),
                properties.remove(NodeFilters.NAME));
        settings = settingsFromProperties(properties, context.expressionAnalyzer,
                context.expressionAnalysisContext);
    }
    Symbol uri = context.processExpression(node.path());

    if (!(uri.valueType() == DataTypes.STRING || uri.valueType() instanceof CollectionType
            && ((CollectionType) uri.valueType()).innerType() == DataTypes.STRING)) {
        throw CopyFromAnalyzedStatement.raiseInvalidType(uri.valueType());
    }

    return new CopyFromAnalyzedStatement(tableInfo, settings, uri, partitionIdent, nodeFilters);
}

From source file:brooklyn.entity.proxy.nginx.NginxControllerImpl.java

@Override
public void connectSensors() {
    super.connectSensors();

    ConfigToAttributes.apply(this);

    // "up" is defined as returning a valid HTTP response from nginx (including a 404 etc)
    httpFeed = addFeed(HttpFeed.builder().uniqueTag("nginx-poll").entity(this)
            .period(getConfig(HTTP_POLL_PERIOD))
            .baseUri(new UrlInferencer(ImmutableMap.of("include-runtime", "true")))
            .poll(new HttpPollConfig<Boolean>(NGINX_URL_ANSWERS_NICELY)
                    // Any response from Nginx is good.
                    .checkSuccess(Predicates.alwaysTrue()).onResult(new Function<HttpToolResponse, Boolean>() {
                        @Override
                        public Boolean apply(HttpToolResponse input) {
                            // Accept any nginx response (don't assert specific version), so that sub-classing
                            // for a custom nginx build is not strict about custom version numbers in headers
                            List<String> actual = input.getHeaderLists().get("Server");
                            return actual != null && actual.size() == 1;
                        }//from  w ww.j  a v a 2 s  . c  om
                    }).setOnException(false))
            .build());

    if (!Lifecycle.RUNNING.equals(getAttribute(SERVICE_STATE_ACTUAL))) {
        // TODO when updating the map, if it would change from empty to empty on a successful run
        // gate with the above check to prevent flashing on ON_FIRE during rebind (this is invoked on rebind as well as during start)
        ServiceNotUpLogic.updateNotUpIndicator(this, NGINX_URL_ANSWERS_NICELY, "No response from nginx yet");
    }
    addEnricher(Enrichers.builder().updatingMap(Attributes.SERVICE_NOT_UP_INDICATORS)
            .uniqueTag("not-up-unless-url-answers").from(NGINX_URL_ANSWERS_NICELY)
            .computing(Functionals.ifNotEquals(true)
                    .value("URL where nginx listens is not answering correctly (with expected header)"))
            .build());
    connectServiceUpIsRunning();

    // Can guarantee that parent/managementContext has been set
    Group urlMappings = getConfig(URL_MAPPINGS);
    if (urlMappings != null && urlMappingsMemberTrackerPolicy == null) {
        // Listen to the targets of each url-mapping changing
        targetAddressesHandler = subscribeToMembers(urlMappings, UrlMapping.TARGET_ADDRESSES,
                new SensorEventListener<Collection<String>>() {
                    @Override
                    public void onEvent(SensorEvent<Collection<String>> event) {
                        updateNeeded();
                    }
                });

        // Listen to url-mappings being added and removed
        urlMappingsMemberTrackerPolicy = addPolicy(
                PolicySpec.create(UrlMappingsMemberTrackerPolicy.class).configure("group", urlMappings));
    }
}

From source file:net.shibboleth.idp.authn.AuthenticationFlowDescriptor.java

/** Constructor. */
public AuthenticationFlowDescriptor() {
    supportsNonBrowser = true;/*from   w  w w.  j av a2 s .co  m*/
    supportedPrincipals = new Subject();
    activationCondition = Predicates.alwaysTrue();
    inactivityTimeout = 30 * 60 * 1000;
}

From source file:org.caleydo.view.bicluster.elem.NormalClusterElement.java

public NormalClusterElement(int bcNr, TablePerspective data, BiClustering clustering, double maxDimThreshold,
        double maxRecThreshold) {
    super(bcNr, data, clustering, Predicates.alwaysTrue());
    this.dimClustering = clustering.getDimClustering(bcNr);
    this.recClustering = clustering.getRecClustering(bcNr);

    this.recThreshold = Math.min(this.recThreshold, (float) maxRecThreshold);
    this.dimThreshold = Math.min(this.dimThreshold, (float) maxDimThreshold);

    this.add(createTopToolBar());
    toolBar = new ToolBar(content.createButtonBarBuilder().layoutAs(EButtonBarLayout.SLIDE_LEFT).size(16)
            .build().setSize(16, 16));/* w w w.  j  a v  a  2 s  .c  o m*/
    this.add(toolBar); // add a element toolbar
    dimThreshBar = new ThresholdBar(true);
    recThreshBar = new ThresholdBar(false);
    this.add(dimThreshBar);
    this.add(recThreshBar);

    dimThreshBar.updateSliders(clustering.getMaxAbsMembership(EDimension.DIMENSION),
            clustering.getClustering(EDimension.DIMENSION, bcNr));
    recThreshBar.updateSliders(clustering.getMaxAbsMembership(EDimension.RECORD),
            clustering.getClustering(EDimension.DIMENSION, bcNr));

    this.add(new HeatMapLabelElement(true, data.getDimensionPerspective(), content));
    this.add(new HeatMapLabelElement(false, data.getRecordPerspective(), content));

    MembershipLZHeatmapElement p = new MembershipLZHeatmapElement(EDimension.DIMENSION,
            clustering.getMaxAbsMembership(EDimension.DIMENSION));
    this.annotations.add(p);
    this.add(p);
    p = new MembershipLZHeatmapElement(EDimension.RECORD, clustering.getMaxAbsMembership(EDimension.RECORD));
    this.annotations.add(p);
    this.add(p);

    resort();
}

From source file:org.apache.brooklyn.util.core.osgi.BundleMaker.java

/** creates a ZIP in a temp file from the given classpath folder, 
 * by recursively taking everything in the referenced directories,
 * treating the given folder as the root,
 * respecting the MANIFEST.MF if present (ie putting it first so it is a valid JAR) */
public File createJarFromClasspathDir(String path) {
    File f = Os.newTempFile(path, "zip");
    ZipOutputStream zout = null;/*w ww . j av  a2  s. c  o  m*/
    try {
        if (Urls.getProtocol(path) == null) {
            // default if no URL is classpath
            path = Os.tidyPath(path);
            if (!path.startsWith("/") && optionalDefaultClassForLoading != null) {
                path = "/" + optionalDefaultClassForLoading.getPackage().getName().replace('.', '/') + "/"
                        + path;
            }
            path = "classpath:" + path;
        }

        if (resources.doesUrlExist(Urls.mergePaths(path, MANIFEST_PATH))) {
            InputStream min = resources.getResourceFromUrl(Urls.mergePaths(path, MANIFEST_PATH));
            zout = new JarOutputStream(new FileOutputStream(f), new Manifest(min));
            addUrlItemRecursively(zout, path, path, Predicates.not(Predicates.equalTo(MANIFEST_PATH)));
        } else {
            zout = new JarOutputStream(new FileOutputStream(f));
            addUrlItemRecursively(zout, path, path, Predicates.alwaysTrue());
        }

        return f;

    } catch (Exception e) {
        throw Exceptions.propagateAnnotated("Error creating ZIP from classpath spec " + path, e);

    } finally {
        Streams.closeQuietly(zout);
    }
}

From source file:gg.uhc.uhc.modules.team.ListTeamsCommand.java

@Override
protected boolean runCommand(CommandSender sender, OptionSet options) {
    int page = pageSpec.value(options);
    boolean emptyOnly = options.has(emptyOnlySpec);
    boolean showAll = options.has(showAllSpec);

    if (showAll && emptyOnly) {
        sender.sendMessage(ChatColor.RED + "You must provide -e OR -a, you cannot supply both");
        return true;
    }//  w w w  .j  a v a  2  s .c o  m

    Predicate<Team> predicate;
    String type;

    if (emptyOnly) {
        type = "(empty teams)";
        predicate = Predicates.not(FunctionalUtil.TEAMS_WITH_PLAYERS);
    } else if (showAll) {
        type = "(all teams)";
        predicate = Predicates.alwaysTrue();
    } else {
        type = "(with players)";
        predicate = FunctionalUtil.TEAMS_WITH_PLAYERS;
    }

    List<Team> teams = Lists.newArrayList(Iterables.filter(teamModule.getTeams().values(), predicate));

    if (teams.size() == 0) {
        sender.sendMessage(ChatColor.RED + "No results found for query " + type);
        return true;
    }

    List<List<Team>> partitioned = Lists.partition(teams, COUNT_PER_PAGE);

    if (page > partitioned.size()) {
        sender.sendMessage(ChatColor.RED + "Page " + page + " does not exist");
        return true;
    }

    List<Team> pageItems = partitioned.get(page - 1);

    Map<String, Object> context = ImmutableMap.<String, Object>builder().put("page", page)
            .put("pages", partitioned.size()).put("type", type).put("count", pageItems.size())
            .put("teams", teams.size()).put("multiple", partitioned.size() > 1).build();

    sender.sendMessage(messages.evalTemplate("header", context));

    Joiner joiner = Joiner.on(", ");
    for (Team team : pageItems) {
        String memberString;
        Set<OfflinePlayer> members = team.getPlayers();

        if (members.size() == 0) {
            memberString = NO_MEMBERS;
        } else {
            memberString = joiner
                    .join(Iterables.transform(team.getPlayers(), FunctionalUtil.PLAYER_NAME_FETCHER));
        }

        sender.sendMessage(
                String.format(FORMAT, team.getPrefix() + team.getDisplayName(), team.getName(), memberString));
    }

    return true;
}

From source file:com.isotrol.impe3.pms.core.obj.ContentTypesObject.java

/**
 * Transforms the object to a protocol buffer message with no filter.
 * @return The PB message./*from  w ww . j  a va2 s . c o m*/
 */
public final ContentTypesPB toPB() {
    return toPB(Predicates.alwaysTrue());
}

From source file:io.crate.analyze.CopyAnalyzer.java

CopyFromAnalyzedStatement convertCopyFrom(CopyFrom node, Analysis analysis) {
    DocTableInfo tableInfo = schemas/*from ww  w  .  j a  va 2s  .  c  om*/
            .getWritableTable(TableIdent.of(node.table(), analysis.sessionContext().defaultSchema()));
    DocTableRelation tableRelation = new DocTableRelation(tableInfo);
    Operation.blockedRaiseException(tableInfo, Operation.INSERT);

    String partitionIdent = null;
    if (!node.table().partitionProperties().isEmpty()) {
        partitionIdent = PartitionPropertiesAnalyzer.toPartitionIdent(tableInfo,
                node.table().partitionProperties(), analysis.parameterContext().parameters());
    }

    EvaluatingNormalizer normalizer = new EvaluatingNormalizer(functions, RowGranularity.CLUSTER,
            ReplaceMode.MUTATE, null, tableRelation);
    ExpressionAnalyzer expressionAnalyzer = createExpressionAnalyzer(analysis, tableRelation);
    expressionAnalyzer.setResolveFieldsOperation(Operation.INSERT);
    ExpressionAnalysisContext expressionAnalysisContext = new ExpressionAnalysisContext();
    Predicate<DiscoveryNode> nodeFilters = Predicates.alwaysTrue();
    Settings settings = Settings.EMPTY;
    if (node.genericProperties().isPresent()) {
        // copy map as items are removed. The GenericProperties map is cached in the query cache and removing
        // items would cause subsequent queries that hit the cache to have different genericProperties
        Map<String, Expression> properties = new HashMap<>(node.genericProperties().get().properties());
        nodeFilters = discoveryNodePredicate(analysis.parameterContext().parameters(),
                properties.remove(NodeFilters.NAME));
        settings = settingsFromProperties(properties, expressionAnalyzer, expressionAnalysisContext);
    }
    Symbol uri = expressionAnalyzer.convert(node.path(), expressionAnalysisContext);
    uri = normalizer.normalize(uri, analysis.transactionContext());

    if (!(uri.valueType() == DataTypes.STRING || uri.valueType() instanceof CollectionType
            && ((CollectionType) uri.valueType()).innerType() == DataTypes.STRING)) {
        throw CopyFromAnalyzedStatement.raiseInvalidType(uri.valueType());
    }

    return new CopyFromAnalyzedStatement(tableInfo, settings, uri, partitionIdent, nodeFilters);
}

From source file:com.cisco.step.jenkins.plugins.jenkow.identity.JenkowUserQueryImpl.java

private Predicate<String> literalAndLike(final String exact, String like) {
    if (exact == null && like == null)
        return Predicates.alwaysTrue();

    final Pattern p = (like != null) ? Pattern.compile(like.replace("%", ".*").replace('_', '?')) : null;
    return new Predicate<String>() {
        public boolean apply(String input) {
            return (exact != null && exact.equals(input)) || (p != null && p.matcher(input).matches());
        }/*from  w w w. jav  a 2  s . c  o  m*/
    };
}