blob: b91b66e0f4fc2d364a541aa7ba7d0853a0b7ad11 [file] [log] [blame]
ADARA Networks1fb1eb12016-09-01 12:04:07 -07001/*
2 * Copyright 2016-present Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.rabbitmq.impl;
17
18import java.io.Serializable;
19import java.util.Map;
20
21import static com.google.common.base.Preconditions.checkNotNull;
22
23/**
24 * Represents message context like data in byte stream and mq properties for
25 * message delivery.
26 */
27public class MessageContext implements Serializable {
28 private static final long serialVersionUID = -4174900539976805047L;
29 private static final String NULL_ERR =
30 "The body and properties should be present";
31
32 private final Map<String, Object> properties;
33 private final byte[] body;
34
35 /**
36 * Initializes MessageContext class.
37 *
38 * @param body Byte stream of the event's JSON data
39 * @param properties Map of the Message Queue properties
40 */
41 public MessageContext(byte[] body, Map<String, Object> properties) {
42 this.body = checkNotNull(body, NULL_ERR);
43 this.properties = checkNotNull(properties, NULL_ERR);
44 }
45
46 /**
47 * Returns the Message Properties Map.
48 *
49 * @return Map of the Message Queue properties
50 */
51
52 public Map<String, Object> getProperties() {
53 return properties;
54 }
55
56 /**
57 * Returns the Message Properties Map.
58 *
59 * @return Byte stream of the event's JSON data
60 */
61 public byte[] getBody() {
62 return body;
63 }
64}