![JAR search and dependency download from the Maven repository](/logo.png)
io.ebean.WhenFind Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ebean-mocker Show documentation
Show all versions of ebean-mocker Show documentation
Ability to set a Mockito mock EbeanServer as 'default' EbeanServer
package io.ebean;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Created by rob on 16/07/15.
*/
public class WhenFind {
List> byId = new ArrayList<>();
Map, WhenBeanReturn>> byUnique = new HashMap<>();
public WhenBeanReturn byId(Class beanType) {
return byId(beanType, null);
}
public WhenBeanReturn byId(Class beanType, Object id) {
WhenBeanReturn ret = new WhenBeanReturn<>(beanType, id);
byId.add(ret);
return ret;
}
public WhenBeanReturn byUnique(Class beanType) {
WhenBeanReturn ret = new WhenBeanReturn<>(beanType);
byUnique.put(beanType, ret);
return ret;
}
@SuppressWarnings("unchecked")
protected WhenBeanReturn findMatchByUnique(Class beanType) {
return (WhenBeanReturn) byUnique.get(beanType);
}
@SuppressWarnings("unchecked")
protected WhenBeanReturn findMatchById(Class beanType, Object id) {
for (WhenBeanReturn> byIdReturn : byId) {
if (byIdReturn.isMatch(beanType, id)){
return (WhenBeanReturn) byIdReturn;
}
}
for (WhenBeanReturn> byIdReturn : byId) {
if (byIdReturn.isMatch(beanType)){
return (WhenBeanReturn) byIdReturn;
}
}
// no match
return null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy