java.util.List.of()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(138)

本文整理了Java中java.util.List.of()方法的一些代码示例,展示了List.of()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。List.of()方法的具体详情如下:
包路径:java.util.List
类名称:List
方法名:of

List.of介绍

暂无

代码示例

代码示例来源:origin: com.github.javaito/hcjf

/**
 * Returns only one instance to insert.
 * @return Instance to insert.
 */
@Override
protected final Collection<Object> getInstances() {
  return List.of(instance);
}

代码示例来源:origin: com.github.javaito/hcjf

/**
 * Returns a list with the queryable instance to execute the delete.
 * @return Queryable instance.
 */
@Override
protected Collection<Object> getInstances() {
  return List.of(queryable);
}

代码示例来源:origin: com.github.javaito/hcjf

/**
 * Returns the instance that contains the information to update the instances.
 * @return Object that contains the new values.
 */
@Override
protected Collection<Object> getInstances() {
  return List.of(instance);
}

代码示例来源:origin: net.dongliu/xhttp

/**
 * Get headers by name. If not exists, return empty list
 */
public List<String> getHeaders(String name) {
  requireNonNull(name);
  return map.getOrDefault(name, List.of());
}

代码示例来源:origin: net.dongliu/xhttp

/**
 * Create request body send x-www-form-encoded data, with UTF-8 charset.
 */
public static Body<List<Param>> wwwForm(Param... params) {
  requireNonNull(params);
  return new FormBody(List.of(params), UTF_8);
}

代码示例来源:origin: net.dongliu/xhttp

/**
 * Set url query params.
 *
 * @param params the parameters
 */
public final T params(Param... params) {
  this.params = List.of(params);
  return self();
}

代码示例来源:origin: net.dongliu/xhttp

/**
 * Create multi-part encoded request body, from several Parts.
 */
public static Body<List<Part>> multiPart(Part... parts) {
  requireNonNull(parts);
  return new MultiPartBody(List.of(parts));
}

代码示例来源:origin: net.dongliu/xhttp

@Override
  public Map<String, List<String>> get(URI uri, Map<String, List<String>> requestHeaders) throws IOException {
    var headers = super.get(uri, requestHeaders);

    var userList = requestHeaders.getOrDefault(HeaderNames.COOKIE, List.of());
    var sessionList = headers.getOrDefault(HeaderNames.COOKIE, List.of());
    var cookieValues = Lists.concat(userList, sessionList);
    if (cookieValues.isEmpty()) {
      return Map.of();
    }
    return Map.of(HeaderNames.COOKIE, cookieValues);

  }
}

代码示例来源:origin: no.ssb.lds/linked-data-store-persistence-provider-foundationdb

@Override
  public CompletableFuture<? extends Subspace> createOrOpen(Tuple key) {
    // To create a nested subdirectory per tuple item, use: directory.createOrOpen(db, t.stream().map(o -> (String) o).collect(Collectors.toList())
    return directorySubspaceByPaths.computeIfAbsent(key, k -> directory.createOrOpen(db, List.of(k.toString())));
  }
}

代码示例来源:origin: net.dongliu/xhttp

/**
 * Set request headers.
 */
public final T headers(Header... headers) {
  headers(List.of(headers));
  return self();
}

代码示例来源:origin: com.github.javaito/hcjf

/**
 * This method verify if the conditions of the query are true or not.
 * @param object Object to use as condition parameters.
 * @return Returns if the evaluation of conditions are true or false in the otherwise.
 */
public final boolean verifyCondition(Object object) {
  Consumer consumer = new Queryable.IntrospectionConsumer<>();
  Collection collection = List.of(object);
  return verifyCondition(object, Q->collection, consumer);
}

代码示例来源:origin: no.ssb.lds/linked-data-store-persistence-provider-test

public static TestSpecificationElement objectNode(SpecificationElementType elementType, String name, Set<TestSpecificationElement> properties) {
  TestSpecificationElement mapElement = new TestSpecificationElement(name, elementType, Set.of("object"), List.of(), Set.of(),
      new TreeMap<>(properties.stream().collect(Collectors.toMap(e -> e.getName(), e -> e))), null);
  properties.forEach(e -> e.parent(mapElement));
  return mapElement;
}

代码示例来源:origin: net.dongliu/xhttp

/**
 * Set request cookies.
 */
public final T cookies(Cookie... cookies) {
  cookies(List.of(cookies));
  return self();
}

代码示例来源:origin: com.github.javaito/hcjf

private DistributedLock getDistributedLock(Object... path) {
  DistributedLock distributedLock;
  synchronized (sharedStore) {
    distributedLock = (DistributedLock) sharedStore.getInstance(path);
    if (distributedLock == null) {
      distributedLock = new DistributedLock();
      distributedLock.setStatus(DistributedLock.Status.UNLOCKED);
      addLocalObject(distributedLock, List.of(thisNode.getId()), List.of(), System.currentTimeMillis(), path);
    }
  }
  return distributedLock;
}

代码示例来源:origin: br.com.jarch/jarch-bpmn

public static List<ProcessInstanceBean> filterProcessInstance(String processDefinitionKey, Map<String, Object> variablesEquals) {
  String processVariables = getVariablesPathEquals(variablesEquals);
  return filterProcessInstanceBase(List.of(processDefinitionKey), Map.of(VARIABLES, processVariables));
}

代码示例来源:origin: br.com.jarch/jarch-bpm

public static List<ProcessInstanceBean> filterProcessInstance(String processDefinitionKey, Map<String, Object> variablesEquals) {
  String processVariables = getVariablesPathEquals(variablesEquals);
  return filterProcessInstanceBase(List.of(processDefinitionKey), Map.of(VARIABLES, processVariables));
}

代码示例来源:origin: no.ssb.lds/linked-data-store-persistence-provider-test

public static TestSpecificationElement arrayNode(String name, TestSpecificationElement items) {
  TestSpecificationElement arrayNode = new TestSpecificationElement(name, SpecificationElementType.EMBEDDED, Set.of("array"), List.of(), Set.of(), Map.of(), items);
  items.parent(arrayNode);
  return arrayNode;
}

代码示例来源:origin: elastic/apm-agent-java

@Test
void testParseUnitInvalid() {
  for (String invalid : List.of("1Kib", "-1b", " 1b", "1 b", "1b ", "1tb")) {
    assertThatCode(() -> ByteValue.of(invalid)).isInstanceOf(IllegalArgumentException.class);
  }
}

代码示例来源:origin: elastic/apm-agent-java

@Test
void testCulprit() {
  when(stacktraceConfiguration.getApplicationPackages()).thenReturn(List.of("org.example.stacktrace"));
  final ErrorCapture errorCapture = new ErrorCapture(tracer);
  final Exception nestedException = new Exception();
  final Exception topLevelException = new Exception(nestedException);
  errorCapture.setException(topLevelException);
  assertThat(errorCapture.getCulprit()).startsWith("org.example.stacktrace.ErrorCaptureTest.testCulprit(ErrorCaptureTest.java:");
  assertThat(errorCapture.getCulprit()).endsWith(":" + nestedException.getStackTrace()[0].getLineNumber() + ")");
}

代码示例来源:origin: elastic/apm-agent-java

@Test
  void testDisabledMetrics() {
    when(config.getDisableMetrics()).thenReturn(List.of(WildcardMatcher.valueOf("jvm.gc.*")));
    final DoubleSupplier problematicMetric = () -> {
      throw new RuntimeException("Huston, we have a problem");
    };
    metricRegistry.addUnlessNegative("jvm.gc.count", emptyMap(), problematicMetric);
    metricRegistry.addUnlessNan("jvm.gc.count", emptyMap(), problematicMetric);
    metricRegistry.add("jvm.gc.count", emptyMap(), problematicMetric);
    assertThat(metricRegistry.getMetricSets()).isEmpty();
  }
}

相关文章