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

com.alibaba.excel.metadata.AbstractParameterBuilder Maven / Gradle / Ivy

There is a newer version: 4.0.3
Show newest version
package com.alibaba.excel.metadata;

import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

import com.alibaba.excel.converters.Converter;

/**
 * ExcelBuilder
 *
 * @author Jiaju Zhuang
 */
public abstract class AbstractParameterBuilder {
    /**
     * You can only choose one of the {@link #head(List)} and {@link #head(Class)}
     *
     * @param head
     * @return
     */
    public T head(List> head) {
        parameter().setHead(head);
        return self();
    }

    /**
     * You can only choose one of the {@link #head(List)} and {@link #head(Class)}
     *
     * @param clazz
     * @return
     */
    public T head(Class clazz) {
        parameter().setClazz(clazz);
        return self();
    }

    /**
     * Custom type conversions override the default.
     *
     * @param converter
     * @return
     */
    public T registerConverter(Converter converter) {
        if (parameter().getCustomConverterList() == null) {
            parameter().setCustomConverterList(new ArrayList());
        }
        parameter().getCustomConverterList().add(converter);
        return self();
    }

    /**
     * true if date uses 1904 windowing, or false if using 1900 date windowing.
     *
     * default is false
     *
     * @param use1904windowing
     * @return
     */
    public T use1904windowing(Boolean use1904windowing) {
        parameter().setUse1904windowing(use1904windowing);
        return self();
    }

    /**
     * A Locale object represents a specific geographical, political, or cultural region. This parameter is
     * used when formatting dates and numbers.
     *
     * @param locale
     * @return
     */
    public T locale(Locale locale) {
        parameter().setLocale(locale);
        return self();
    }

    /**
     * Automatic trim includes sheet name and content
     *
     * @param autoTrim
     * @return
     */
    public T autoTrim(Boolean autoTrim) {
        parameter().setAutoTrim(autoTrim);
        return self();
    }

    @SuppressWarnings("unchecked")
    protected T self() {
        return (T)this;
    }

    /**
     * Get parameter
     *
     * @return
     */
    protected abstract C parameter();
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy