/*
 * Copyright 2015 Axel Howind <axel@dua3.com>.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.dua3.meja.model.generic;

/**
 *
 * @author Axel Howind <axel@dua3.com>
 */
public class GenericRow {

}

/*
 * Copyright 2015 Axel Howind <axel@dua3.com>.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.dua3.meja.model.generic;

import com.dua3.meja.model.Cell;
import com.dua3.meja.model.Row;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Axel Howind <axel@dua3.com>
 */
public class GenericRow implements Row {

    private final GenericSheet sheet;
    private final List<GenericCell> cells = new ArrayList<>();

    public GenericRow(GenericSheet sheet) {
        this.sheet = sheet;
        reserve(sheet.getNumberOfColumns());
    }

    @Override
    public GenericSheet getSheet() {
        return sheet;
    }

    @Override
    public Cell getCell(int col) {
        reserve(col);
        return cells.get(col);
    }

    private void reserve(int col) {
        for (int colNum=cells.size(); colNum<=col; colNum++) {
            cells.add(new GenericCell(this));
        }
    }

}

implement generic model (wip)