=htc add missing Java model class for ContentTypeRange
This commit is contained in:
parent
2eb6cea683
commit
a70e37d65c
3 changed files with 28 additions and 2 deletions
|
|
@ -0,0 +1,25 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2009-2015 Typesafe Inc. <http://www.typesafe.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
package akka.http.javadsl.model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A data structure that combines an acceptable media range and an acceptable charset range into
|
||||||
|
* one structure to be used with unmarshalling.
|
||||||
|
*/
|
||||||
|
public abstract class ContentTypeRange {
|
||||||
|
public abstract MediaRange mediaRange();
|
||||||
|
|
||||||
|
public abstract HttpCharsetRange charsetRange();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if this range includes the given content type.
|
||||||
|
*/
|
||||||
|
public abstract boolean matches(ContentType contentType);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a ContentType instance which fits this range.
|
||||||
|
*/
|
||||||
|
public abstract ContentType specimen();
|
||||||
|
}
|
||||||
|
|
@ -156,6 +156,7 @@ private[http] object JavaMapping {
|
||||||
implicit object DateTime extends Inherited[jm.DateTime, akka.http.scaladsl.model.DateTime]
|
implicit object DateTime extends Inherited[jm.DateTime, akka.http.scaladsl.model.DateTime]
|
||||||
|
|
||||||
implicit object ContentType extends Inherited[jm.ContentType, sm.ContentType]
|
implicit object ContentType extends Inherited[jm.ContentType, sm.ContentType]
|
||||||
|
implicit object ContentTypeRange extends Inherited[jm.ContentTypeRange, sm.ContentTypeRange]
|
||||||
implicit object Host extends Inherited[jm.Host, sm.Uri.Host]
|
implicit object Host extends Inherited[jm.Host, sm.Uri.Host]
|
||||||
implicit object HttpCharset extends Inherited[jm.HttpCharset, sm.HttpCharset]
|
implicit object HttpCharset extends Inherited[jm.HttpCharset, sm.HttpCharset]
|
||||||
implicit object HttpCharsetRange extends Inherited[jm.HttpCharsetRange, sm.HttpCharsetRange]
|
implicit object HttpCharsetRange extends Inherited[jm.HttpCharsetRange, sm.HttpCharsetRange]
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@ import akka.japi.{ Option ⇒ JOption }
|
||||||
import akka.http.javadsl.{ model ⇒ jm }
|
import akka.http.javadsl.{ model ⇒ jm }
|
||||||
import akka.http.impl.util.JavaMapping.Implicits._
|
import akka.http.impl.util.JavaMapping.Implicits._
|
||||||
|
|
||||||
final case class ContentTypeRange(mediaRange: MediaRange, charsetRange: HttpCharsetRange) extends ValueRenderable {
|
final case class ContentTypeRange(mediaRange: MediaRange, charsetRange: HttpCharsetRange) extends jm.ContentTypeRange with ValueRenderable {
|
||||||
def matches(contentType: ContentType) =
|
def matches(contentType: jm.ContentType) =
|
||||||
mediaRange.matches(contentType.mediaType) && charsetRange.matches(contentType.charset)
|
mediaRange.matches(contentType.mediaType) && charsetRange.matches(contentType.charset)
|
||||||
|
|
||||||
def render[R <: Rendering](r: R): r.type = charsetRange match {
|
def render[R <: Rendering](r: R): r.type = charsetRange match {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue