001package com.quorum.tessera.config.builder;
002
003import com.quorum.tessera.config.JdbcConfig;
004
005import java.util.Optional;
006
007public interface JdbcConfigFactory {
008
009    static JdbcConfig fromLegacyStorageString(String storage) {
010        
011        Optional.ofNullable(storage).orElseThrow(IllegalArgumentException::new);
012        
013        if(storage.startsWith("jdbc")) {
014            return new JdbcConfig(null, null, storage);
015        }
016
017        if(storage.startsWith("sqlite")) {
018            return new JdbcConfig(null, null, String.format("jdbc:%s", storage));
019        }
020        
021        if(storage.startsWith("memory")) {
022            return new JdbcConfig(null, null, "jdbc:h2:mem:tessera");
023        }
024
025        throw new UnsupportedOperationException(String.format("%s is not a supported storage option.", storage));
026    }
027
028}