Java Code Examples for java.util.List#getClass()
The following examples show how to use
java.util.List#getClass() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NestedSubList.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Test(dataProvider="lists") public void testAccessToSublists(List<Integer> list, boolean modifiable) { Class<?> cls = list.getClass(); for (int i = 0; i < NEST_LIMIT; ++i) { list = list.subList(0, 1); } try { list.get(0); if (modifiable) { list.remove(0); list.add(0, 42); } } catch (StackOverflowError e) { fail("failed for " + cls); } }
Example 2
Source File: ObjectDumper.java From symja_android_library with GNU General Public License v3.0 | 6 votes |
private <E> void appendList(List<E> list, DumpMode dumpMode, int depth) { Class<?> collectionClass = list.getClass(); result.append(collectionClass.getName()).append("["); if (list.isEmpty()) { result.append(EMPTY); } else { result.append("\n"); E element; for (int i = 0; i < list.size(); i++) { element = list.get(i); makeIndent(depth + 1); result.append(i).append(" => "); appendObject(element, getElementDumpMode(element, dumpMode), depth + 1); result.append("\n"); } makeIndent(depth); } result.append("]"); }
Example 3
Source File: KryoTest.java From spliceengine with GNU Affero General Public License v3.0 | 6 votes |
@Test public void testImmutableList() throws Exception { List in = Collections.unmodifiableList(Lists.newArrayList(1, 2)); Class<? extends List> clazz = in.getClass(); Output output = new Output(new byte[20],20); kryo.writeObject(output, in); byte[] bytes = output.toBytes(); assertNotNull(bytes); Input input = new Input(new ByteArrayInputStream(bytes), bytes.length); List out = kryo.readObject(input, clazz); assertNotNull(out); assertEquals(in, out); }
Example 4
Source File: SpringSpoutTest.java From breeze with Apache License 2.0 | 6 votes |
/** * Tests the {@link SpringSpout#setFailSignature(String) fail signature} effect * on a {@link SpringSpout#setOutputStreamId(String) custom stream ID} with collection fields. */ @Test public void failTransaction() throws Exception { List<Object> bean = new ArrayList<>(); bean.add("dang"); doReturn(bean).when(applicationContextMock).getBean(bean.getClass()); SpringSpout subject = new SpringSpout(bean.getClass(), "clone()", "x"); subject.setFailSignature("clear()"); subject.setOutputStreamId("universe"); subject.setApplicationContext(applicationContextMock); subject.open(stormConf, contextMock, collectorMock); subject.nextTuple(); ArgumentCaptor<Object> messageIdCaptor = ArgumentCaptor.forClass(Object.class); verify(collectorMock).emit(eq("universe"), eq(asList((Object) bean)), messageIdCaptor.capture()); subject.fail(messageIdCaptor.getValue()); assertEquals(Collections.emptyList(), bean); }
Example 5
Source File: ConfigListConvOption.java From hugegraph-common with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public ConfigListConvOption(String name, boolean required, String desc, Predicate<List<T>> pred, Function<T, R> convert, Class<T> clazz, List<T> values) { super(name, required, desc, pred, (Class<List<T>>) values.getClass(), values); E.checkNotNull(convert, "convert"); if (clazz == null && values.size() > 0) { clazz = (Class<T>) values.get(0).getClass(); } E.checkArgumentNotNull(clazz, "Element class can't be null"); this.elemClass = clazz; this.converter = convert; }
Example 6
Source File: ConfigListOption.java From hugegraph-common with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public ConfigListOption(String name, boolean required, String desc, Predicate<List<T>> pred, Class<T> clazz, List<T> values) { super(name, required, desc, pred, (Class<List<T>>) values.getClass(), values); if (clazz == null && values.size() > 0) { clazz = (Class<T>) values.get(0).getClass(); } E.checkArgumentNotNull(clazz, "Element class can't be null"); this.elemClass = clazz; }
Example 7
Source File: CompoundParams.java From javageci with Apache License 2.0 | 5 votes |
private static List<String> assertListOfStrings(List value) { for (final var string : value) { if (!(string instanceof String)) { throw new IllegalArgumentException(value.getClass() + " cannot be used in " + CompoundParams.class.getSimpleName() + " as parameter value as it contains non-String elements."); } } return value; }
Example 8
Source File: ParseTreeNodes.java From caja with Apache License 2.0 | 5 votes |
private static String getCtorErrorMessage( Constructor<? extends ParseTreeNode> ctor, Object value, List<? extends ParseTreeNode> children) { return "Error calling ctor " + ctor.toString() +" with value = " + value +" (" + (value == null ? "" : value.getClass()) + ")" +" with children = " + children +" (" + (children == null ? "" : children.getClass()) + ")"; }
Example 9
Source File: SpringSpoutTest.java From breeze with Apache License 2.0 | 5 votes |
/** * Tests the {@link SpringSpout#setAckSignature(String) ack signature} effect * with {@link SpringSpout#setScatterOutput(boolean) record chunks}. */ @Test public void ackTransaction() throws Exception { TestBean.Data record1 = new TestBean.Data(); record1.setId(0); record1.setMessage("ding"); TestBean.Data record2 = new TestBean.Data(); record2.setId(1); record2.setMessage("dong"); List<Object> bean = new ArrayList<>(); bean.add(record1); bean.add(record2); doReturn(bean).when(applicationContextMock).getBean(bean.getClass()); SpringSpout subject = new SpringSpout(bean.getClass(), "toArray()", "g"); subject.setScatterOutput(true); subject.setAckSignature("set(id, message)"); subject.setApplicationContext(applicationContextMock); subject.open(stormConf, contextMock, collectorMock); subject.nextTuple(); ArgumentCaptor<Object> messageIdCaptor = ArgumentCaptor.forClass(Object.class); verify(collectorMock).emit(eq("default"), eq(bean.subList(0, 1)), messageIdCaptor.capture()); verify(collectorMock).emit(eq("default"), eq(bean.subList(1, 2)), messageIdCaptor.capture()); verifyNoMoreInteractions(collectorMock); subject.ack(messageIdCaptor.getAllValues().get(0)); subject.ack(messageIdCaptor.getAllValues().get(1)); assertEquals(asList((Object) "ding", "dong"), bean); }
Example 10
Source File: ListModelValue.java From core with GNU Lesser General Public License v2.1 | 5 votes |
@Override ModelValue protect() { final List<ModelNode> list = this.list; for (final ModelNode node : list) { node.protect(); } return list.getClass() == ArrayList.class ? new ListModelValue(Collections.unmodifiableList(list)) : this; }
Example 11
Source File: FolderList.java From netbeans with Apache License 2.0 | 4 votes |
public FileListTransferable(final List<? extends File> data) { data.getClass(); this.data = data; }
Example 12
Source File: ListWritable.java From laser with Apache License 2.0 | 4 votes |
public ListWritable(List<Writable> values) { listClass = values.getClass(); valueClass = values.get(0).getClass(); this.values = values; }