本文整理匯總了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);
}