All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.itsallcode.jdbc.resultset.generic.ColumnValue Maven / Gradle / Ivy

There is a newer version: 0.7.1
Show newest version
package org.itsallcode.jdbc.resultset.generic;

/**
 * Represents a generic column value.
 * 
 * @param type  column type
 * @param value column value
 */
public record ColumnValue(ColumnType type, Object value) {

    /**
     * Get the column value cast to the given type.
     * 
     * @param type expected type
     * @param   result type
     * @return value of the given type
     */
    public  T getValue(final Class type) {
        return cast(type);
    }

    /**
     * Get the column value as a string.
     * 
     * @return column value as string
     */
    public String getString() {
        return cast(String.class);
    }

    private  T cast(final Class type) {
        return type.cast(this.value);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy