com.github.andyshaox.jdbc.DaoDetectorCach Maven / Gradle / Ivy
package com.github.andyshaox.jdbc;
import java.util.HashMap;
import java.util.Map;
/**
*
* Title:
* Descript:
* Copyright: Copryright(c) Apr 21, 2016
* Encoding:UNIX UTF-8
*
* @author Andy.Shao
*
*/
public class DaoDetectorCach implements DaoDetector {
private DaoDetector daoDetector = null;
private final Map , Object> temp = new HashMap<>();
@SuppressWarnings("unchecked")
@Override
public T finding(Class clazz) {
if (this.temp.containsKey(clazz)) return (T) this.temp.get(clazz);
else {
if (this.daoDetector == null) return null;
T result = this.daoDetector.finding(clazz);
this.temp.put(clazz , result);
return result;
}
}
public void setDaoDetector(DaoDetector daoDetector) {
this.daoDetector = daoDetector;
}
}