com.jpattern.orm.classmapper.ClassMapper Maven / Gradle / Ivy
package com.jpattern.orm.classmapper;
import java.util.Map;
/**
*
* @author Francesco Cina
*
* 22/mag/2011
*/
public class ClassMapper implements IClassMapper {
/**
*
*/
private final Class mappedClass;
private final Map fieldColumnMapping;
private String[] allColumnJavaNames = new String[0];
private String[] allNotGeneratedColumnJavaNames = new String[0];
private String[] primaryKeyColumnJavaNames = new String[0];
private String[] primaryKeyAndVersionColumnJavaNames = new String[0];
private String[] notPrimaryKeyColumnJavaNames = new String[0];
private String[] allGeneratedColumnJavaNames = new String[0];
private String[] allGeneratedColumnDBNames = new String[0];
private final ITableMap tableMap;
// private IOrmLogger logger = OrmLogger.getOrmLogger(this.getClass());
public ClassMapper(Class mappedClass, ITableMap tableMap, Map fieldColumnMapping) {
this.mappedClass = mappedClass;
this.tableMap = tableMap;
this.fieldColumnMapping = fieldColumnMapping;
}
@Override
public Class getMappedClass() {
return mappedClass;
}
@Override
public IColumn getColumnWithJavaName(String javaName) {
if (fieldColumnMapping.containsKey(javaName)) {
return fieldColumnMapping.get(javaName);
}
return new NullColumn();
}
@Override
public String[] getAllColumnJavaNames() {
return allColumnJavaNames;
}
@Override
public String[] getPrimaryKeyColumnJavaNames() {
return primaryKeyColumnJavaNames;
}
@Override
public String[] getNotPrimaryKeyColumnJavaNames() {
return notPrimaryKeyColumnJavaNames;
}
public void setAllColumnJavaNames(String[] allColumnJavaNames) {
this.allColumnJavaNames = allColumnJavaNames;
}
public void setPrimaryKeyColumnJavaNames(String[] primaryKeyColumnJavaNames) {
this.primaryKeyColumnJavaNames = primaryKeyColumnJavaNames;
}
public void setNotPrimaryKeyColumnJavaNames(String[] notPrimaryKeyColumnJavaNames) {
this.notPrimaryKeyColumnJavaNames = notPrimaryKeyColumnJavaNames;
}
@Override
public ITableMap getTableMap() {
return tableMap;
}
public void setAllNotGeneratedColumnJavaNames(String[] allNotGeneratedColumnJavaNames) {
this.allNotGeneratedColumnJavaNames = allNotGeneratedColumnJavaNames;
}
@Override
public String[] getAllNotGeneratedColumnJavaNames() {
return allNotGeneratedColumnJavaNames;
}
public void setAllGeneratedColumnJavaNames(String[] allGeneratedColumnJavaNames) {
this.allGeneratedColumnJavaNames = allGeneratedColumnJavaNames;
}
@Override
public String[] getAllGeneratedColumnJavaNames() {
return allGeneratedColumnJavaNames;
}
public void setAllGeneratedColumnDBNames(String[] allGeneratedColumnDBNames) {
this.allGeneratedColumnDBNames = allGeneratedColumnDBNames;
}
@Override
public String[] getAllGeneratedColumnDBNames() {
return allGeneratedColumnDBNames;
}
public void setPrimaryKeyAndVersionColumnJavaNames(
String[] primaryKeyAndVersionColumnJavaNames) {
this.primaryKeyAndVersionColumnJavaNames = primaryKeyAndVersionColumnJavaNames;
}
@Override
public String[] getPrimaryKeyAndVersionColumnJavaNames() {
return primaryKeyAndVersionColumnJavaNames;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy