1 package org.apache.archiva.rest.api.v2.model;
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
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
20 import io.swagger.v3.oas.annotations.media.Schema;
22 import javax.xml.bind.annotation.XmlRootElement;
23 import java.io.Serializable;
26 * @author Olivier Lamy
27 * @author Martin Stockhammer
30 @XmlRootElement( name = "cacheConfiguration" )
31 @Schema(name="CacheConfiguration",description = "Cache configuration attributes")
32 public class CacheConfiguration
33 implements Serializable
35 private static final long serialVersionUID = 5479989049980673894L;
39 private int timeToIdleSeconds = -1;
44 private int timeToLiveSeconds = -1;
47 * max elements in memory.
49 private int maxEntriesInMemory = -1;
52 * max elements on disk.
54 private int maxEntriesOnDisk = -1;
56 public CacheConfiguration()
61 public static CacheConfiguration of( org.apache.archiva.admin.model.beans.CacheConfiguration beanConfiguration ) {
62 CacheConfiguration newConfig = new CacheConfiguration( );
63 newConfig.setMaxEntriesInMemory( beanConfiguration.getMaxElementsInMemory() );
64 newConfig.setMaxEntriesOnDisk( beanConfiguration.getMaxElementsOnDisk() );
65 newConfig.setTimeToIdleSeconds( beanConfiguration.getTimeToIdleSeconds( ) );
66 newConfig.setTimeToLiveSeconds( beanConfiguration.getTimeToLiveSeconds( ) );
70 @Schema(name="time_to_idle_seconds", description = "The maximum number of seconds an element can exist in the cache without being accessed. "+
71 "The element expires at this limit and will no longer be returned from the cache.")
72 public int getTimeToIdleSeconds()
74 return timeToIdleSeconds;
77 public void setTimeToIdleSeconds( int timeToIdleSeconds )
79 this.timeToIdleSeconds = timeToIdleSeconds;
82 @Schema(name="time_to_live_seconds", description = "The maximum number of seconds an element can exist in the cache regardless of use. "+
83 "The element expires at this limit and will no longer be returned from the cache.")
84 public int getTimeToLiveSeconds()
86 return timeToLiveSeconds;
89 public void setTimeToLiveSeconds( int timeToLiveSeconds )
91 this.timeToLiveSeconds = timeToLiveSeconds;
94 @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.")
95 public int getMaxEntriesInMemory()
97 return maxEntriesInMemory;
100 public void setMaxEntriesInMemory( int maxEntriesInMemory )
102 this.maxEntriesInMemory = maxEntriesInMemory;
105 @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.")
106 public int getMaxEntriesOnDisk()
108 return maxEntriesOnDisk;
111 public void setMaxEntriesOnDisk( int maxEntriesOnDisk )
113 this.maxEntriesOnDisk = maxEntriesOnDisk;
117 public boolean equals( Object o )
119 if ( this == o ) return true;
120 if ( o == null || getClass( ) != o.getClass( ) ) return false;
122 CacheConfiguration that = (CacheConfiguration) o;
124 if ( timeToIdleSeconds != that.timeToIdleSeconds ) return false;
125 if ( timeToLiveSeconds != that.timeToLiveSeconds ) return false;
126 if ( maxEntriesInMemory != that.maxEntriesInMemory ) return false;
127 return maxEntriesOnDisk == that.maxEntriesOnDisk;
131 public int hashCode( )
133 int result = timeToIdleSeconds;
134 result = 31 * result + timeToLiveSeconds;
135 result = 31 * result + maxEntriesInMemory;
136 result = 31 * result + maxEntriesOnDisk;
141 public String toString()
143 final StringBuilder sb = new StringBuilder();
144 sb.append( "CacheConfiguration" );
145 sb.append( "{time_to_idle_seconds=" ).append( timeToIdleSeconds );
146 sb.append( ", time_to_live_seconds=" ).append( timeToLiveSeconds );
147 sb.append( ", max_elements_in_memory=" ).append( maxEntriesInMemory );
148 sb.append( ", max_elements_on_disk=" ).append( maxEntriesOnDisk );
150 return sb.toString();