package com.atlassian.bitbucket.mesh.boot.config;

import org.springframework.boot.context.properties.ConstructorBinding;
import org.springframework.boot.context.properties.bind.DefaultValue;
import org.springframework.boot.convert.DataSizeUnit;
import org.springframework.util.unit.DataSize;

import javax.annotation.Nonnull;

import static java.util.Objects.requireNonNull;
import static org.springframework.util.unit.DataUnit.MEGABYTES;

public class DirectMemoryConfig {

    private final DataSize max;
    private final DataSize reserved;

    @ConstructorBinding
    public DirectMemoryConfig(@DataSizeUnit(MEGABYTES) @DefaultValue("-1") @Nonnull DataSize max,
                              @DataSizeUnit(MEGABYTES) @DefaultValue("50") @Nonnull DataSize reserved) {
        this.max = requireNonNull(max, "max");
        this.reserved = requireNonNull(reserved, "reserved");
    }

    @Nonnull
    public DataSize getMax() {
        return max;
    }

    @Nonnull
    public DataSize getReserved() {
        return reserved;
    }
}
