本文整理汇总了Java中java.util.List.getClass方法的典型用法代码示例。如果您正苦于以下问题:Java List.getClass方法的具体用法?Java List.getClass怎么用?Java List.getClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.List
的用法示例。
在下文中一共展示了List.getClass方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deserializesMapsDueToTypeErasure
import java.util.List; //导入方法依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void deserializesMapsDueToTypeErasure() {
List<TextAnnotation> initialValue = Collections.singletonList(anno("n", "t"));
Class<List<TextAnnotation>> valueType = (Class<List<TextAnnotation>>)
initialValue.getClass();
List<TextAnnotation> readValue = writeThenRead(initialValue, valueType);
assertThat(readValue, is(not(initialValue)));
LinkedTreeMap<String, LinkedTreeMap<String, String>> deserialized =
new LinkedTreeMap<>();
LinkedTreeMap<String, String> deserializedAnno =
new LinkedTreeMap<>();
deserializedAnno.put("fst", "n");
deserializedAnno.put("snd", "t");
deserialized.put("wrappedValue", deserializedAnno);
assertThat(readValue, is(Collections.singletonList(deserialized))); // (*)
}
示例2: deserializesMapsDueToTypeErasure
import java.util.List; //导入方法依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void deserializesMapsDueToTypeErasure() {
List<PositiveN> initialValue = Collections.singletonList(posN(1));
Class<List<PositiveN>> valueType = (Class<List<PositiveN>>)
initialValue.getClass();
List<PositiveN> readValue = writeThenRead(initialValue, valueType);
assertThat(readValue, is(not(initialValue)));
LinkedTreeMap<String, Double> deserialized =
new LinkedTreeMap<>();
deserialized.put("wrappedValue", 1.0);
assertThat(readValue, is(Collections.singletonList(deserialized))); // (*)
}
示例3: write
import java.util.List; //导入方法依赖的package包/类
public void write(Packer pk, List<E> target, boolean required)
throws IOException {
if (!(target instanceof List)) {
if (target == null) {
if (required) {
throw new MessageTypeException("Attempted to write null");
}
pk.writeNil();
return;
}
throw new MessageTypeException("Target is not a List but "
+ target.getClass());
}
pk.writeArrayBegin(target.size());
for (E e : target) {
elementTemplate.write(pk, e);
}
pk.writeArrayEnd();
}
示例4: testAccessToSublists
import java.util.List; //导入方法依赖的package包/类
@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);
}
}
示例5: function
import java.util.List; //导入方法依赖的package包/类
public static <I extends NlpInstance, T extends NlpInstance, U> FeatureFunction<I> function(
NlpContextFactory<I, T> context, List<? extends FeatureExtractor<T, U>> extractors) {
if (extractors.size() == 0) {
throw new IllegalArgumentException("Feature function requires at least one extractor, got 0.");
}
FeatureExtractor<T, U> extractor = extractors.get(0);
if (extractor instanceof StringExtractor) {
List<StringExtractor<T>> stringExtractors = extractors.stream()
.map(e -> ((StringExtractor<T>) e))
.collect(Collectors.toList());
return new StringFeatureFunction<>(context, stringExtractors);
} else if (extractor instanceof StringListExtractor) {
List<StringListExtractor<T>> stringListExtractors = extractors.stream()
.map(e -> ((StringListExtractor<T>) e))
.collect(Collectors.toList());
return new MultiStringFeatureFunction<>(context, stringListExtractors);
}
throw new IllegalArgumentException("Unsupported extractor :" + extractors.getClass());
}
示例6: FileListTransferable
import java.util.List; //导入方法依赖的package包/类
public FileListTransferable(final List<? extends File> data) {
data.getClass();
this.data = data;
}
示例7: main
import java.util.List; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
BiddingWord biddingWord = new BiddingWord();
biddingWord.setWordType(BiddingWord.WordType.getWordType(1));
biddingWord.setSortType(BiddingWord.SortType.getSortType(1));
biddingWord.setName("测试");
biddingWord.setScore(new BigDecimal(100));
biddingWord.setAaaaa(10);
User user = new User();
user.setName("用户1");
user.setAge(23);
user.setNum(200);
biddingWord.setUser(user);
List<User> userList = new ArrayList<>();
userList.add(user);
userList.add(new User());
biddingWord.setUserList(userList);
int total = 1000000;
System.out.println(total + "条数据");
FastClone fastClone = new FastClone();
long startTime = System.currentTimeMillis();
int i = 0;
while (i < total) {
fastClone.clone(biddingWord);
i++;
}
long endTime = System.currentTimeMillis();
// System.out.println("deepClone耗时: " + (endTime - startTime));
startTime = System.currentTimeMillis();
i = 0;
while (i < total) {
fastClone.clone(biddingWord);
i++;
}
endTime = System.currentTimeMillis();
System.out.println("deepClone耗时: " + (endTime - startTime));
startTime = System.currentTimeMillis();
i = 0;
while (i < total) {
fastClone.cloneShallow(biddingWord);
i++;
}
endTime = System.currentTimeMillis();
System.out.println("shallowClone耗时: " + (endTime - startTime));
BiddingWord biddingWord1 = fastClone.clone(biddingWord);
System.out.println(biddingWord1);
Class type = Collections.EMPTY_LIST.getClass();
Class type1 = userList.getClass();
System.out.println(type);
}