All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.unix4j.convert.FileConverters Maven / Gradle / Ivy

There is a newer version: 0.6
Show newest version
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