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));
}
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) {
}
}
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));
}
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();
}
};
}
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);
}
}
Aggregations