This project has retired. For details please refer to its Attic page.
CacheEntry xref
View Javadoc
1   package org.apache.archiva.rest.api.model;
2   /*
3    * Licensed to the Apache Software Foundation (ASF) under one
4    * or more contributor license agreements.  See the NOTICE file
5    * distributed with this work for additional information
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  You may obtain a copy of the License at
10   *
11   *   http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing,
14   * software distributed under the License is distributed on an
15   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16   * KIND, either express or implied.  See the License for the
17   * specific language governing permissions and limitations
18   * under the License.
19   */
20  
21  import javax.xml.bind.annotation.XmlRootElement;
22  import java.io.Serializable;
23  
24  /**
25   * @author Olivier Lamy
26   * @since 1.4-M3
27   */
28  @XmlRootElement(name = "cacheEntry")
29  public class CacheEntry
30      implements Serializable, Comparable
31  {
32      private String key;
33  
34      private long size;
35  
36      private long cacheHits;
37  
38      private long cacheMiss;
39  
40      private String cacheHitRate;
41  
42      private long inMemorySize;
43  
44      public CacheEntry()
45      {
46          // no op
47      }
48  
49      public CacheEntry( String key, long size, long cacheHits, long cacheMiss, String cacheHitRate, long inMemorySize )
50      {
51          this.key = key;
52          this.size = size;
53          this.cacheHits = cacheHits;
54          this.cacheMiss = cacheMiss;
55          this.cacheHitRate = cacheHitRate;
56          // size is in bytes so use kb
57          this.inMemorySize = inMemorySize / 1024;
58      }
59  
60      public String getKey()
61      {
62          return key;
63      }
64  
65      public void setKey( String key )
66      {
67          this.key = key;
68      }
69  
70      public long getSize()
71      {
72          return size;
73      }
74  
75      public void setSize( long size )
76      {
77          this.size = size;
78      }
79  
80      public long getCacheHits()
81      {
82          return cacheHits;
83      }
84  
85      public void setCacheHits( long cacheHits )
86      {
87          this.cacheHits = cacheHits;
88      }
89  
90      public long getCacheMiss()
91      {
92          return cacheMiss;
93      }
94  
95      public void setCacheMiss( long cacheMiss )
96      {
97          this.cacheMiss = cacheMiss;
98      }
99  
100     public String getCacheHitRate()
101     {
102         return cacheHitRate;
103     }
104 
105     public void setCacheHitRate( String cacheHitRate )
106     {
107         this.cacheHitRate = cacheHitRate;
108     }
109 
110     /**
111      * @return cache size in kb
112      */
113     public long getInMemorySize()
114     {
115         return inMemorySize;
116     }
117 
118     public void setInMemorySize( long inMemorySize )
119     {
120         this.inMemorySize = inMemorySize;
121     }
122 
123     @Override
124     public int compareTo( Object o )
125     {
126         return this.key.compareTo( ( (CacheEntry) o ).key );
127     }
128 
129     @Override
130     public boolean equals( Object o )
131     {
132         if ( this == o )
133         {
134             return true;
135         }
136         if ( o == null || getClass() != o.getClass() )
137         {
138             return false;
139         }
140 
141         CacheEntry that = (CacheEntry) o;
142 
143         if ( !key.equals( that.key ) )
144         {
145             return false;
146         }
147 
148         return true;
149     }
150 
151     @Override
152     public int hashCode()
153     {
154         return key.hashCode();
155     }
156 
157     @Override
158     public String toString()
159     {
160         final StringBuilder sb = new StringBuilder();
161         sb.append( "CacheEntry" );
162         sb.append( "{key='" ).append( key ).append( '\'' );
163         sb.append( ", size=" ).append( size );
164         sb.append( ", cacheHits=" ).append( cacheHits );
165         sb.append( ", cacheMiss=" ).append( cacheMiss );
166         sb.append( ", cacheHitRate='" ).append( cacheHitRate ).append( '\'' );
167         sb.append( ", inMemorySize=" ).append( inMemorySize );
168         sb.append( '}' );
169         return sb.toString();
170     }
171 }