org.apache.ibatis.mapping.Discriminator Maven / Gradle / Ivy
The newest version!
package org.apache.ibatis.mapping;
import org.apache.ibatis.session.Configuration;
import java.util.Collections;
import java.util.Map;
public class Discriminator {
private ResultMapping resultMapping;
private Map discriminatorMap;
private Discriminator() {
}
public static class Builder {
private Discriminator discriminator = new Discriminator();
public Builder(Configuration configuration, ResultMapping resultMapping, Map discriminatorMap) {
discriminator.resultMapping = resultMapping;
discriminator.discriminatorMap = discriminatorMap;
}
public Discriminator build() {
assert discriminator.resultMapping != null;
assert discriminator.discriminatorMap != null;
assert discriminator.discriminatorMap.size() > 0;
//lock down map
discriminator.discriminatorMap = Collections.unmodifiableMap(discriminator.discriminatorMap);
return discriminator;
}
}
public ResultMapping getResultMapping() {
return resultMapping;
}
public Map getDiscriminatorMap() {
return discriminatorMap;
}
public String getMapIdFor(String s) {
return discriminatorMap.get(s);
}
}