/*
 *  Copyright (c) 2024 John Ahlroos
 *
 *  Creative Commons Attribution-NoDerivatives 4.0 International Public License
 *
 *  By exercising the Licensed Rights (defined below), You accept and agree
 *  to be bound by the terms and conditions of this Creative Commons
 *  Attribution-NoDerivatives 4.0 International Public License ("Public
 *  License"). To the extent this Public License may be interpreted as a
 *  contract, You are granted the Licensed Rights in consideration of Your
 *  acceptance of these terms and conditions, and the Licensor grants You
 *  such rights in consideration of benefits the Licensor receives from
 *  making the Licensed Material available under these terms and
 *  conditions.
 *
 *  Refer to LICENSE file or https://creativecommons.org/licenses/by-nd/4.0 for full license.
 *
 */
package com.devsoap.json;

import jakarta.json.JsonArray;
import jakarta.json.JsonValue;
import org.assertj.core.api.AbstractListAssert;

import java.util.List;


public class JsonArrayAssert<VALUE_TYPE extends JsonValue> extends AbstractListAssert<JsonArrayAssert<VALUE_TYPE>,
        List<VALUE_TYPE>,
        VALUE_TYPE, JsonValueAssert<VALUE_TYPE>> {

    private final String fieldName;

    protected JsonArrayAssert(String fieldName, JsonArray array) {
        super(array.getValuesAs(jsonValue -> (VALUE_TYPE) jsonValue), JsonArrayAssert.class);
        this.fieldName = fieldName;
    }

    public JsonArrayAssert(String fieldName, VALUE_TYPE value) {
        super(List.of(value), JsonArrayAssert.class);
        this.fieldName = fieldName;
    }

    @Override
    protected JsonValueAssert<VALUE_TYPE> toAssert(VALUE_TYPE value, String description) {
        return new JsonValueAssert<>(fieldName, (JsonValue) value, value);
    }

    @Override
    protected JsonArrayAssert<VALUE_TYPE> newAbstractIterableAssert(Iterable<? extends VALUE_TYPE> iterable) {
        //TODO
        return null;
    }
}