Javadoc singleton versus default instances

This commit is contained in:
Gary Gregory 2024-06-10 18:21:36 -04:00
parent 215571a0bd
commit 225edf5ea8
56 changed files with 124 additions and 23 deletions

View File

@ -58,6 +58,9 @@ import org.apache.hc.core5.util.Args;
@Contract(threading = ThreadingBehavior.IMMUTABLE)
public class HttpCacheEntryFactory {
/**
* Default instance of {@link HttpCacheEntryFactory}.
*/
public static final HttpCacheEntryFactory INSTANCE = new HttpCacheEntryFactory();
private static HeaderGroup headers(final Iterator<Header> it) {

View File

@ -58,6 +58,9 @@ import org.apache.hc.core5.annotation.ThreadingBehavior;
@Contract(threading = ThreadingBehavior.STATELESS)
public final class ByteArrayCacheEntrySerializer implements HttpCacheEntrySerializer<byte[]> {
/**
* Default instance of {@link ByteArrayCacheEntrySerializer}.
*/
public static final ByteArrayCacheEntrySerializer INSTANCE = new ByteArrayCacheEntrySerializer();
@Override

View File

@ -47,6 +47,9 @@ import org.apache.hc.core5.util.CharArrayBuffer;
@Contract(threading = ThreadingBehavior.IMMUTABLE)
class CacheControlHeaderGenerator {
/**
* Default instance of {@link CacheControlHeaderGenerator}.
*/
public static final CacheControlHeaderGenerator INSTANCE = new CacheControlHeaderGenerator();
public List<NameValuePair> convert(final RequestCacheControl cacheControl) {

View File

@ -70,6 +70,9 @@ import org.apache.hc.core5.util.TextUtils;
@Contract(threading = ThreadingBehavior.STATELESS)
public class CacheKeyGenerator implements Resolver<URI, String> {
/**
* Default instance of {@link CacheKeyGenerator}.
*/
public static final CacheKeyGenerator INSTANCE = new CacheKeyGenerator();
@Override

View File

@ -41,6 +41,9 @@ import org.apache.hc.core5.util.Args;
@Contract(threading = ThreadingBehavior.STATELESS)
public class HeapResourceFactory implements ResourceFactory {
/**
* Default instance of {@link HeapResourceFactory}.
*/
public static final HeapResourceFactory INSTANCE = new HeapResourceFactory();
@Override

View File

@ -91,7 +91,7 @@ public class HttpByteArrayCacheEntrySerializer implements HttpCacheEntrySerializ
static final String HC_VARIANT = "HC-Variant";
/**
* Singleton instance of this class.
* Default instance of {@link HttpByteArrayCacheEntrySerializer}.
*/
public static final HttpByteArrayCacheEntrySerializer INSTANCE = new HttpByteArrayCacheEntrySerializer();

View File

@ -41,6 +41,9 @@ import org.apache.hc.core5.annotation.ThreadingBehavior;
@Contract(threading = ThreadingBehavior.STATELESS)
public class NoopCacheEntrySerializer implements HttpCacheEntrySerializer<HttpCacheStorageEntry> {
/**
* Default instance of {@link NoopCacheEntrySerializer}.
*/
public static final NoopCacheEntrySerializer INSTANCE = new NoopCacheEntrySerializer();
@Override

View File

@ -45,6 +45,9 @@ import org.apache.hc.core5.http.protocol.HttpContext;
@Contract(threading = ThreadingBehavior.IMMUTABLE)
class ResponseViaCache implements HttpResponseInterceptor {
/**
* Default instance of {@link ResponseViaCache}.
*/
public static final ResponseViaCache INSTANCE = new ResponseViaCache();
@Override

View File

@ -44,6 +44,9 @@ import org.slf4j.LoggerFactory;
*/
public final class SHA256KeyHashingScheme implements KeyHashingScheme {
/**
* Default instance of {@link SHA256KeyHashingScheme}.
*/
public static final SHA256KeyHashingScheme INSTANCE = new SHA256KeyHashingScheme();
private static final Logger LOG = LoggerFactory.getLogger(SHA256KeyHashingScheme.class);

View File

@ -39,6 +39,9 @@ import org.apache.hc.core5.util.TimeValue;
@Contract(threading = ThreadingBehavior.STATELESS)
public class ImmediateSchedulingStrategy implements SchedulingStrategy {
/**
* Default instance of {@link ImmediateSchedulingStrategy}.
*/
public final static ImmediateSchedulingStrategy INSTANCE = new ImmediateSchedulingStrategy();
@Override

View File

@ -36,6 +36,9 @@ import java.net.UnknownHostException;
*/
public class SystemDefaultDnsResolver implements DnsResolver {
/**
* Default instance of {@link SystemDefaultDnsResolver}.
*/
public static final SystemDefaultDnsResolver INSTANCE = new SystemDefaultDnsResolver();
@Override

View File

@ -46,7 +46,7 @@ import org.apache.hc.core5.annotation.ThreadingBehavior;
public class CookieIdentityComparator implements Serializable, Comparator<Cookie> {
/**
* Singleton instance.
* Default instance of {@link CookieIdentityComparator}.
*
* @since 5.2
*/

View File

@ -51,6 +51,9 @@ import org.apache.hc.core5.annotation.ThreadingBehavior;
@Contract(threading = ThreadingBehavior.STATELESS)
public class CookiePathComparator implements Serializable, Comparator<Cookie> {
/**
* Default instance of {@link CookiePathComparator}.
*/
public static final CookiePathComparator INSTANCE = new CookiePathComparator();
private static final long serialVersionUID = 7523645369616405818L;

View File

@ -43,6 +43,9 @@ import org.apache.hc.core5.annotation.ThreadingBehavior;
@Contract(threading = ThreadingBehavior.STATELESS)
public class CookiePriorityComparator implements Comparator<Cookie> {
/**
* Default instance of {@link CookiePriorityComparator}.
*/
public static final CookiePriorityComparator INSTANCE = new CookiePriorityComparator();
private int getPathLength(final Cookie cookie) {

View File

@ -41,6 +41,9 @@ import org.brotli.dec.BrotliInputStream;
@Contract(threading = ThreadingBehavior.STATELESS)
public class BrotliInputStreamFactory implements InputStreamFactory {
/**
* Default instance of {@link BrotliInputStreamFactory}.
*/
private static final BrotliInputStreamFactory INSTANCE = new BrotliInputStreamFactory();
public static BrotliInputStreamFactory getInstance() {

View File

@ -42,7 +42,7 @@ import org.apache.hc.core5.annotation.ThreadingBehavior;
public class DeflateInputStreamFactory implements InputStreamFactory {
/**
* Singleton instance.
* Default instance of {@link DeflateInputStreamFactory}.
*/
private static final DeflateInputStreamFactory INSTANCE = new DeflateInputStreamFactory();

View File

@ -43,7 +43,7 @@ import org.apache.hc.core5.annotation.ThreadingBehavior;
public class GZIPInputStreamFactory implements InputStreamFactory {
/**
* Singleton instance.
* Default instance of {@link GZIPInputStreamFactory}.
*/
private static final GZIPInputStreamFactory INSTANCE = new GZIPInputStreamFactory();

View File

@ -61,6 +61,9 @@ public class DefaultAuthenticationStrategy implements AuthenticationStrategy {
private static final Logger LOG = LoggerFactory.getLogger(DefaultAuthenticationStrategy.class);
/**
* Default instance of {@link DefaultAuthenticationStrategy}.
*/
public static final DefaultAuthenticationStrategy INSTANCE = new DefaultAuthenticationStrategy();
private static final List<String> DEFAULT_SCHEME_PRIORITY =

View File

@ -44,6 +44,9 @@ import org.apache.hc.core5.http.protocol.HttpContext;
@Contract(threading = ThreadingBehavior.STATELESS)
public class DefaultClientConnectionReuseStrategy extends DefaultConnectionReuseStrategy {
/**
* Default instance of {@link DefaultClientConnectionReuseStrategy}.
*/
public static final DefaultClientConnectionReuseStrategy INSTANCE = new DefaultClientConnectionReuseStrategy();
@Override

View File

@ -54,6 +54,9 @@ import org.apache.hc.core5.util.TimeValue;
@Contract(threading = ThreadingBehavior.STATELESS)
public class DefaultConnectionKeepAliveStrategy implements ConnectionKeepAliveStrategy {
/**
* Default instance of {@link DefaultConnectionKeepAliveStrategy}.
*/
public static final DefaultConnectionKeepAliveStrategy INSTANCE = new DefaultConnectionKeepAliveStrategy();
@Override

View File

@ -64,6 +64,9 @@ import org.apache.hc.core5.util.TimeValue;
@Contract(threading = ThreadingBehavior.STATELESS)
public class DefaultHttpRequestRetryStrategy implements HttpRequestRetryStrategy {
/**
* Default instance of {@link DefaultHttpRequestRetryStrategy}.
*/
public static final DefaultHttpRequestRetryStrategy INSTANCE = new DefaultHttpRequestRetryStrategy();
/**

View File

@ -54,6 +54,9 @@ import org.apache.hc.core5.util.Args;
@Contract(threading = ThreadingBehavior.STATELESS)
public class DefaultRedirectStrategy implements RedirectStrategy {
/**
* Default instance of {@link DefaultRedirectStrategy}.
*/
public static final DefaultRedirectStrategy INSTANCE = new DefaultRedirectStrategy();
@Override

View File

@ -42,6 +42,9 @@ import org.apache.hc.core5.util.Args;
@Contract(threading = ThreadingBehavior.STATELESS)
public class DefaultSchemePortResolver implements SchemePortResolver {
/**
* Default instance of {@link DefaultSchemePortResolver}.
*/
public static final DefaultSchemePortResolver INSTANCE = new DefaultSchemePortResolver();
@Override

View File

@ -59,6 +59,9 @@ import org.apache.hc.core5.http.protocol.HttpContext;
@Contract(threading = ThreadingBehavior.STATELESS)
public class DefaultUserTokenHandler implements UserTokenHandler {
/**
* Default instance of {@link DefaultUserTokenHandler}.
*/
public static final DefaultUserTokenHandler INSTANCE = new DefaultUserTokenHandler();
@Override

View File

@ -40,6 +40,9 @@ import org.apache.hc.core5.http.protocol.HttpContext;
@Contract(threading = ThreadingBehavior.STATELESS)
public class NoopUserTokenHandler implements UserTokenHandler {
/**
* Default instance of {@link NoopUserTokenHandler}.
*/
public static final NoopUserTokenHandler INSTANCE = new NoopUserTokenHandler();
@Override

View File

@ -42,6 +42,9 @@ import org.apache.hc.core5.http.message.BasicHttpRequest;
@Deprecated
public final class RequestCopier implements MessageCopier<HttpRequest> {
/**
* Default instance of {@link RequestCopier}.
*/
public static final RequestCopier INSTANCE = new RequestCopier();
@Override

View File

@ -33,6 +33,9 @@ import org.slf4j.LoggerFactory;
class LoggingExceptionCallback implements Callback<Exception> {
/**
* Singleton instance of LoggingExceptionCallback.
*/
static final LoggingExceptionCallback INSTANCE = new LoggingExceptionCallback();
private static final Logger LOG = LoggerFactory.getLogger("org.apache.hc.client5.http.impl.async");

View File

@ -34,6 +34,9 @@ import org.slf4j.LoggerFactory;
final class LoggingIOSessionDecorator implements Decorator<IOSession> {
/**
* Singleton instance of LoggingIOSessionDecorator.
*/
public final static LoggingIOSessionDecorator INSTANCE = new LoggingIOSessionDecorator();
private static final Logger WIRE_LOG = LoggerFactory.getLogger("org.apache.hc.client5.http.wire");

View File

@ -46,6 +46,9 @@ import org.apache.hc.core5.util.Tokenizer;
*/
public class AuthChallengeParser {
/**
* Default instance of {@link AuthChallengeParser}.
*/
public static final AuthChallengeParser INSTANCE = new AuthChallengeParser();
private final Tokenizer tokenParser = Tokenizer.INSTANCE;

View File

@ -46,7 +46,7 @@ import org.apache.hc.core5.http.protocol.HttpContext;
public class BasicSchemeFactory implements AuthSchemeFactory {
/**
* Singleton instance with a null Charset.
* Default instance of {@link BasicSchemeFactory with a null Charset}.
*/
public static final BasicSchemeFactory INSTANCE = new BasicSchemeFactory();

View File

@ -42,6 +42,9 @@ import org.apache.hc.core5.http.protocol.HttpContext;
@Contract(threading = ThreadingBehavior.STATELESS)
public class BearerSchemeFactory implements AuthSchemeFactory {
/**
* Default instance of {@link BearerSchemeFactory}.
*/
public static final BearerSchemeFactory INSTANCE = new BearerSchemeFactory();
public BearerSchemeFactory() {

View File

@ -46,11 +46,10 @@ import org.apache.hc.core5.http.protocol.HttpContext;
public class DigestSchemeFactory implements AuthSchemeFactory {
/**
* Singleton instance.
* Default instance of {@link DigestSchemeFactory}.
*/
public static final DigestSchemeFactory INSTANCE = new DigestSchemeFactory();
/**
* @param charset the {@link Charset} set to be used for encoding credentials. This parameter is ignored as UTF-8 is always used.
* @deprecated This constructor is deprecated to enforce the use of {@link StandardCharsets#UTF_8} encoding

View File

@ -50,7 +50,7 @@ import org.apache.hc.core5.http.protocol.HttpContext;
public class NTLMSchemeFactory implements AuthSchemeFactory {
/**
* Singleton instance.
* Default instance of {@link NTLMSchemeFactory}.
*/
public static final NTLMSchemeFactory INSTANCE = new NTLMSchemeFactory();

View File

@ -42,6 +42,9 @@ import org.apache.hc.core5.http.message.BasicClassicHttpRequest;
@Deprecated
public final class ClassicRequestCopier implements org.apache.hc.client5.http.impl.MessageCopier<ClassicHttpRequest> {
/**
* Default instance of {@link ClassicRequestCopier}.
*/
public static final ClassicRequestCopier INSTANCE = new ClassicRequestCopier();
@Override

View File

@ -50,7 +50,7 @@ public class BasicDomainHandler implements CommonCookieAttributeHandler {
/**
* Singleton instance.
* Default instance of {@link BasicDomainHandler}.
*
* @since 5.2
*/

View File

@ -44,7 +44,7 @@ import org.apache.hc.core5.util.Args;
public class BasicHttpOnlyHandler implements CommonCookieAttributeHandler {
/**
* Singleton instance.
* Default instance of {@link BasicHttpOnlyHandler}.
*
* @since 5.2
*/

View File

@ -45,7 +45,7 @@ import org.apache.hc.core5.util.Args;
public class BasicMaxAgeHandler extends AbstractCookieAttributeHandler implements CommonCookieAttributeHandler {
/**
* Singleton instance.
* Default instance of {@link BasicMaxAgeHandler}.
*
* @since 5.2
*/

View File

@ -45,7 +45,7 @@ import org.apache.hc.core5.util.TextUtils;
public class BasicPathHandler implements CommonCookieAttributeHandler {
/**
* Singleton instance.
* Default instance of {@link BasicPathHandler}.
*
* @since 5.2
*/

View File

@ -44,7 +44,7 @@ import org.apache.hc.core5.util.Args;
public class BasicSecureHandler extends AbstractCookieAttributeHandler implements CommonCookieAttributeHandler {
/**
* Singleton instance.
* Default instance BasicSecureHandler.
*
* @since 5.2
*/

View File

@ -46,7 +46,7 @@ import org.apache.hc.core5.http.Header;
public class IgnoreSpecSpec extends CookieSpecBase {
/**
* Singleton instance.
* Default instance of {@link IgnoreSpecSpec}.
*
* @since 5.2
*/

View File

@ -57,7 +57,7 @@ import org.apache.hc.core5.util.Tokenizer;
public class LaxExpiresHandler extends AbstractCookieAttributeHandler implements CommonCookieAttributeHandler {
/**
* Singleton instance.
* Default instance of {@link LaxExpiresHandler}.
*
* @since 5.2
*/

View File

@ -49,7 +49,7 @@ import org.apache.hc.core5.util.TextUtils;
public class LaxMaxAgeHandler extends AbstractCookieAttributeHandler implements CommonCookieAttributeHandler {
/**
* Singleton instance.
* Default instance of {@link LaxMaxAgeHandler}.
*
* @since 5.2
*/

View File

@ -46,6 +46,9 @@ import org.apache.hc.core5.http.message.LineParser;
@Contract(threading = ThreadingBehavior.STATELESS)
public class DefaultHttpResponseParserFactory implements HttpMessageParserFactory<ClassicHttpResponse> {
/**
* Default instance DefaultHttpResponseParserFactory.
*/
public static final DefaultHttpResponseParserFactory INSTANCE = new DefaultHttpResponseParserFactory();
private final Http1Config h1Config;

View File

@ -60,6 +60,9 @@ public class ManagedHttpClientConnectionFactory implements HttpConnectionFactory
private static final AtomicLong COUNTER = new AtomicLong();
/**
* Default instance of {@link ManagedHttpClientConnectionFactory}.
*/
public static final ManagedHttpClientConnectionFactory INSTANCE = new ManagedHttpClientConnectionFactory();
private final Http1Config h1Config;

View File

@ -42,7 +42,7 @@ import org.apache.hc.core5.util.Args;
public class BasicRouteDirector implements HttpRouteDirector {
/**
* Singleton instance.
* Default instance of {@link BasicRouteDirector}.
*
* @since 5.2
*/

View File

@ -67,7 +67,7 @@ import org.slf4j.LoggerFactory;
public class RequestAddCookies implements HttpRequestInterceptor {
/**
* Singleton instance.
* Default instance of {@link RequestAddCookies}.
*
* @since 5.2
*/

View File

@ -50,7 +50,7 @@ import org.apache.hc.core5.util.Args;
public class RequestDefaultHeaders implements HttpRequestInterceptor {
/**
* Singleton instance.
* Default instance of {@link RequestDefaultHeaders}.
*
* @since 5.2
*/

View File

@ -72,7 +72,7 @@ import org.apache.hc.core5.util.Args;
public class RequestIfRange implements HttpRequestInterceptor {
/**
* Singleton instance.
* Default instance of {@link RequestIfRange}.
*
* @since 5.4
*/

View File

@ -101,7 +101,7 @@ import org.apache.hc.core5.util.Args;
public class RequestValidateTrace implements HttpRequestInterceptor {
/**
* Singleton instance of {@link RequestValidateTrace}.
* Default instance of {@link RequestValidateTrace}.
*/
public static final HttpRequestInterceptor INSTANCE = new RequestValidateTrace();

View File

@ -59,7 +59,7 @@ import org.slf4j.LoggerFactory;
public class ResponseProcessCookies implements HttpResponseInterceptor {
/**
* Singleton instance.
* Default instance of {@link ResponseProcessCookies}.
*
* @since 5.2
*/

View File

@ -45,7 +45,7 @@ import org.apache.hc.core5.annotation.ThreadingBehavior;
public final class PublicSuffixListParser {
/**
* Singleton instance.
* Default instance of {@link PublicSuffixListParser}.
*
* @since 5.2
*/

View File

@ -56,6 +56,9 @@ import org.apache.hc.core5.util.TimeValue;
@Contract(threading = ThreadingBehavior.STATELESS)
public class PlainConnectionSocketFactory implements ConnectionSocketFactory {
/**
* Default instance of {@link PlainConnectionSocketFactory}.
*/
public static final PlainConnectionSocketFactory INSTANCE = new PlainConnectionSocketFactory();
public static PlainConnectionSocketFactory getSocketFactory() {

View File

@ -37,6 +37,9 @@ import org.apache.hc.core5.util.Tokenizer;
final class DistinguishedNameParser {
/**
* Default instance of {@link DistinguishedNameParser}.
*/
public final static DistinguishedNameParser INSTANCE = new DistinguishedNameParser();
private static final Tokenizer.Delimiter EQUAL_OR_COMMA_OR_PLUS = Tokenizer.delimiters('=', ',', '+');

View File

@ -42,6 +42,9 @@ import org.apache.hc.core5.annotation.ThreadingBehavior;
@Contract(threading = ThreadingBehavior.STATELESS)
public class NoopHostnameVerifier implements HostnameVerifier {
/**
* Default instance of {@link NoopHostnameVerifier}.
*/
public static final NoopHostnameVerifier INSTANCE = new NoopHostnameVerifier();
@Override

View File

@ -50,6 +50,9 @@ import org.apache.hc.core5.ssl.TrustStrategy;
@Contract(threading = ThreadingBehavior.STATELESS)
public class TrustAllStrategy implements TrustStrategy {
/**
* Default instance of {@link TrustAllStrategy}.
*/
public static final TrustAllStrategy INSTANCE = new TrustAllStrategy();
@Override

View File

@ -52,6 +52,9 @@ import org.apache.hc.core5.ssl.TrustStrategy;
@Contract(threading = ThreadingBehavior.STATELESS)
public class TrustSelfSignedStrategy implements TrustStrategy {
/**
* Default instance of {@link TrustSelfSignedStrategy}
*/
public static final TrustSelfSignedStrategy INSTANCE = new TrustSelfSignedStrategy();
@Override