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

org.simpleflatmapper.poi.impl.PoiFloatGetter Maven / Gradle / Ivy

There is a newer version: 9.0.2
Show newest version
package org.simpleflatmapper.poi.impl;


import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.simpleflatmapper.reflect.Getter;
import org.simpleflatmapper.reflect.primitive.FloatGetter;

public class PoiFloatGetter implements Getter, FloatGetter {

    private final int index;

    public PoiFloatGetter(int index) {
        this.index = index;
    }

    @Override
    public Float get(Row target) throws Exception {
        final Cell cell = target.getCell(index);
        if (cell != null) {
            return (float)cell.getNumericCellValue();
        } else {
            return null;
        }
    }

    @Override
    public float getFloat(Row target) throws Exception {
        final Cell cell = target.getCell(index);
        if (cell != null) {
            return  (float)cell.getNumericCellValue();
        } else {
            return 0;
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy