Skip to content

Instantly share code, notes, and snippets.

@dblevins
Created February 2, 2015 03:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dblevins/00cde6af51730dbcaf8e to your computer and use it in GitHub Desktop.
Save dblevins/00cde6af51730dbcaf8e to your computer and use it in GitHub Desktop.
import java.io.File;
import java.lang.annotation.Annotation;
public class FileConstraints {
{
final Mapper mapper = new Mapper();
mapper.map(Executable.class, File.class, File::canExecute);
mapper.map(Writable.class, File.class, File::canWrite);
mapper.map(Readable.class, File.class, File::canRead);
mapper.map(Directory.class, File.class, File::isDirectory);
mapper.map(Exists.class, File.class, File::exists);
}
public static class Mapper {
public <A extends Annotation, T> void map(Class<A> a, Class<T> type, Constraint<T> constraint) {
}
public <A extends Annotation, T> void map2(Class<A> a, Constraint<T> constraint) {
}
}
public interface Constraint <T> {
public boolean isValid(final T value);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment