package ru.nbch.indicsearchservice.util;

import java.util.Arrays;
import java.util.List;
import java.util.Optional;

public class IndicSearchCommon {
    public static Optional<String> getRowValue(String string, String key) {
        return getRowValue(Arrays.asList(string.split("%%%", -1)), key);
    }

    public static Optional<String> getRowValue(List<String> stringValues, String key) {
        int keyIndex = stringValues.indexOf(key);
        if (keyIndex != -1) {
            return Optional.of(stringValues.get(keyIndex + 1));
        }
        return Optional.empty();
    }
}
