• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2009 Google Inc.  All rights reserved.
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  */
16 
17 package com.google.polo.pairing.message;
18 
19 /**
20  * Object implementing the internal representation of the protocol message
21  * 'PAIRING_REQUEST'.
22  */
23 public class PairingRequestAckMessage extends PoloMessage {
24 
25   /**
26    * Server name.
27    */
28   private final String mServerName;
29 
PairingRequestAckMessage()30   public PairingRequestAckMessage() {
31     this(null);
32   }
33 
PairingRequestAckMessage(String serverName)34   public PairingRequestAckMessage(String serverName) {
35     super(PoloMessage.PoloMessageType.PAIRING_REQUEST_ACK);
36     mServerName = serverName;
37   }
38 
getServerName()39   public String getServerName() {
40     return mServerName;
41   }
42 
hasServerName()43   public boolean hasServerName() {
44     return mServerName != null;
45   }
46 
47   @Override
toString()48   public String toString() {
49     return new StringBuilder()
50         .append("[")
51         .append(getType())
52         .append(" server_name=")
53         .append(mServerName)
54         .append("]").toString();
55   }
56 
57   @Override
equals(Object obj)58   public boolean equals(Object obj) {
59     if (this == obj) {
60       return true;
61     }
62 
63     if (!(obj instanceof PairingRequestAckMessage)) {
64       return false;
65     }
66 
67     PairingRequestAckMessage other = (PairingRequestAckMessage) obj;
68 
69     if (mServerName == null) {
70       if (other.mServerName != null) {
71         return false;
72       }
73     } else if (!mServerName.equals(other.mServerName)) {
74       return false;
75     }
76     return true;
77   }
78 
79 }
80