1 package org.apache.archiva.rest.api.model.v2;
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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
21 import io.swagger.v3.oas.annotations.media.Schema;
23 import javax.xml.bind.annotation.XmlRootElement;
24 import java.io.Serializable;
27 * @author Olivier Lamy
28 * @author Martin Stockhammer
31 @XmlRootElement( name = "cacheConfiguration" )
32 @Schema(name="CacheConfiguration",description = "Cache configuration attributes")
33 public class CacheConfiguration
34 implements Serializable
36 private static final long serialVersionUID = 5479989049980673894L;
40 private int timeToIdleSeconds = -1;
45 private int timeToLiveSeconds = -1;
48 * max elements in memory.
50 private int maxEntriesInMemory = -1;
53 * max elements on disk.
55 private int maxEntriesOnDisk = -1;
57 public CacheConfiguration()
62 public static CacheConfiguration of( org.apache.archiva.admin.model.beans.CacheConfiguration beanConfiguration ) {
63 CacheConfiguration newConfig = new CacheConfiguration( );
64 newConfig.setMaxEntriesInMemory( beanConfiguration.getMaxElementsInMemory() );
65 newConfig.setMaxEntriesOnDisk( beanConfiguration.getMaxElementsOnDisk() );
66 newConfig.setTimeToIdleSeconds( beanConfiguration.getTimeToIdleSeconds( ) );
67 newConfig.setTimeToLiveSeconds( beanConfiguration.getTimeToLiveSeconds( ) );
71 @Schema(name="time_to_idle_seconds", description = "The maximum number of seconds an element can exist in the cache without being accessed. "+
72 "The element expires at this limit and will no longer be returned from the cache.")
73 public int getTimeToIdleSeconds()
75 return timeToIdleSeconds;
78 public void setTimeToIdleSeconds( int timeToIdleSeconds )
80 this.timeToIdleSeconds = timeToIdleSeconds;
83 @Schema(name="time_to_live_seconds", description = "The maximum number of seconds an element can exist in the cache regardless of use. "+
84 "The element expires at this limit and will no longer be returned from the cache.")
85 public int getTimeToLiveSeconds()
87 return timeToLiveSeconds;
90 public void setTimeToLiveSeconds( int timeToLiveSeconds )
92 this.timeToLiveSeconds = timeToLiveSeconds;
95 @Schema(name="max_entries_in_memory", description = "The maximum cache entries to keep in memory. If the limit is reached, older entries will be evicted, or persisted on disk.")
96 public int getMaxEntriesInMemory()
98 return maxEntriesInMemory;
101 public void setMaxEntriesInMemory( int maxEntriesInMemory )
103 this.maxEntriesInMemory = maxEntriesInMemory;
106 @Schema(name="max_entries_on_disk", description = "The maximum cache entries to keep on disk. If the limit is reached, older entries will be evicted.")
107 public int getMaxEntriesOnDisk()
109 return maxEntriesOnDisk;
112 public void setMaxEntriesOnDisk( int maxEntriesOnDisk )
114 this.maxEntriesOnDisk = maxEntriesOnDisk;
118 public boolean equals( Object o )
120 if ( this == o ) return true;
121 if ( o == null || getClass( ) != o.getClass( ) ) return false;
123 CacheConfiguration that = (CacheConfiguration) o;
125 if ( timeToIdleSeconds != that.timeToIdleSeconds ) return false;
126 if ( timeToLiveSeconds != that.timeToLiveSeconds ) return false;
127 if ( maxEntriesInMemory != that.maxEntriesInMemory ) return false;
128 return maxEntriesOnDisk == that.maxEntriesOnDisk;
132 public int hashCode( )
134 int result = timeToIdleSeconds;
135 result = 31 * result + timeToLiveSeconds;
136 result = 31 * result + maxEntriesInMemory;
137 result = 31 * result + maxEntriesOnDisk;
142 public String toString()
144 final StringBuilder sb = new StringBuilder();
145 sb.append( "CacheConfiguration" );
146 sb.append( "{time_to_idle_seconds=" ).append( timeToIdleSeconds );
147 sb.append( ", time_to_live_seconds=" ).append( timeToLiveSeconds );
148 sb.append( ", max_elements_in_memory=" ).append( maxEntriesInMemory );
149 sb.append( ", max_elements_on_disk=" ).append( maxEntriesOnDisk );
151 return sb.toString();