当前位置: 首页>>代码示例>>Java>>正文


Java List.getClass方法代码示例

本文整理汇总了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)));  // (*)
}
 
开发者ID:openmicroscopy,项目名称:omero-ms-queue,代码行数:21,代码来源:TextAnnotationListTest.java

示例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)));  // (*)
}
 
开发者ID:openmicroscopy,项目名称:omero-ms-queue,代码行数:17,代码来源:PositiveNListTest.java

示例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();
}
 
开发者ID:tiglabs,项目名称:jsf-sdk,代码行数:20,代码来源:ListTemplate.java

示例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);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:NestedSubList.java

示例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());
}
 
开发者ID:clearwsd,项目名称:clearwsd,代码行数:20,代码来源:Features.java

示例6: FileListTransferable

import java.util.List; //导入方法依赖的package包/类
public FileListTransferable(final List<? extends File> data) {
    data.getClass();
    this.data = data;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:5,代码来源:FolderList.java

示例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);
    }
 
开发者ID:bruce-cloud,项目名称:fastclone,代码行数:54,代码来源:App.java


注:本文中的java.util.List.getClass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。