io.odpf.depot.config.converter.ConverterUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of depot Show documentation
Show all versions of depot Show documentation
A sink connector library containing multiple sink implementations
package io.odpf.depot.config.converter;
import io.odpf.depot.common.Tuple;
import java.util.ArrayList;
import java.util.List;
public class ConverterUtils {
public static final String ELEMENT_SEPARATOR = ",";
private static final String VALUE_SEPARATOR = "=";
private static final int MAX_LENGTH = 63;
public static List> convertToList(String input) {
List> result = new ArrayList<>();
String[] chunks = input.split(ELEMENT_SEPARATOR, -1);
for (String chunk : chunks) {
String[] entry = chunk.split(VALUE_SEPARATOR, -1);
if (entry.length <= 1) {
continue;
}
String key = entry[0].trim();
if (key.isEmpty()) {
continue;
}
String value = entry[1].trim();
value = value.length() > MAX_LENGTH ? value.substring(0, MAX_LENGTH) : value;
result.add(new Tuple<>(key, value));
}
return result;
}
}