+htc #19162 add safe java accessors to scala objects
This commit is contained in:
parent
ed6acd63ec
commit
fc613aea7c
23 changed files with 139 additions and 5 deletions
|
|
@ -9,6 +9,8 @@ import java.nio.charset.Charset;
|
|||
/**
|
||||
* Represents a charset in Http. See {@link HttpCharsets} for a set of predefined charsets and
|
||||
* static constructors to create custom charsets.
|
||||
*
|
||||
* @see HttpCharsets for convenience access to often used values.
|
||||
*/
|
||||
public abstract class HttpCharset {
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ package akka.http.javadsl.model;
|
|||
/**
|
||||
* Represents an Http charset range. This can either be `*` which matches all charsets or a specific
|
||||
* charset. {@link HttpCharsetRanges} contains static constructors for HttpCharsetRanges.
|
||||
*
|
||||
* @see HttpCharsetRanges for convenience access to often used values.
|
||||
*/
|
||||
public abstract class HttpCharsetRange {
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ import akka.stream.javadsl.Source;
|
|||
public final class HttpEntities {
|
||||
private HttpEntities() {}
|
||||
|
||||
public static final HttpEntity.Strict EMPTY = HttpEntity$.MODULE$.Empty();
|
||||
|
||||
public static HttpEntity.Strict create(String string) {
|
||||
return HttpEntity$.MODULE$.apply(string);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
package akka.http.javadsl.model;
|
||||
|
||||
import akka.http.impl.util.Util;
|
||||
import akka.http.javadsl.model.headers.EntityTagRanges;
|
||||
import akka.http.scaladsl.model.HttpEntity$;
|
||||
import akka.stream.Materializer;
|
||||
import akka.stream.javadsl.Source;
|
||||
|
|
@ -37,6 +38,8 @@ import java.util.concurrent.CompletionStage;
|
|||
* - UniversalEntity: an entity type that can be used in every context
|
||||
*
|
||||
* Use the static constructors in HttpEntities to construct instances.
|
||||
*
|
||||
* @see HttpEntities for javadsl convenience methods.
|
||||
*/
|
||||
public interface HttpEntity {
|
||||
/**
|
||||
|
|
@ -46,8 +49,12 @@ public interface HttpEntity {
|
|||
|
||||
/**
|
||||
* The empty entity.
|
||||
*
|
||||
* @deprecated Will be removed in Akka 3.x, use {@link HttpEntities#EMPTY} instead.
|
||||
*/
|
||||
HttpEntity.Strict EMPTY = HttpEntity$.MODULE$.Empty();
|
||||
@Deprecated
|
||||
// FIXME: Remove in Akka 3.0
|
||||
HttpEntity.Strict EMPTY = HttpEntities.EMPTY;
|
||||
|
||||
/**
|
||||
* Returns if this entity is known to be empty. Open-ended entity types like
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ package akka.http.javadsl.model;
|
|||
/**
|
||||
* Represents an HTTP request method. See {@link HttpMethods} for a set of predefined methods
|
||||
* and static constructors to create custom ones.
|
||||
*
|
||||
* @see HttpMethods for convenience access to often used values.
|
||||
*/
|
||||
public abstract class HttpMethod {
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ package akka.http.javadsl.model;
|
|||
/**
|
||||
* Represents an Http protocol (currently only HTTP/1.0 or HTTP/1.1). See {@link HttpProtocols}
|
||||
* for the predefined constants for the supported protocols.
|
||||
*
|
||||
* @see HttpProtocols for convenience access to often used values.
|
||||
*/
|
||||
public abstract class HttpProtocol {
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import java.util.Optional;
|
|||
/**
|
||||
* Contains the set of predefined media-types.
|
||||
*/
|
||||
public abstract class MediaTypes {
|
||||
public final class MediaTypes {
|
||||
public static final MediaType.WithOpenCharset APPLICATION_ATOM_XML = akka.http.scaladsl.model.MediaTypes.application$divatom$plusxml();
|
||||
public static final MediaType.WithOpenCharset APPLICATION_BASE64 = akka.http.scaladsl.model.MediaTypes.application$divbase64();
|
||||
public static final MediaType.Binary APPLICATION_EXCEL = akka.http.scaladsl.model.MediaTypes.application$divexcel();
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ package akka.http.javadsl.model;
|
|||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.Optional;
|
||||
|
||||
import akka.http.javadsl.model.headers.HttpEncodingRanges;
|
||||
import scala.compat.java8.OptionConverters;
|
||||
|
||||
public abstract class RemoteAddress {
|
||||
|
|
@ -19,7 +21,6 @@ public abstract class RemoteAddress {
|
|||
*/
|
||||
public abstract int getPort();
|
||||
|
||||
public static final RemoteAddress UNKNOWN = akka.http.scaladsl.model.RemoteAddress.Unknown$.MODULE$;
|
||||
public static RemoteAddress create(InetAddress address) {
|
||||
return akka.http.scaladsl.model.RemoteAddress.apply(address, OptionConverters.toScala(Optional.empty()));
|
||||
}
|
||||
|
|
@ -29,4 +30,13 @@ public abstract class RemoteAddress {
|
|||
public static RemoteAddress create(byte[] address) {
|
||||
return akka.http.scaladsl.model.RemoteAddress.apply(address);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated because of troublesome initialisation order (with regards to scaladsl class implementing this class).
|
||||
* In some edge cases this field could end up containing a null value.
|
||||
* Will be removed in Akka 3.x, use {@link HttpEncodingRanges#ALL} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
// FIXME: Remove in Akka 3.0
|
||||
public static final RemoteAddress UNKNOWN = RemoteAddresses.UNKNOWN;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
/*
|
||||
* Copyright (C) 2009-2016 Lightbend Inc. <http://www.lightbend.com>
|
||||
*/
|
||||
|
||||
package akka.http.javadsl.model;
|
||||
|
||||
public abstract class RemoteAddresses {
|
||||
|
||||
public static final RemoteAddress UNKNOWN = akka.http.scaladsl.model.RemoteAddress.Unknown$.MODULE$;
|
||||
}
|
||||
|
|
@ -7,6 +7,8 @@ package akka.http.javadsl.model;
|
|||
/**
|
||||
* Represents an Http status-code and message. See {@link StatusCodes} for the set of predefined
|
||||
* status-codes.
|
||||
*
|
||||
* @see StatusCodes for convenience access to often used values.
|
||||
*/
|
||||
public abstract class StatusCode {
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -5,9 +5,13 @@
|
|||
package akka.http.javadsl.model;
|
||||
|
||||
import akka.http.impl.util.Util;
|
||||
import akka.http.javadsl.model.headers.EntityTagRanges;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @see TransferEncodings for convenience access to often used values.
|
||||
*/
|
||||
public abstract class TransferEncoding {
|
||||
public abstract String name();
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
package akka.http.javadsl.model.headers;
|
||||
|
||||
/** @see CacheDirectives for convenience access to often used values. */
|
||||
public interface CacheDirective {
|
||||
String value();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@
|
|||
|
||||
package akka.http.javadsl.model.headers;
|
||||
|
||||
/**
|
||||
* @see ContentDispositionTypes for convenience access to often used values.
|
||||
*/
|
||||
public interface ContentDispositionType {
|
||||
String name();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,9 +6,20 @@ package akka.http.javadsl.model.headers;
|
|||
|
||||
import akka.http.impl.util.Util;
|
||||
|
||||
/**
|
||||
* @see EntityTagRanges for convenience access to often used values.
|
||||
*/
|
||||
public abstract class EntityTagRange {
|
||||
public static EntityTagRange create(EntityTag... tags) {
|
||||
return akka.http.scaladsl.model.headers.EntityTagRange.apply(Util.<EntityTag, akka.http.scaladsl.model.headers.EntityTag>convertArray(tags));
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated because of troublesome initialisation order (with regards to scaladsl class implementing this class).
|
||||
* In some edge cases this field could end up containing a null value.
|
||||
* Will be removed in Akka 3.x, use {@link EntityTagRanges#ALL} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
// FIXME: Remove in Akka 3.0
|
||||
public static final EntityTagRange ALL = akka.http.scaladsl.model.headers.EntityTagRange.$times$.MODULE$;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
/*
|
||||
* Copyright (C) 2009-2016 Lightbend Inc. <http://www.lightbend.com>
|
||||
*/
|
||||
|
||||
package akka.http.javadsl.model.headers;
|
||||
|
||||
public final class EntityTagRanges {
|
||||
private EntityTagRanges() { }
|
||||
|
||||
public static final EntityTagRange ALL = akka.http.scaladsl.model.headers.EntityTagRange.$times$.MODULE$;
|
||||
}
|
||||
|
|
@ -6,14 +6,25 @@ package akka.http.javadsl.model.headers;
|
|||
|
||||
import akka.http.scaladsl.model.headers.HttpEncodingRange$;
|
||||
|
||||
/**
|
||||
* @see HttpEncodingRanges for convenience access to often used values.
|
||||
*/
|
||||
public abstract class HttpEncodingRange {
|
||||
public abstract float qValue();
|
||||
public abstract boolean matches(HttpEncoding encoding);
|
||||
|
||||
public abstract HttpEncodingRange withQValue(float qValue);
|
||||
|
||||
public static final HttpEncodingRange ALL = akka.http.scaladsl.model.headers.HttpEncodingRange.$times$.MODULE$;
|
||||
public static HttpEncodingRange create(HttpEncoding encoding) {
|
||||
return HttpEncodingRange$.MODULE$.apply((akka.http.scaladsl.model.headers.HttpEncoding) encoding);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated because of troublesome initialisation order (with regards to scaladsl class implementing this class).
|
||||
* In some edge cases this field could end up containing a null value.
|
||||
* Will be removed in Akka 3.x, use {@link HttpEncodingRanges#ALL} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
// FIXME: Remove in Akka 3.0
|
||||
public static final HttpEncodingRange ALL = akka.http.scaladsl.model.headers.HttpEncodingRange.$times$.MODULE$;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
/*
|
||||
* Copyright (C) 2009-2016 Lightbend Inc. <http://www.lightbend.com>
|
||||
*/
|
||||
|
||||
package akka.http.javadsl.model.headers;
|
||||
|
||||
public final class HttpEncodingRanges {
|
||||
private HttpEncodingRanges() { }
|
||||
|
||||
public static final HttpEncodingRange ALL = akka.http.scaladsl.model.headers.HttpEncodingRange.$times$.MODULE$;
|
||||
}
|
||||
|
|
@ -7,11 +7,22 @@ package akka.http.javadsl.model.headers;
|
|||
import akka.http.scaladsl.model.headers.HttpOriginRange$;
|
||||
import akka.http.impl.util.Util;
|
||||
|
||||
/**
|
||||
* @see HttpOriginRanges for convenience access to often used values.
|
||||
*/
|
||||
public abstract class HttpOriginRange {
|
||||
public abstract boolean matches(HttpOrigin origin);
|
||||
|
||||
public static final HttpOriginRange ALL = akka.http.scaladsl.model.headers.HttpOriginRange.$times$.MODULE$;
|
||||
public static HttpOriginRange create(HttpOrigin... origins) {
|
||||
return HttpOriginRange$.MODULE$.apply(Util.<HttpOrigin, akka.http.scaladsl.model.headers.HttpOrigin>convertArray(origins));
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated because of troublesome initialisation order (with regards to scaladsl class implementing this class).
|
||||
* In some edge cases this field could end up containing a null value.
|
||||
* Will be removed in Akka 3.x, use {@link HttpEncodingRanges#ALL} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
// FIXME: Remove in Akka 3.0
|
||||
public static final HttpOriginRange ALL = akka.http.scaladsl.model.headers.HttpOriginRange.$times$.MODULE$;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
/*
|
||||
* Copyright (C) 2009-2016 Lightbend Inc. <http://www.lightbend.com>
|
||||
*/
|
||||
|
||||
package akka.http.javadsl.model.headers;
|
||||
|
||||
public final class HttpOriginRanges {
|
||||
private HttpOriginRanges() { }
|
||||
|
||||
public static final HttpOriginRange ALL = akka.http.scaladsl.model.headers.HttpOriginRange.$times$.MODULE$;
|
||||
}
|
||||
|
|
@ -11,5 +11,12 @@ public interface LanguageRange {
|
|||
public abstract Iterable<String> getSubTags();
|
||||
public abstract LanguageRange withQValue(float qValue);
|
||||
|
||||
/**
|
||||
* @deprecated because of troublesome initialisation order (with regards to scaladsl class implementing this class).
|
||||
* In some edge cases this field could end up containing a null value.
|
||||
* Will be removed in Akka 3.x, use {@link LanguageRanges#ALL} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
// FIXME: Remove in Akka 3.0
|
||||
public static final LanguageRange ALL = akka.http.scaladsl.model.headers.LanguageRange.$times$.MODULE$;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
/*
|
||||
* Copyright (C) 2009-2016 Lightbend Inc. <http://www.lightbend.com>
|
||||
*/
|
||||
|
||||
package akka.http.javadsl.model.headers;
|
||||
|
||||
public class LanguageRanges {
|
||||
private LanguageRanges() { }
|
||||
|
||||
public static final LanguageRange ALL = akka.http.scaladsl.model.headers.LanguageRange.$times$.MODULE$;
|
||||
}
|
||||
|
|
@ -7,6 +7,8 @@ import java.util.Optional
|
|||
|
||||
/**
|
||||
* Represents an Http content-type. A content-type consists of a media-type and an optional charset.
|
||||
*
|
||||
* See [[ContentTypes]] for convenience access to often used values.
|
||||
*/
|
||||
// Has to be defined in Scala even though it's JavaDSL because of:
|
||||
// https://issues.scala-lang.org/browse/SI-9621
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ package akka.http.javadsl.model
|
|||
/**
|
||||
* Represents an Http media-type. A media-type consists of a main-type and a sub-type.
|
||||
*
|
||||
* See [[MediaTypes]] for convenience access to often used values.
|
||||
*/
|
||||
// Has to be defined in Scala even though it's JavaDSL because of:
|
||||
// https://issues.scala-lang.org/browse/SI-9621
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue