org.gradle.cache.PersistentIndexedCacheParameters Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gradle-tooling-api Show documentation
Show all versions of gradle-tooling-api Show documentation
Gradle Tooling API - the programmatic API to invoke Gradle
The newest version!
/*
* Copyright 2011 the original author or authors.
*
* 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.
*/
package org.gradle.cache;
import org.gradle.internal.serialize.BaseSerializerFactory;
import org.gradle.internal.serialize.Serializer;
import javax.annotation.Nullable;
public class PersistentIndexedCacheParameters {
private static final BaseSerializerFactory SERIALIZER_FACTORY = new BaseSerializerFactory();
private final String cacheName;
private final Serializer keySerializer;
private final Serializer valueSerializer;
private final CacheDecorator cacheDecorator;
public static PersistentIndexedCacheParameters of(String cacheName, Serializer keySerializer, Serializer valueSerializer) {
return new PersistentIndexedCacheParameters(cacheName, keySerializer, valueSerializer, null);
}
public static PersistentIndexedCacheParameters of(String cacheName, Class keyType, Serializer valueSerializer) {
return new PersistentIndexedCacheParameters(cacheName, SERIALIZER_FACTORY.getSerializerFor(keyType), valueSerializer, null);
}
public static PersistentIndexedCacheParameters of(String cacheName, Class keyType, Class valueType) {
return new PersistentIndexedCacheParameters(cacheName, SERIALIZER_FACTORY.getSerializerFor(keyType), SERIALIZER_FACTORY.getSerializerFor(valueType), null);
}
private PersistentIndexedCacheParameters(String cacheName, Serializer keySerializer, Serializer valueSerializer, @Nullable CacheDecorator cacheDecorator) {
this.cacheName = cacheName;
this.keySerializer = keySerializer;
this.valueSerializer = valueSerializer;
this.cacheDecorator = cacheDecorator;
}
public String getCacheName() {
return cacheName;
}
public Serializer getKeySerializer() {
return keySerializer;
}
public Serializer getValueSerializer() {
return valueSerializer;
}
@Nullable
public CacheDecorator getCacheDecorator() {
return cacheDecorator;
}
public PersistentIndexedCacheParameters withCacheDecorator(CacheDecorator cacheDecorator) {
return new PersistentIndexedCacheParameters(cacheName, keySerializer, valueSerializer, cacheDecorator);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy