public static void checkMapColumns(final Sheet sheet, final Class<?> recordClass,
            final List<RecordHeader> headers, final AnnotationReader reader, final Configuration config)
                    throws CellNotFoundException {
        
        List<FieldAccessor> properties = FieldAccessorUtils.getPropertiesWithAnnotation(recordClass, reader, XlsMapColumns.class);
        
        for(FieldAccessor property : properties) {
            final XlsMapColumns mapColumns = property.getAnnotation(XlsMapColumns.class).get();
            if(mapColumns.optional()) {
                continue;
            }
            
            final String previousColumnName = mapColumns.previousColumnName();
            boolean foundPrevious = headers.stream()
                .filter(info -> Utils.matches(info.getLabel(), previousColumnName, config))
                .findFirst()
                .isPresent();
            
            if(!foundPrevious) {
                throw new CellNotFoundException(sheet.getSheetName(), previousColumnName);
            }
            
            final String nextColumnName = mapColumns.nextColumnName();
            if(!nextColumnName.isEmpty()) {
                boolean foundNext = headers.stream()
                        .filter(info -> Utils.matches(info.getLabel(), nextColumnName, config))
                        .findFirst()
                        .isPresent();
                
                if(!foundNext) {
                    throw new CellNotFoundException(sheet.getSheetName(), nextColumnName);
                }
            }
            
        }
    }
public static void checkMapColumns ( final Sheet sheet , final Class < ? > recordClass , final List < RecordHeader > headers , final AnnotationReader reader , final Configuration config ) throws CellNotFoundException { List < FieldAccessor > properties = FieldAccessorUtils . getPropertiesWithAnnotation ( recordClass , reader , XlsMapColumns . class ) ; for ( FieldAccessor property : properties ) { final XlsMapColumns mapColumns = property . getAnnotation ( XlsMapColumns . class ) . get ( ) ; if ( mapColumns . optional ( ) ) { continue ; } final String previousColumnName = mapColumns . previousColumnName ( ) ; boolean foundPrevious = headers . stream ( ) . filter ( info -> Utils . matches ( info . getLabel ( ) , previousColumnName , config ) ) . findFirst ( ) . isPresent ( ) ; if ( ! foundPrevious ) { throw new CellNotFoundException ( sheet . getSheetName ( ) , previousColumnName ) ; } final String nextColumnName = mapColumns . nextColumnName ( ) ; if ( ! nextColumnName . isEmpty ( ) ) { boolean foundNext = headers . stream ( ) . filter ( info -> Utils . matches ( info . getLabel ( ) , nextColumnName , config ) ) . findFirst ( ) . isPresent ( ) ; if ( ! foundNext ) { throw new CellNotFoundException ( sheet . getSheetName ( ) , nextColumnName ) ; } } } }
アノテーション{@link XlsMapColumns}の属性previousColumnName、nextColumnNameで指定した値がヘッダーセルに存在するかチェックする。
@since 2.0
@param sheet
@param recordClass
@param headers
@param reader
@param config
@throws CellNotFoundException セルが見つからない場合