Example usage for com.google.common.collect ImmutableList contains

List of usage examples for com.google.common.collect ImmutableList contains

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableList contains.

Prototype

boolean contains(Object o);

Source Link

Document

Returns true if this list contains the specified element.

Usage

From source file:org.apache.calcite.interpreter.TableScanNode.java

private static TableScanNode createProjectableFilterable(Interpreter interpreter, TableScan rel,
        ImmutableList<RexNode> filters, ImmutableIntList projects, ProjectableFilterableTable pfTable) {
    final DataContext root = interpreter.getDataContext();
    final ImmutableIntList originalProjects = projects;
    for (;;) {/*from  www.  j av  a 2s  . c  o  m*/
        final List<RexNode> mutableFilters = Lists.newArrayList(filters);
        final int[] projectInts;
        if (projects == null || projects.equals(TableScan.identity(rel.getTable()))) {
            projectInts = null;
        } else {
            projectInts = projects.toIntArray();
        }
        final Enumerable<Object[]> enumerable1 = pfTable.scan(root, mutableFilters, projectInts);
        for (RexNode filter : mutableFilters) {
            if (!filters.contains(filter)) {
                throw RESOURCE.filterableTableInventedFilter(filter.toString()).ex();
            }
        }
        final ImmutableBitSet usedFields = RelOptUtil.InputFinder.bits(mutableFilters, null);
        if (projects != null) {
            int changeCount = 0;
            for (int usedField : usedFields) {
                if (!projects.contains(usedField)) {
                    // A field that is not projected is used in a filter that the
                    // table rejected. We won't be able to apply the filter later.
                    // Try again without any projects.
                    projects = ImmutableIntList.copyOf(Iterables.concat(projects, ImmutableList.of(usedField)));
                    ++changeCount;
                }
            }
            if (changeCount > 0) {
                continue;
            }
        }
        final Enumerable<Row> rowEnumerable = Enumerables.toRow(enumerable1);
        final ImmutableIntList rejectedProjects;
        if (Objects.equals(projects, originalProjects)) {
            rejectedProjects = null;
        } else {
            // We projected extra columns because they were needed in filters. Now
            // project the leading columns.
            rejectedProjects = ImmutableIntList.identity(originalProjects.size());
        }
        return createEnumerable(interpreter, rel, rowEnumerable, projects, mutableFilters, rejectedProjects);
    }
}

From source file:com.techcavern.pircbotz.cap.TLSCapHandler.java

@Override
public boolean handleACK(PircBotZ bot, ImmutableList<String> capabilities) throws CAPException {
    if (capabilities.contains("tls"))
        bot.sendRaw().rawLineNow("STARTTLS");
    //Not finished, still need to wait for 670 line
    return false;
}

From source file:org.pircbotx.cap.TLSCapHandler.java

@Override
public boolean handleACK(PircBotX bot, ImmutableList<String> capabilities) throws CAPException {
    if (capabilities.contains("tls")) {
        log.debug("Supported capability tls, sending STARTTLS and awaiting 670 response");
        bot.sendRaw().rawLineNow("STARTTLS");
        //Not finished, still need to wait for 670 line
        return false;
    }/*  ww  w  .j  a v  a2  s  . c  om*/
    //Ignore, not for us
    return false;
}

From source file:org.pircbotx.cap.SASLCapHandler.java

public boolean handleACK(PircBotX bot, ImmutableList<String> capabilities) {
    if (capabilities.contains("sasl")) {
        //Server acknowledges our request to use sasl 
        bot.sendRaw().rawLineNow("AUTHENTICATE PLAIN");
        //Still not finished
        return false;
    } else/* w  w  w. j a  v a  2  s  .co  m*/
        return true;
}

From source file:com.techcavern.pircbotz.cap.SASLCapHandler.java

public boolean handleACK(PircBotZ bot, ImmutableList<String> capabilities) {
    if (capabilities.contains("sasl")) {
        //Server acknowledges our request to use sasl 
        bot.sendRaw().rawLineNow("AUTHENTICATE PLAIN");
        //Still not finished
        return false;
    } else/*from w ww .ja v  a  2 s.c o m*/
        return true;
}

From source file:org.pircbotx.cap.EnableCapHandler.java

public boolean handleNAK(PircBotX bot, ImmutableList<String> capabilities) throws CAPException {
    if (capabilities.contains(cap)) {
        //Make sure the bot didn't register this capability
        bot.getEnabledCapabilities().remove(cap);
        if (!ignoreFail)
            throw new CAPException(CAPException.Reason.UnsupportedCapability, cap);
        else/* w w w  .j  a  va2 s .  c o  m*/
            //Nothing more to do
            return true;
    }
    //Not applicable to us
    return false;
}

From source file:com.techcavern.pircbotz.cap.EnableCapHandler.java

public boolean handleNAK(PircBotZ bot, ImmutableList<String> capabilities) throws CAPException {
    if (capabilities.contains(cap)) {
        //Make sure the bot didn't register this capability
        bot.getEnabledCapabilities().remove(cap);
        if (!ignoreFail)
            throw new CAPException(CAPException.Reason.UnsupportedCapability, cap);
        else/*from w w w  .j ava 2  s  .com*/
            //Nothing more to do
            return true;
    }
    //Not applicable to us
    return false;
}

From source file:org.pircbotx.cap.EnableCapHandler.java

public boolean handleLS(PircBotX bot, ImmutableList<String> capabilities) throws CAPException {
    if (capabilities.contains(cap)) {
        //Server supports capability, send request to use it
        log.debug("Supported capability " + cap);
        bot.sendCAP().request(cap);//from w ww.j a v a  2 s .  co  m
        //Need to wait for server ACK
        return false;
    } else if (!ignoreFail)
        throw new CAPException(CAPException.Reason.UnsupportedCapability, cap);
    else {
        //Server doesn't support capability but were ignoring exceptions
        log.debug("Unsupported capability " + cap);
        return true;
    }
}

From source file:com.techcavern.pircbotz.cap.EnableCapHandler.java

public boolean handleLS(PircBotZ bot, ImmutableList<String> capabilities) throws CAPException {
    if (capabilities.contains(cap))
        //Server supports capability, send request to use it
        bot.sendCAP().request(cap);/*  w ww  .  j  av a  2  s .com*/
    else if (!ignoreFail)
        throw new CAPException(CAPException.Reason.UnsupportedCapability, cap);
    else {
        //Server doesn't support capability but were ignoring exceptions
        log.debug("Unsupported capability " + cap);
        return true;
    }
    log.debug("Supported capability " + cap);
    //Not finished yet
    return false;
}

From source file:com.facebook.buck.apple.xcode.ProjectGeneratorTestUtils.java

public static void assertHasSingletonFrameworksPhaseWithFrameworkEntries(PBXTarget target,
        ImmutableList<String> frameworks) {
    PBXFrameworksBuildPhase buildPhase = getSingletonPhaseByType(target, PBXFrameworksBuildPhase.class);
    assertEquals("Framework phase should have right number of elements", frameworks.size(),
            buildPhase.getFiles().size());

    for (PBXBuildFile file : buildPhase.getFiles()) {
        PBXReference.SourceTree sourceTree = file.getFileRef().getSourceTree();
        switch (sourceTree) {
        case GROUP:
            fail("Should not emit frameworks with sourceTree <group>");
            break;
        case ABSOLUTE:
            fail("Should not emit frameworks with sourceTree <absolute>");
            break;
        // $CASES-OMITTED$
        default:/*from ww  w  .  jav a  2  s . c  o m*/
            String serialized = "$" + sourceTree + "/" + file.getFileRef().getPath();
            assertTrue("Framework should be listed in list of expected frameworks: " + serialized,
                    frameworks.contains(serialized));
            break;
        }
    }
}