org.simpleflatmapper.jdbc.impl.ColumnMeta Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sfm-jdbc Show documentation
Show all versions of sfm-jdbc Show documentation
Java library to map flat record - ResultSet, csv - to java object with minimum configuration and low footprint.
package org.simpleflatmapper.jdbc.impl;
import org.simpleflatmapper.jdbc.JdbcColumnKey;
import org.simpleflatmapper.map.property.AutoGeneratedProperty;
public class ColumnMeta {
private final String column;
private final int sqlType;
private final boolean key;
private final AutoGeneratedProperty generated;
public ColumnMeta(String column, int sqlType, boolean key, AutoGeneratedProperty generated) {
this.column = column;
this.sqlType = sqlType;
this.key = key;
this.generated = generated;
}
public String getColumn() {
return column;
}
public int getSqlType() {
return sqlType;
}
public boolean isKey() {
return key;
}
public boolean isGenerated() {
return generated != null;
}
public JdbcColumnKey toJdbcColumnKey(int index) {
return new JdbcColumnKey(column, index, sqlType);
}
public boolean isInsertable() {
return generated == null || generated.getExpression() != null;
}
public String getInsertExpression() {
return generated == null ? "?" : generated.getExpression();
}
}