Java Code Examples for java.util.List.getClass()

The following are Jave code examples for showing how to use getClass() of the java.util.List class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: omero-ms-queue   File: TextAnnotationListTest.java   View Source Code Vote up 6 votes
@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)));  // (*)
}
 
Example 2
Project: omero-ms-queue   File: PositiveNListTest.java   View Source Code Vote up 6 votes
@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)));  // (*)
}
 
Example 3
Project: jsf-sdk   File: ListTemplate.java   View Source Code Vote up 6 votes
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();
}
 
Example 4
Project: openjdk-jdk10   File: NestedSubList.java   View Source Code Vote up 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 5
Project: clearwsd   File: Features.java   View Source Code Vote up 6 votes
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());
}
 
Example 6
Project: incubator-netbeans   File: FolderList.java   View Source Code Vote up 4 votes
public FileListTransferable(final List<? extends File> data) {
    data.getClass();
    this.data = data;
}
 
Example 7
Project: fastclone   File: App.java   View Source Code Vote up 4 votes
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);
    }