com.github.andyshaox.jdbc.DaoDetectorCach Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of GearEE Show documentation
Show all versions of GearEE Show documentation
Enhance and formating the coding of JDK
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;
}
}