View Javadoc

1   /*
2   Copyright 2011-2014 AGH-UST, http://www.agh.edu.pl
3   Faculty of Computer Science, Electronics and Telecommunications
4   Department of Computer Science 
5   
6   See the NOTICE file distributed with this work for additional
7   information regarding copyright ownership
8   
9   Licensed under the Apache License, Version 2.0 (the "License");
10  you may not use this file except in compliance with the License.
11  You may obtain a copy of the License at
12  
13    http://www.apache.org/licenses/LICENSE-2.0
14  
15  Unless required by applicable law or agreed to in writing, software
16  distributed under the License is distributed on an "AS IS" BASIS,
17  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  See the License for the specific language governing permissions and
19  limitations under the License.
20  */
21  package org.universAAL.ri.gateway.communicator.service;
22  
23  import java.io.Serializable;
24  
25  /**
26   * This class represents a generic message sent between inside and outside world
27   * of AALSpace.
28   * 
29   * @author skallz
30   */
31  public class Message implements Serializable {
32  
33      /**
34       * 
35       */
36      private static final long serialVersionUID = -2259161945843015685L;
37  
38      /**
39       * Content of the message.
40       */
41      private Object content;
42      
43      private String remoteProxyRegistrationId;
44      
45      private String remoteMemberId;
46      
47      /**
48       * Initializes with a message to send.
49       * 
50       * @param content
51       *            content of the message
52       */
53      public Message(final Object content) {
54  	this.content = content;
55      }
56  
57      /**
58       * Returns content of the message.
59       * 
60       * @return content of the message
61       */
62      public Object getContent() {
63  	return content;
64      }
65  
66      @Override
67      public String toString() {
68  	if (content != null) {
69  	    return "content: " + content.toString();
70  	} else {
71  	    return "content: " + "null";
72  	}
73      }
74  
75      @Override
76      public boolean equals(final Object obj) {
77  	if (obj == null || !(obj instanceof Message)) {
78  	    return false;
79  	}
80  	Message o = (Message) obj;
81  	if (content == null && o.content == null) {
82  	    return true;
83  	}
84  	return content.equals(o.content);
85      }
86  
87      @Override
88      public int hashCode() {
89  	if (content == null) {
90  	    return 0;
91  	}
92  	return content.hashCode();
93      }
94  
95      public String getRemoteProxyRegistrationId() {
96  	return remoteProxyRegistrationId;
97      }
98  
99      public void setRemoteProxyRegistrationId(String remoteProxyRegistrationId) {
100 	this.remoteProxyRegistrationId = remoteProxyRegistrationId;
101     }
102 
103 	public String getRemoteMemberId() {
104 		return remoteMemberId;
105 	}
106 
107 	public void setRemoteMemberId(String remoteMemberId) {
108 		this.remoteMemberId = remoteMemberId;
109 	}
110 
111 }