本文整理了Java中io.vavr.collection.List.get()
方法的一些代码示例,展示了List.get()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。List.get()
方法的具体详情如下:
包路径:io.vavr.collection.List
类名称:List
方法名:get
暂无
代码示例来源:origin: vavr-io/vavr
@Override
default List<T> update(int index, Function<? super T, ? extends T> updater) {
Objects.requireNonNull(updater, "updater is null");
return update(index, updater.apply(get(index)));
}
代码示例来源:origin: vavr-io/vavr
@Override
public T get(int index) {
if (isEmpty()) {
throw new IndexOutOfBoundsException("get(" + index + ") on empty Queue");
}
if (index < 0) {
throw new IndexOutOfBoundsException("get(" + index + ")");
}
final int length = front.length();
if (index < length) {
return front.get(index);
} else {
final int rearIndex = index - length;
final int rearLength = rear.length();
if (rearIndex < rearLength) {
final int reverseRearIndex = rearLength - rearIndex - 1;
return rear.get(reverseRearIndex);
} else {
throw new IndexOutOfBoundsException("get(" + index + ") on Queue of length " + length());
}
}
}
代码示例来源:origin: resilience4j/resilience4j
assertThat(bufferedExceptions.get(0)).isInstanceOf(IllegalArgumentException.class);
assertThat(bufferedExceptions.get(1)).isInstanceOf(IOException.class);
assertThat(bufferedExceptions.get(2)).isInstanceOf(IllegalStateException.class);
assertThat(bufferedExceptions.get(3)).isInstanceOf(UnknownHostException.class);
代码示例来源:origin: com.pragmaticobjects.oo.data/data-core
@Override
public final Declaration<A> uniqueByKey(K key) {
return allByKey(key).get();
}
}
代码示例来源:origin: io.vavr/vavr
@Override
default List<T> update(int index, Function<? super T, ? extends T> updater) {
Objects.requireNonNull(updater, "updater is null");
return update(index, updater.apply(get(index)));
}
代码示例来源:origin: net.serenity-bdd/serenity-model
public void generateReportsFor(TestOutcomes testOutcomes) {
LOGGER.debug("GENERATING JUNIT REPORTS");
groupByTestCase(testOutcomes).entrySet().stream().parallel().forEach(
entry -> {
String testCase = entry.getKey();
List<TestOutcome> testCaseOutcomes = entry.getValue();
String reportFilename = reportFilenameFor(testCaseOutcomes.get(0));
File report = new File(getOutputDirectory(), reportFilename);
try (OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(report))) {
junitXMLConverter.write(testCase, testCaseOutcomes.asJava(), outputStream);
outputStream.flush();
} catch (ParserConfigurationException | TransformerException | IOException e) {
LOGGER.warn("Failed to generate JUnit XML report", e);
}
}
);
}
代码示例来源:origin: io.vavr/vavr
@Override
public T get(int index) {
if (isEmpty()) {
throw new IndexOutOfBoundsException("get(" + index + ") on empty Queue");
}
if (index < 0) {
throw new IndexOutOfBoundsException("get(" + index + ")");
}
final int length = front.length();
if (index < length) {
return front.get(index);
} else {
final int rearIndex = index - length;
final int rearLength = rear.length();
if (rearIndex < rearLength) {
final int reverseRearIndex = rearLength - rearIndex - 1;
return rear.get(reverseRearIndex);
} else {
throw new IndexOutOfBoundsException("get(" + index + ") on Queue of length " + length());
}
}
}
代码示例来源:origin: vavr-io/vavr-jackson
@Test
public void testList() throws Exception {
List<A> src = List.of(new B("a", "b"));
String json = MAPPER.writeValueAsString(new ListPojo().setValue(src));
Assert.assertEquals(json, "{\"value\":[{\"ExtFieldsPojoTest$B\":{\"a\":\"a\",\"b\":\"b\"}}]}");
ListPojo pojo = MAPPER.readValue(json, ListPojo.class);
List<A> restored = pojo.getValue();
Assert.assertTrue(restored.get(0) instanceof B);
Assert.assertEquals(restored.get(0).a, "a");
Assert.assertEquals(((B) restored.get(0)).b, "b");
}
代码示例来源:origin: vavr-io/vavr-jackson
@Test
public void testList() throws Exception {
List<I> src = List.of(new A(), new B());
String json = MAPPER.writeValueAsString(new ListPojo().setValue(src));
Assert.assertEquals(json, "{\"value\":[{\"type\":\"a\"},{\"type\":\"b\"}]}");
ListPojo pojo = MAPPER.readValue(json, ListPojo.class);
List<I> restored = pojo.getValue();
Assert.assertTrue(restored.get(0) instanceof A);
Assert.assertTrue(restored.get(1) instanceof B);
}
内容来源于网络,如有侵权,请联系作者删除!