org.unix4j.convert.FileConverters Maven / Gradle / Ivy
package org.unix4j.convert;
import java.io.File;
import java.net.URL;
public class FileConverters {
public static final ValueConverter URL_TO_FILE = new ValueConverter() {
@Override
public File convert(Object value) throws IllegalArgumentException {
if (value instanceof URL) {
return new File(((URL)value).getFile());
}
return null;
}
};
public static final ValueConverter URL = ConcatenatedConverter.concat(URLConverters.DEFAULT, URL_TO_FILE);
public static final ValueConverter STRING = new ValueConverter() {
@Override
public File convert(Object value) throws IllegalArgumentException {
if (value != null) {
return new File(value.toString());
}
return null;
}
};
public static final ValueConverter DEFAULT = new CompositeValueConverter().add(URL).add(STRING);
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy