Search in sources :

Example 21 with AbstractList

use of java.util.AbstractList in project robovm by robovm.

the class AbstractListTest method test_lastIndexOfLjava_lang_Object.

public void test_lastIndexOfLjava_lang_Object() {
    AbstractList al = new ArrayList();
    al.add(0);
    al.add(1);
    al.add(2);
    al.add(2);
    al.add(2);
    al.add(2);
    al.add(2);
    al.add(3);
    al.add(4);
    assertEquals(-1, al.lastIndexOf(5));
    assertEquals(6, al.lastIndexOf(2));
}
Also used : AbstractList(java.util.AbstractList) ArrayList(java.util.ArrayList)

Example 22 with AbstractList

use of java.util.AbstractList in project dagger by square.

the class InjectionTest method noProvideBindingsForAbstractClasses.

@Test
public void noProvideBindingsForAbstractClasses() {
    class TestEntryPoint {

        @Inject
        AbstractList abstractList;
    }
    @Module(injects = TestEntryPoint.class)
    class TestModule {
    }
    ObjectGraph graph = ObjectGraph.createWith(new TestingLoader(), new TestModule());
    try {
        graph.validate();
        fail();
    } catch (IllegalStateException expected) {
    }
}
Also used : AbstractList(java.util.AbstractList) TestingLoader(dagger.internal.TestingLoader) Test(org.junit.Test)

Example 23 with AbstractList

use of java.util.AbstractList in project neo4j by neo4j.

the class DependenciesTest method givenSatisfiedTypeWhenResolveWithSuperTypeThenInstanceReturned.

@Test
public void givenSatisfiedTypeWhenResolveWithSuperTypeThenInstanceReturned() throws Exception {
    // Given
    Dependencies dependencies = new Dependencies();
    AbstractList foo = new ArrayList();
    dependencies.satisfyDependency(foo);
    // When
    AbstractList instance = dependencies.resolveDependency(AbstractList.class);
    // Then
    assertThat(instance, equalTo(foo));
}
Also used : AbstractList(java.util.AbstractList) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 24 with AbstractList

use of java.util.AbstractList in project camel by apache.

the class CxfPayload method getBody.

/**
     * Get the body as a List of DOM elements. 
     * This will cause the Body to be fully read and parsed.
     * @return
     */
public List<Element> getBody() {
    return new AbstractList<Element>() {

        public boolean add(Element e) {
            return body.add(new DOMSource(e));
        }

        public Element set(int index, Element element) {
            Source s = body.set(index, new DOMSource(element));
            try {
                return StaxUtils.read(s).getDocumentElement();
            } catch (XMLStreamException e) {
                throw new RuntimeCamelException("Problem converting content to Element", e);
            }
        }

        public void add(int index, Element element) {
            body.add(index, new DOMSource(element));
        }

        public Element remove(int index) {
            Source s = body.remove(index);
            try {
                return StaxUtils.read(s).getDocumentElement();
            } catch (XMLStreamException e) {
                throw new RuntimeCamelException("Problem converting content to Element", e);
            }
        }

        public Element get(int index) {
            Source s = body.get(index);
            try {
                Element el = StaxUtils.read(s).getDocumentElement();
                addNamespace(el, nsMap);
                body.set(index, new DOMSource(el));
                return el;
            } catch (Exception ex) {
                throw new RuntimeCamelException("Problem converting content to Element", ex);
            }
        }

        public int size() {
            return body.size();
        }
    };
}
Also used : AbstractList(java.util.AbstractList) DOMSource(javax.xml.transform.dom.DOMSource) XMLStreamException(javax.xml.stream.XMLStreamException) Element(org.w3c.dom.Element) RuntimeCamelException(org.apache.camel.RuntimeCamelException) DOMSource(javax.xml.transform.dom.DOMSource) Source(javax.xml.transform.Source) RuntimeCamelException(org.apache.camel.RuntimeCamelException) XMLStreamException(javax.xml.stream.XMLStreamException)

Example 25 with AbstractList

use of java.util.AbstractList in project drill by apache.

the class SqlHandlerUtil method qualifyPartitionCol.

/**
   *  Resolve the partition columns specified in "PARTITION BY" clause of CTAS statement.
   *
   *  A partition column is resolved, either (1) the same column appear in the select list of CTAS
   *  or (2) CTAS has a * in select list.
   *
   *  In the second case, a PROJECT with ITEM expression would be created and returned.
   *  Throw validation error if a partition column is not resolved correctly.
   *
   * @param input : the RelNode represents the select statement in CTAS.
   * @param partitionColumns : the list of partition columns.
   * @return : 1) the original RelNode input, if all partition columns are in select list of CTAS
   *           2) a New Project, if a partition column is resolved to * column in select list
   *           3) validation error, if partition column is not resolved.
   */
public static RelNode qualifyPartitionCol(RelNode input, List<String> partitionColumns) {
    final RelDataType inputRowType = input.getRowType();
    final List<RexNode> colRefStarExprs = Lists.newArrayList();
    final List<String> colRefStarNames = Lists.newArrayList();
    final RexBuilder builder = input.getCluster().getRexBuilder();
    final int originalFieldSize = inputRowType.getFieldCount();
    for (final String col : partitionColumns) {
        final RelDataTypeField field = inputRowType.getField(col, false, false);
        if (field == null) {
            throw UserException.validationError().message("Partition column %s is not in the SELECT list of CTAS!", col).build(logger);
        } else {
            if (field.getName().startsWith(StarColumnHelper.STAR_COLUMN)) {
                colRefStarNames.add(col);
                final List<RexNode> operands = Lists.newArrayList();
                operands.add(new RexInputRef(field.getIndex(), field.getType()));
                operands.add(builder.makeLiteral(col));
                final RexNode item = builder.makeCall(SqlStdOperatorTable.ITEM, operands);
                colRefStarExprs.add(item);
            }
        }
    }
    if (colRefStarExprs.isEmpty()) {
        return input;
    } else {
        final List<String> names = new AbstractList<String>() {

            @Override
            public String get(int index) {
                if (index < originalFieldSize) {
                    return inputRowType.getFieldNames().get(index);
                } else {
                    return colRefStarNames.get(index - originalFieldSize);
                }
            }

            @Override
            public int size() {
                return originalFieldSize + colRefStarExprs.size();
            }
        };
        final List<RexNode> refs = new AbstractList<RexNode>() {

            public int size() {
                return originalFieldSize + colRefStarExprs.size();
            }

            public RexNode get(int index) {
                if (index < originalFieldSize) {
                    return RexInputRef.of(index, inputRowType.getFieldList());
                } else {
                    return colRefStarExprs.get(index - originalFieldSize);
                }
            }
        };
        return RelOptUtil.createProject(input, refs, names, false);
    }
}
Also used : AbstractList(java.util.AbstractList) RelDataTypeField(org.apache.calcite.rel.type.RelDataTypeField) RexBuilder(org.apache.calcite.rex.RexBuilder) RexInputRef(org.apache.calcite.rex.RexInputRef) RelDataType(org.apache.calcite.rel.type.RelDataType) RexNode(org.apache.calcite.rex.RexNode)

Aggregations

AbstractList (java.util.AbstractList)26 ArrayList (java.util.ArrayList)19 List (java.util.List)10 Collection (java.util.Collection)6 ConcurrentModificationException (java.util.ConcurrentModificationException)5 Vector (java.util.Vector)4 ListIterator (java.util.ListIterator)3 Set (java.util.Set)3 IOException (java.io.IOException)2 Collections (java.util.Collections)2 LinkedList (java.util.LinkedList)2 RandomAccess (java.util.RandomAccess)2 Collectors (java.util.stream.Collectors)2 Query (org.apache.lucene.search.Query)2 Test (org.junit.Test)2 JsArrayString (com.google.gwt.core.client.JsArrayString)1 TestingLoader (dagger.internal.TestingLoader)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 Array (java.lang.reflect.Array)1