fixed warning, usage of 2.8 features: default arguments and generated copy method.
This commit is contained in:
parent
73c70acb7e
commit
733ce7d9c2
4 changed files with 10 additions and 15 deletions
|
|
@ -14,12 +14,7 @@ import org.apache.camel.util.ExchangeHelper
|
|||
*
|
||||
* @author Martin Krasser
|
||||
*/
|
||||
case class Message(val body: Any, val headers: Map[String, Any]) {
|
||||
/**
|
||||
* Creates a message with a body and an empty header map.
|
||||
*/
|
||||
def this(body: Any) = this(body, Map.empty)
|
||||
|
||||
case class Message(val body: Any, val headers: Map[String, Any] = Map.empty) {
|
||||
/**
|
||||
* Returns the body of the message converted to the type given by the <code>clazz</code>
|
||||
* argument. Conversion is done using Camel's type converter. The type converter is obtained
|
||||
|
|
@ -56,23 +51,23 @@ case class Message(val body: Any, val headers: Map[String, Any]) {
|
|||
/**
|
||||
* Creates a new Message with new <code>headers</code>.
|
||||
*/
|
||||
def setHeaders(headers: Map[String, Any]) = new Message(this.body, headers)
|
||||
def setHeaders(headers: Map[String, Any]) = copy(this.body, headers)
|
||||
|
||||
/**
|
||||
* Creates a new Message with the <code>headers</code> argument added to the existing headers.
|
||||
*/
|
||||
def addHeaders(headers: Map[String, Any]) = new Message(this.body, this.headers ++ headers)
|
||||
def addHeaders(headers: Map[String, Any]) = copy(this.body, this.headers ++ headers)
|
||||
|
||||
/**
|
||||
* Creates a new Message with the <code>header</code> argument added to the existing headers.
|
||||
*/
|
||||
def addHeader(header: (String, Any)) = new Message(this.body, this.headers + header)
|
||||
def addHeader(header: (String, Any)) = copy(this.body, this.headers + header)
|
||||
|
||||
/**
|
||||
* Creates a new Message where the header with name <code>headerName</code> is removed from
|
||||
* the existing headers.
|
||||
*/
|
||||
def removeHeader(headerName: String) = new Message(this.body, this.headers - headerName)
|
||||
def removeHeader(headerName: String) = copy(this.body, this.headers - headerName)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -113,7 +108,7 @@ object Message {
|
|||
*
|
||||
* @author Martin Krasser
|
||||
*/
|
||||
case class Failure(val cause: Exception, val headers: Map[String, Any])
|
||||
case class Failure(val cause: Exception, val headers: Map[String, Any] = Map.empty)
|
||||
|
||||
/**
|
||||
* Adapter for converting an org.apache.camel.Exchange to and from Message and Failure objects.
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ class ActorProducer(val ep: ActorEndpoint) extends DefaultProducer(ep) {
|
|||
private def targetById(id: String) = ActorRegistry.actorsFor(id) match {
|
||||
case Nil => None
|
||||
case actor :: Nil => Some(actor)
|
||||
case actors => Some(actors.first)
|
||||
case actors => Some(actors.head)
|
||||
}
|
||||
|
||||
private def targetByUuid(uuid: String) = ActorRegistry.actorFor(uuid)
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ class ConsumerPublisher extends Actor with Logging {
|
|||
* @param endpointUri endpoint URI of the consumer actor
|
||||
* @param id actor identifier
|
||||
* @param uuid <code>true</code> if <code>id</code> refers to Actor.uuid, <code>false</code> if
|
||||
* <code>id</code> refers to Acotr.getId.
|
||||
* <code>id</code> refers to Actor.getId.
|
||||
*
|
||||
* @author Martin Krasser
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -26,9 +26,9 @@ class CamelExchangeAdapterTest extends JUnitSuite {
|
|||
}
|
||||
|
||||
@Test def shouldSetExceptionFromFailureMessage = {
|
||||
val e1 = sampleInOnly.fromFailureMessage(Failure(new Exception("test1"), Map.empty))
|
||||
val e1 = sampleInOnly.fromFailureMessage(Failure(new Exception("test1")))
|
||||
assert(e1.getException.getMessage === "test1")
|
||||
val e2 = sampleInOut.fromFailureMessage(Failure(new Exception("test2"), Map.empty))
|
||||
val e2 = sampleInOut.fromFailureMessage(Failure(new Exception("test2")))
|
||||
assert(e2.getException.getMessage === "test2")
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue