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

com.github.batkinson.jxlsform.common.Choice Maven / Gradle / Ivy

The newest version!
package com.github.batkinson.jxlsform.common;

import com.github.batkinson.jxlsform.api.XLSFormException;

import java.util.Optional;

public class Choice implements com.github.batkinson.jxlsform.api.Choice {

    private final com.github.batkinson.jxlsform.api.ChoiceList list;
    private final com.github.batkinson.jxlsform.api.Row row;

    Choice(com.github.batkinson.jxlsform.api.ChoiceList list, com.github.batkinson.jxlsform.api.Row row) {
        if (list == null) {
            throw new XLSFormException("list is required");
        }
        if (row == null) {
            throw new XLSFormException("row is required");
        }
        this.list = list;
        this.row = row;
    }

    @Override
    public com.github.batkinson.jxlsform.api.ChoiceList getList() {
        return list;
    }

    @Override
    public com.github.batkinson.jxlsform.api.Row getRow() {
        return row;
    }

    @Override
    public String getName() {
        return row.getCellByHeader("name")
                .map(com.github.batkinson.jxlsform.api.Cell::getValue)
                .orElseThrow(() -> new XLSFormException("name is required"));
    }

    @Override
    public Optional getLabel() {
        return row.getCellByHeader("label")
                .map(com.github.batkinson.jxlsform.api.Cell::getValue);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy