okhttp3.internal.Util.immutableList()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(11.3k)|赞(0)|评价(0)|浏览(443)

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

Util.immutableList介绍

[英]Returns an immutable copy of list.
[中]返回列表的不可变副本。

代码示例

代码示例来源:origin: square/okhttp

FormBody(List<String> encodedNames, List<String> encodedValues) {
 this.encodedNames = Util.immutableList(encodedNames);
 this.encodedValues = Util.immutableList(encodedValues);
}

代码示例来源:origin: square/okhttp

public Builder connectionSpecs(List<ConnectionSpec> connectionSpecs) {
 this.connectionSpecs = Util.immutableList(connectionSpecs);
 return this;
}

代码示例来源:origin: square/okhttp

private static <T> List<T> nullSafeImmutableList(T[] elements) {
 return elements == null ? Collections.emptyList() : Util.immutableList(elements);
}

代码示例来源:origin: square/okhttp

public static Handshake get(TlsVersion tlsVersion, CipherSuite cipherSuite,
  List<Certificate> peerCertificates, List<Certificate> localCertificates) {
 if (tlsVersion == null) throw new NullPointerException("tlsVersion == null");
 if (cipherSuite == null) throw new NullPointerException("cipherSuite == null");
 return new Handshake(tlsVersion, cipherSuite, Util.immutableList(peerCertificates),
   Util.immutableList(localCertificates));
}

代码示例来源:origin: com.squareup.okhttp3/okhttp

public Builder connectionSpecs(List<ConnectionSpec> connectionSpecs) {
 this.connectionSpecs = Util.immutableList(connectionSpecs);
 return this;
}

代码示例来源:origin: com.squareup.okhttp3/okhttp

FormBody(List<String> encodedNames, List<String> encodedValues) {
 this.encodedNames = Util.immutableList(encodedNames);
 this.encodedValues = Util.immutableList(encodedValues);
}

代码示例来源:origin: square/okhttp

/**
 * Indicates the protocols supported by ALPN on incoming HTTPS connections. This list is ignored
 * when {@link #setProtocolNegotiationEnabled negotiation is disabled}.
 *
 * @param protocols the protocols to use, in order of preference. The list must contain
 * {@linkplain Protocol#HTTP_1_1}. It must not contain null.
 */
public void setProtocols(List<Protocol> protocols) {
 protocols = Util.immutableList(protocols);
 if (protocols.contains(Protocol.H2_PRIOR_KNOWLEDGE) && protocols.size() > 1) {
  // when using h2_prior_knowledge, no other protocol should be supported.
  throw new IllegalArgumentException(
    "protocols containing h2_prior_knowledge cannot use other protocols: " + protocols);
 } else if (!protocols.contains(Protocol.H2_PRIOR_KNOWLEDGE)
   && !protocols.contains(Protocol.HTTP_1_1)) {
  throw new IllegalArgumentException("protocols doesn't contain http/1.1: " + protocols);
 }
 if (protocols.contains(null)) {
  throw new IllegalArgumentException("protocols must not contain null");
 }
 this.protocols = protocols;
}

代码示例来源:origin: square/okhttp

/** Prepares the proxy servers to try. */
private void resetNextProxy(HttpUrl url, Proxy proxy) {
 if (proxy != null) {
  // If the user specifies a proxy, try that and only that.
  proxies = Collections.singletonList(proxy);
 } else {
  // Try each of the ProxySelector choices until one connection succeeds.
  List<Proxy> proxiesOrNull = address.proxySelector().select(url.uri());
  proxies = proxiesOrNull != null && !proxiesOrNull.isEmpty()
    ? Util.immutableList(proxiesOrNull)
    : Util.immutableList(Proxy.NO_PROXY);
 }
 nextProxyIndex = 0;
}

代码示例来源:origin: com.squareup.okhttp3/okhttp

public static Handshake get(TlsVersion tlsVersion, CipherSuite cipherSuite,
  List<Certificate> peerCertificates, List<Certificate> localCertificates) {
 if (tlsVersion == null) throw new NullPointerException("tlsVersion == null");
 if (cipherSuite == null) throw new NullPointerException("cipherSuite == null");
 return new Handshake(tlsVersion, cipherSuite, Util.immutableList(peerCertificates),
   Util.immutableList(localCertificates));
}

代码示例来源:origin: square/okhttp

MultipartBody(ByteString boundary, MediaType type, List<Part> parts) {
 this.boundary = boundary;
 this.originalType = type;
 this.contentType = MediaType.get(type + "; boundary=" + boundary.utf8());
 this.parts = Util.immutableList(parts);
}

代码示例来源:origin: square/okhttp

public Address(String uriHost, int uriPort, Dns dns, SocketFactory socketFactory,
  @Nullable SSLSocketFactory sslSocketFactory, @Nullable HostnameVerifier hostnameVerifier,
  @Nullable CertificatePinner certificatePinner, Authenticator proxyAuthenticator,
  @Nullable Proxy proxy, List<Protocol> protocols, List<ConnectionSpec> connectionSpecs,
  ProxySelector proxySelector) {
 this.url = new HttpUrl.Builder()
   .scheme(sslSocketFactory != null ? "https" : "http")
   .host(uriHost)
   .port(uriPort)
   .build();
 if (dns == null) throw new NullPointerException("dns == null");
 this.dns = dns;
 if (socketFactory == null) throw new NullPointerException("socketFactory == null");
 this.socketFactory = socketFactory;
 if (proxyAuthenticator == null) {
  throw new NullPointerException("proxyAuthenticator == null");
 }
 this.proxyAuthenticator = proxyAuthenticator;
 if (protocols == null) throw new NullPointerException("protocols == null");
 this.protocols = Util.immutableList(protocols);
 if (connectionSpecs == null) throw new NullPointerException("connectionSpecs == null");
 this.connectionSpecs = Util.immutableList(connectionSpecs);
 if (proxySelector == null) throw new NullPointerException("proxySelector == null");
 this.proxySelector = proxySelector;
 this.proxy = proxy;
 this.sslSocketFactory = sslSocketFactory;
 this.hostnameVerifier = hostnameVerifier;
 this.certificatePinner = certificatePinner;
}

代码示例来源:origin: square/okhttp

public static Handshake get(SSLSession session) throws IOException {
 String cipherSuiteString = session.getCipherSuite();
 if (cipherSuiteString == null) throw new IllegalStateException("cipherSuite == null");
 if ("SSL_NULL_WITH_NULL_NULL".equals(cipherSuiteString)) {
  throw new IOException("cipherSuite == SSL_NULL_WITH_NULL_NULL");
 }
 CipherSuite cipherSuite = CipherSuite.forJavaName(cipherSuiteString);
 String tlsVersionString = session.getProtocol();
 if (tlsVersionString == null) throw new IllegalStateException("tlsVersion == null");
 if ("NONE".equals(tlsVersionString)) throw new IOException("tlsVersion == NONE");
 TlsVersion tlsVersion = TlsVersion.forJavaName(tlsVersionString);
 Certificate[] peerCertificates;
 try {
  peerCertificates = session.getPeerCertificates();
 } catch (SSLPeerUnverifiedException ignored) {
  peerCertificates = null;
 }
 List<Certificate> peerCertificatesList = peerCertificates != null
   ? Util.immutableList(peerCertificates)
   : Collections.emptyList();
 Certificate[] localCertificates = session.getLocalCertificates();
 List<Certificate> localCertificatesList = localCertificates != null
   ? Util.immutableList(localCertificates)
   : Collections.emptyList();
 return new Handshake(tlsVersion, cipherSuite, peerCertificatesList, localCertificatesList);
}

代码示例来源:origin: com.squareup.okhttp3/okhttp

/** Prepares the proxy servers to try. */
private void resetNextProxy(HttpUrl url, Proxy proxy) {
 if (proxy != null) {
  // If the user specifies a proxy, try that and only that.
  proxies = Collections.singletonList(proxy);
 } else {
  // Try each of the ProxySelector choices until one connection succeeds.
  List<Proxy> proxiesOrNull = address.proxySelector().select(url.uri());
  proxies = proxiesOrNull != null && !proxiesOrNull.isEmpty()
    ? Util.immutableList(proxiesOrNull)
    : Util.immutableList(Proxy.NO_PROXY);
 }
 nextProxyIndex = 0;
}

代码示例来源:origin: com.squareup.okhttp3/okhttp

MultipartBody(ByteString boundary, MediaType type, List<Part> parts) {
 this.boundary = boundary;
 this.originalType = type;
 this.contentType = MediaType.get(type + "; boundary=" + boundary.utf8());
 this.parts = Util.immutableList(parts);
}

代码示例来源:origin: com.squareup.okhttp3/okhttp

public Address(String uriHost, int uriPort, Dns dns, SocketFactory socketFactory,
  @Nullable SSLSocketFactory sslSocketFactory, @Nullable HostnameVerifier hostnameVerifier,
  @Nullable CertificatePinner certificatePinner, Authenticator proxyAuthenticator,
  @Nullable Proxy proxy, List<Protocol> protocols, List<ConnectionSpec> connectionSpecs,
  ProxySelector proxySelector) {
 this.url = new HttpUrl.Builder()
   .scheme(sslSocketFactory != null ? "https" : "http")
   .host(uriHost)
   .port(uriPort)
   .build();
 if (dns == null) throw new NullPointerException("dns == null");
 this.dns = dns;
 if (socketFactory == null) throw new NullPointerException("socketFactory == null");
 this.socketFactory = socketFactory;
 if (proxyAuthenticator == null) {
  throw new NullPointerException("proxyAuthenticator == null");
 }
 this.proxyAuthenticator = proxyAuthenticator;
 if (protocols == null) throw new NullPointerException("protocols == null");
 this.protocols = Util.immutableList(protocols);
 if (connectionSpecs == null) throw new NullPointerException("connectionSpecs == null");
 this.connectionSpecs = Util.immutableList(connectionSpecs);
 if (proxySelector == null) throw new NullPointerException("proxySelector == null");
 this.proxySelector = proxySelector;
 this.proxy = proxy;
 this.sslSocketFactory = sslSocketFactory;
 this.hostnameVerifier = hostnameVerifier;
 this.certificatePinner = certificatePinner;
}

代码示例来源:origin: square/okhttp

this.protocols = builder.protocols;
this.connectionSpecs = builder.connectionSpecs;
this.interceptors = Util.immutableList(builder.interceptors);
this.networkInterceptors = Util.immutableList(builder.networkInterceptors);
this.eventListenerFactory = builder.eventListenerFactory;
this.proxySelector = builder.proxySelector;

代码示例来源:origin: com.squareup.okhttp3/okhttp

public static Handshake get(SSLSession session) throws IOException {
 String cipherSuiteString = session.getCipherSuite();
 if (cipherSuiteString == null) throw new IllegalStateException("cipherSuite == null");
 if ("SSL_NULL_WITH_NULL_NULL".equals(cipherSuiteString)) {
  throw new IOException("cipherSuite == SSL_NULL_WITH_NULL_NULL");
 }
 CipherSuite cipherSuite = CipherSuite.forJavaName(cipherSuiteString);
 String tlsVersionString = session.getProtocol();
 if (tlsVersionString == null) throw new IllegalStateException("tlsVersion == null");
 if ("NONE".equals(tlsVersionString)) throw new IOException("tlsVersion == NONE");
 TlsVersion tlsVersion = TlsVersion.forJavaName(tlsVersionString);
 Certificate[] peerCertificates;
 try {
  peerCertificates = session.getPeerCertificates();
 } catch (SSLPeerUnverifiedException ignored) {
  peerCertificates = null;
 }
 List<Certificate> peerCertificatesList = peerCertificates != null
   ? Util.immutableList(peerCertificates)
   : Collections.emptyList();
 Certificate[] localCertificates = session.getLocalCertificates();
 List<Certificate> localCertificatesList = localCertificates != null
   ? Util.immutableList(localCertificates)
   : Collections.emptyList();
 return new Handshake(tlsVersion, cipherSuite, peerCertificatesList, localCertificatesList);
}

代码示例来源:origin: com.squareup.okhttp3/okhttp

this.protocols = builder.protocols;
this.connectionSpecs = builder.connectionSpecs;
this.interceptors = Util.immutableList(builder.interceptors);
this.networkInterceptors = Util.immutableList(builder.networkInterceptors);
this.eventListenerFactory = builder.eventListenerFactory;
this.proxySelector = builder.proxySelector;

代码示例来源:origin: huxq17/SwipeCardsView

public static Handshake get(CipherSuite cipherSuite, List<Certificate> peerCertificates,
  List<Certificate> localCertificates) {
 if (cipherSuite == null) throw new IllegalArgumentException("cipherSuite == null");
 return new Handshake(cipherSuite, Util.immutableList(peerCertificates),
   Util.immutableList(localCertificates));
}

代码示例来源:origin: com.qiniu/qiniu-android-sdk

MultipartBody(ByteString boundary, MediaType type, List<Part> parts) {
  this.boundary = boundary;
  this.originalType = type;
  this.contentType = MediaType.get(type + "; boundary=" + boundary.utf8());
  this.parts = Util.immutableList(parts);
}

相关文章