From 9fd543bff0ff5c9458a14b2bedceedad3c4c2be3 Mon Sep 17 00:00:00 2001 From: Konrad Malawski Date: Thu, 14 Jan 2016 14:25:43 +0100 Subject: [PATCH] =htc #19418 avoid LUB calculation problem, see SI-9621 --- .../akka/http/javadsl/model/MediaType.java | 67 ---------------- .../akka/http/javadsl/model/MediaType.scala | 77 +++++++++++++++++++ 2 files changed, 77 insertions(+), 67 deletions(-) delete mode 100644 akka-http-core/src/main/java/akka/http/javadsl/model/MediaType.java create mode 100644 akka-http-core/src/main/scala/akka/http/javadsl/model/MediaType.scala diff --git a/akka-http-core/src/main/java/akka/http/javadsl/model/MediaType.java b/akka-http-core/src/main/java/akka/http/javadsl/model/MediaType.java deleted file mode 100644 index b53721cc38..0000000000 --- a/akka-http-core/src/main/java/akka/http/javadsl/model/MediaType.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Copyright (C) 2009-2014 Typesafe Inc. - */ - -package akka.http.javadsl.model; - -/** - * Represents an Http media-type. A media-type consists of a main-type and a sub-type. - */ -public interface MediaType { - - /** - * The main-type of this media-type. - */ - String mainType(); - - /** - * The sub-type of this media-type. - */ - String subType(); - - /** - * True when this media-type is generally compressible. - */ - boolean isCompressible(); - - /** - * True when this media-type is not character-based. - */ - boolean binary(); - - boolean isApplication(); - boolean isAudio(); - boolean isImage(); - boolean isMessage(); - boolean isMultipart(); - boolean isText(); - boolean isVideo(); - - /** - * Creates a media-range from this media-type. - */ - MediaRange toRange(); - - /** - * Creates a media-range from this media-type with a given qValue. - */ - MediaRange toRange(float qValue); - - interface Binary extends MediaType { - ContentType.Binary toContentType(); - } - - interface NonBinary extends MediaType { - } - - interface WithFixedCharset extends NonBinary { - ContentType.WithFixedCharset toContentType(); - } - - interface WithOpenCharset extends NonBinary { - ContentType.WithCharset toContentType(HttpCharset charset); - } - - interface Multipart extends WithOpenCharset { - } -} diff --git a/akka-http-core/src/main/scala/akka/http/javadsl/model/MediaType.scala b/akka-http-core/src/main/scala/akka/http/javadsl/model/MediaType.scala new file mode 100644 index 0000000000..06101fb9f4 --- /dev/null +++ b/akka-http-core/src/main/scala/akka/http/javadsl/model/MediaType.scala @@ -0,0 +1,77 @@ +/** + * Copyright (C) 2009-2014 Typesafe Inc. + */ +package akka.http.javadsl.model + +/** + * Represents an Http media-type. A media-type consists of a main-type and a sub-type. + * + * Has to be defined in Scala even though it's JavaDSL because of: https://issues.scala-lang.org/browse/SI-9621 + */ +object MediaType { + + trait Binary extends MediaType { + def toContentType: ContentType.Binary + } + + trait NonBinary extends MediaType { + } + + trait WithFixedCharset extends NonBinary { + def toContentType: ContentType.WithFixedCharset + } + + trait WithOpenCharset extends NonBinary { + def toContentType(charset: HttpCharset): ContentType.WithCharset + } + + trait Multipart extends WithOpenCharset { + } + +} + +trait MediaType { + /** + * The main-type of this media-type. + */ + def mainType: String + + /** + * The sub-type of this media-type. + */ + def subType: String + + /** + * True when this media-type is generally compressible. + */ + def isCompressible: Boolean + + /** + * True when this media-type is not character-based. + */ + def binary: Boolean + + def isApplication: Boolean + + def isAudio: Boolean + + def isImage: Boolean + + def isMessage: Boolean + + def isMultipart: Boolean + + def isText: Boolean + + def isVideo: Boolean + + /** + * Creates a media-range from this media-type. + */ + def toRange: MediaRange + + /** + * Creates a media-range from this media-type with a given qValue. + */ + def toRange(qValue: Float): MediaRange +}