org.apache.ibatis.mapping.ResultMap Maven / Gradle / Ivy
package org.apache.ibatis.mapping;
import java.util.*;
public class ResultMap {
private String id;
private Class type;
private List resultMappings;
private List idResultMappings;
private List constructorResultMappings;
private List propertyResultMappings;
private Discriminator discriminator;
private ResultMap() {
}
public static class Builder {
private ResultMap resultMap = new ResultMap();
public Builder(Configuration configuration, String id, Class type, List resultMappings) {
resultMap.id = id;
resultMap.type = type;
resultMap.resultMappings = resultMappings;
}
public Builder discriminator(Discriminator discriminator) {
resultMap.discriminator = discriminator;
return this;
}
public Class type() {
return resultMap.type;
}
public ResultMap build() {
resultMap.idResultMappings = new ArrayList();
resultMap.constructorResultMappings = new ArrayList();
resultMap.propertyResultMappings = new ArrayList();
for (ResultMapping resultMapping : resultMap.resultMappings) {
if (resultMapping.getFlags().contains(ResultFlag.CONSTRUCTOR)) {
resultMap.constructorResultMappings.add(resultMapping);
} else {
resultMap.propertyResultMappings.add(resultMapping);
}
if (resultMapping.getFlags().contains(ResultFlag.ID)) {
resultMap.idResultMappings.add(resultMapping);
}
}
if (resultMap.idResultMappings.isEmpty()) {
resultMap.idResultMappings.addAll(resultMap.resultMappings);
}
// lock down collections
resultMap.resultMappings = Collections.unmodifiableList(resultMap.resultMappings);
resultMap.idResultMappings = Collections.unmodifiableList(resultMap.idResultMappings);
resultMap.constructorResultMappings = Collections.unmodifiableList(resultMap.constructorResultMappings);
resultMap.propertyResultMappings = Collections.unmodifiableList(resultMap.propertyResultMappings);
return resultMap;
}
}
public String getId() {
return id;
}
public Class getType() {
return type;
}
public List getResultMappings() {
return resultMappings;
}
public List getConstructorResultMappings() {
return constructorResultMappings;
}
public List getPropertyResultMappings() {
return propertyResultMappings;
}
public List getIdResultMappings() {
return idResultMappings;
}
public Discriminator getDiscriminator() {
return discriminator;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy