All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.google.common.cache.DeepCacheBuilder Maven / Gradle / Ivy

There is a newer version: 5.3.2
Show newest version
package com.google.common.cache;

import com.google.common.base.Equivalence;

import static com.google.common.base.DeepEquivalence.DEEP_EQUIVALENCE;

public class DeepCacheBuilder {
		
	/**
	 * 为{@link CacheBuilder}实例指定KEY执行深度比较
	 * @param builder
	 * @return always builder
	 * @since 3.32.0
	 */
	public static final CacheBuilder keyDeepEqual(CacheBuilder builder){
		if(builder != null){
			builder.keyEquivalence(DEEP_EQUIVALENCE);
		}
		return builder;
	}
	/**
	 * 为{@link CacheBuilder}实例指定VALUE执行深度比较
	 * @param builder
	 * @return always builder
	 * @since 3.32.0
	 */
	public static final CacheBuilder valueDeepEqual(CacheBuilder builder){
		if(builder != null){
			builder.valueEquivalence(DEEP_EQUIVALENCE);
		}
		return builder;
	}
	public static final CacheBuilder newBuilder(){
		return newBuilder(DEEP_EQUIVALENCE,DEEP_EQUIVALENCE);
	}
	public static final CacheBuilder newBuilder(
			Equivalence keyEquivalence,
			Equivalence valueEquivalence){
		CacheBuilder builder = CacheBuilder.newBuilder();
		if(keyEquivalence != null){
			builder.keyEquivalence(keyEquivalence);
		}
		if(valueEquivalence != null){
			builder.valueEquivalence(valueEquivalence);	
		}
		return builder;
	}
}