00001 /* 00002 * Copyright (C) 2011 Google Inc. 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 00005 * use this file except in compliance with the License. You may obtain a copy of 00006 * the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 00012 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 00013 * License for the specific language governing permissions and limitations under 00014 * the License. 00015 */ 00016 00017 package org.ros.internal.message.topic; 00018 00019 import org.ros.message.MessageDeclaration; 00020 import org.ros.message.MessageIdentifier; 00021 00027 public class TopicDescription extends MessageDeclaration { 00028 00029 private final String md5Checksum; 00030 00031 public TopicDescription(String type, String definition, String md5Checksum) { 00032 super(MessageIdentifier.of(type), definition); 00033 this.md5Checksum = md5Checksum; 00034 } 00035 00036 public String getMd5Checksum() { 00037 return md5Checksum; 00038 } 00039 00040 @Override 00041 public String toString() { 00042 return "TopicDescription<" + getType() + ", " + md5Checksum + ">"; 00043 } 00044 00045 @Override 00046 public int hashCode() { 00047 final int prime = 31; 00048 int result = super.hashCode(); 00049 result = prime * result + ((md5Checksum == null) ? 0 : md5Checksum.hashCode()); 00050 return result; 00051 } 00052 00053 @Override 00054 public boolean equals(Object obj) { 00055 if (this == obj) 00056 return true; 00057 if (!super.equals(obj)) 00058 return false; 00059 if (getClass() != obj.getClass()) 00060 return false; 00061 TopicDescription other = (TopicDescription) obj; 00062 if (md5Checksum == null) { 00063 if (other.md5Checksum != null) 00064 return false; 00065 } else if (!md5Checksum.equals(other.md5Checksum)) 00066 return false; 00067 return true; 00068 } 00069 }