/* * (C) 2007-2012 Alibaba Group Holding Limited. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * Authors: * wuhua <wq163@163.com> , boyan <killme2008@gmail.com> */ package com.taobao.metamorphosis.network; import com.taobao.gecko.core.command.CommandHeader; import com.taobao.gecko.core.command.RequestCommand; /** * ����������� * * @author boyan * */ public abstract class AbstractRequestCommand implements RequestCommand, MetaEncodeCommand { private Integer opaque; private String topic; static final long serialVersionUID = -1L; public AbstractRequestCommand(final String topic, final Integer opaque) { super(); this.topic = topic; this.opaque = opaque; } @Override public CommandHeader getRequestHeader() { return this; } @Override public Integer getOpaque() { return this.opaque; } public void setOpaque(final Integer opaque) { this.opaque = opaque; } public String getTopic() { return this.topic; } public void setTopic(final String topic) { this.topic = topic; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + (this.opaque == null ? 0 : this.opaque.hashCode()); result = prime * result + (this.topic == null ? 0 : this.topic.hashCode()); return result; } @Override public boolean equals(final Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (this.getClass() != obj.getClass()) { return false; } final AbstractRequestCommand other = (AbstractRequestCommand) obj; if (this.opaque == null) { if (other.opaque != null) { return false; } } else if (!this.opaque.equals(other.opaque)) { return false; } if (this.topic == null) { if (other.topic != null) { return false; } } else if (!this.topic.equals(other.topic)) { return false; } return true; } }