=htc add missing Java model class for ContentTypeRange

This commit is contained in:
Johannes Rudolph 2015-08-25 15:05:48 +02:00
parent 2eb6cea683
commit a70e37d65c
3 changed files with 28 additions and 2 deletions

View file

@ -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();
}

View file

@ -156,6 +156,7 @@ private[http] object JavaMapping {
implicit object DateTime extends Inherited[jm.DateTime, akka.http.scaladsl.model.DateTime]
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 HttpCharset extends Inherited[jm.HttpCharset, sm.HttpCharset]
implicit object HttpCharsetRange extends Inherited[jm.HttpCharsetRange, sm.HttpCharsetRange]

View file

@ -10,8 +10,8 @@ import akka.japi.{ Option ⇒ JOption }
import akka.http.javadsl.{ model jm }
import akka.http.impl.util.JavaMapping.Implicits._
final case class ContentTypeRange(mediaRange: MediaRange, charsetRange: HttpCharsetRange) extends ValueRenderable {
def matches(contentType: ContentType) =
final case class ContentTypeRange(mediaRange: MediaRange, charsetRange: HttpCharsetRange) extends jm.ContentTypeRange with ValueRenderable {
def matches(contentType: jm.ContentType) =
mediaRange.matches(contentType.mediaType) && charsetRange.matches(contentType.charset)
def render[R <: Rendering](r: R): r.type = charsetRange match {