View Javadoc

1   /*
2    * Copyright 2001-2004 The Apache Software Foundation
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  package org.apache.commons.cache.remote;
17  
18  import java.io.Serializable;
19  
20  /**
21   * tk.
22   *
23   * @version $Id: StoreRequest.java 155435 2005-02-26 13:17:27Z dirkv $
24   * @author Rodney Waldhoff
25   */
26  public class StoreRequest implements CacheRequest {
27    protected Serializable _key = null;
28    protected Serializable _val = null;
29    protected Serializable _group = null;
30    protected Long _expiry = null;
31    protected Long _cost = null;
32  
33    public StoreRequest(Serializable key, Serializable val, Long expiry) {
34      this(key,val,expiry,(Long)null,(Serializable)null);
35    }
36  
37    public StoreRequest(Serializable key, Serializable val, Long expiry, Long cost) {
38      this(key,val,expiry,cost,(Serializable)null);
39    }
40  
41    public StoreRequest(Serializable key, Serializable val, Long expiry, Long cost, Serializable group) {
42      _key = key;
43      _val = val;
44      _expiry = expiry;
45      _cost = cost;
46      _group = group;
47    }
48  
49    public Serializable getKey() {
50      return _key;
51    }
52  
53    public Serializable getValue() {
54      return _val;
55    }
56  
57    public Serializable getGroup() {
58      return _group;
59    }
60  
61    public Long getExpiresAt() {
62      return _expiry;
63    }
64  
65    public Long getCost() {
66      return _cost;
67    }
68  
69    public boolean equals(StoreRequest req) {
70      return ( (null != req)
71               && (null == req.getKey()       ? null == _key    : _key.equals(req.getKey()))
72               && (null == req.getGroup()     ? null == _group  : _group.equals(req.getGroup()))
73               && (null == req.getExpiresAt() ? null == _expiry : _expiry.equals(req.getExpiresAt()))
74               && (null == req.getCost()      ? null == _cost   : _cost.equals(req.getCost()))
75               && (null == req.getValue()     ? null == _val    : _val.equals(req.getValue()))
76             );
77    }
78  
79    public int hashCode() {
80      return (null == _key ? -1 : _key.hashCode());
81    }
82  }