本文整理了Java中org.apache.calcite.util.Util.cast()
方法的一些代码示例,展示了Util.cast()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.cast()
方法的具体详情如下:
包路径:org.apache.calcite.util.Util
类名称:Util
方法名:cast
[英]Converts an Iterable whose members are automatically down-cast to a given type.
All modifications are automatically written to the backing iterator. Not synchronized.
[中]将其成员自动向下转换为给定类型的Iterable转换为给定类型。
所有修改都会自动写入支持迭代器。没有同步。
代码示例来源:origin: Qihoo360/Quicksql
/**
* Converts an {@link Iterable} whose members are automatically down-cast to
* a given type.
*
* <p>All modifications are automatically written to the backing iterator.
* Not synchronized.
*
* @param iterable Backing iterable
* @param clazz Class to cast to
* @return An iterable whose members are of the desired type.
*/
public static <E> Iterable<E> cast(
final Iterable<? super E> iterable,
final Class<E> clazz) {
return () -> cast(iterable.iterator(), clazz);
}
代码示例来源:origin: org.apache.calcite/calcite-core
/**
* Converts an {@link Iterable} whose members are automatically down-cast to
* a given type.
*
* <p>All modifications are automatically written to the backing iterator.
* Not synchronized.
*
* @param iterable Backing iterable
* @param clazz Class to cast to
* @return An iterable whose members are of the desired type.
*/
public static <E> Iterable<E> cast(
final Iterable<? super E> iterable,
final Class<E> clazz) {
return () -> cast(iterable.iterator(), clazz);
}
代码示例来源:origin: Qihoo360/Quicksql
/**
* Concatenates the operands of a call to this operator.
*/
public static SqlLiteral concatenateOperands(SqlCall call) {
final List<SqlNode> operandList = call.getOperandList();
assert operandList.size() > 0;
assert operandList.get(0) instanceof SqlLiteral
: operandList.get(0).getClass();
return SqlUtil.concatenateLiterals(
Util.cast(operandList, SqlLiteral.class));
}
}
代码示例来源:origin: org.apache.calcite/calcite-core
/**
* Concatenates the operands of a call to this operator.
*/
public static SqlLiteral concatenateOperands(SqlCall call) {
final List<SqlNode> operandList = call.getOperandList();
assert operandList.size() > 0;
assert operandList.get(0) instanceof SqlLiteral
: operandList.get(0).getClass();
return SqlUtil.concatenateLiterals(
Util.cast(operandList, SqlLiteral.class));
}
}
代码示例来源:origin: Qihoo360/Quicksql
/**
* Tests {@link org.apache.calcite.util.CastingList} and {@link Util#cast}.
*/
@Test public void testCastingList() {
final List<Number> numberList = new ArrayList<>();
numberList.add(1);
numberList.add(null);
numberList.add(2);
List<Integer> integerList = Util.cast(numberList, Integer.class);
assertEquals(3, integerList.size());
assertEquals(Integer.valueOf(2), integerList.get(2));
// Nulls are OK.
assertNull(integerList.get(1));
// Can update the underlying list.
integerList.set(1, 345);
assertEquals(Integer.valueOf(345), integerList.get(1));
integerList.set(1, null);
assertNull(integerList.get(1));
// Can add a member of the wrong type to the underlying list.
numberList.add(3.1415D);
assertEquals(4, integerList.size());
// Access a member which is of the wrong type.
try {
integerList.get(3);
fail("expected exception");
} catch (ClassCastException e) {
// ok
}
}
代码示例来源:origin: org.apache.calcite/calcite-core
/**
* Tests {@link org.apache.calcite.util.CastingList} and {@link Util#cast}.
*/
@Test public void testCastingList() {
final List<Number> numberList = new ArrayList<>();
numberList.add(1);
numberList.add(null);
numberList.add(2);
List<Integer> integerList = Util.cast(numberList, Integer.class);
assertEquals(3, integerList.size());
assertEquals(Integer.valueOf(2), integerList.get(2));
// Nulls are OK.
assertNull(integerList.get(1));
// Can update the underlying list.
integerList.set(1, 345);
assertEquals(Integer.valueOf(345), integerList.get(1));
integerList.set(1, null);
assertNull(integerList.get(1));
// Can add a member of the wrong type to the underlying list.
numberList.add(3.1415D);
assertEquals(4, integerList.size());
// Access a member which is of the wrong type.
try {
integerList.get(3);
fail("expected exception");
} catch (ClassCastException e) {
// ok
}
}
内容来源于网络,如有侵权,请联系作者删除!