class NcFileStitcher {

    static void setDimensions(SlstrNFileWritable nFileWriteable, List<Dimension>[] dimensionLists,
                              ImageSize targetImageSize, List<Variable>[] variableLists)
            throws PDUStitchingException, IOException {
        List<String> namesOfAddedDimensions = new ArrayList<>();
        for (int i = 0; i < dimensionLists.length; i++) {
            List<Dimension> dimensions = dimensionLists[i];
            for (Dimension dimension : dimensions) {
                final String dimensionName = dimension.getFullName();
                if (!namesOfAddedDimensions.contains(dimensionName)) {
                    switch (dimensionName) {
                        case "rows":
                            nFileWriteable.addDimension("rows", targetImageSize.getRows());
                            break;
                        case "columns":
                            nFileWriteable.addDimension("columns", targetImageSize.getColumns());
                            break;
                        default:
                            checkWhetherEquallyNamedVariablesContainEqualValues(dimensionName, i, variableLists);
                            checkWhetherDimensionLengthIsEqualAcrossAllEquallyNamedDimensions(dimension, i, dimensionLists);
                            nFileWriteable.addDimension(dimensionName, dimension.getLength());
                            break;
                    }
                    namesOfAddedDimensions.add(dimensionName);
                }
            }
        }
    }

}