Add enum class for different DataFlavors

osx
sgoudham 3 years ago
parent 1ef16260c8
commit 2cb1997d95
No known key found for this signature in database
GPG Key ID: EF51A29A50FB754C

@ -0,0 +1,37 @@
package me.goudham.util;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.DataFlavor;
public enum Contents {
STRING(DataFlavor.stringFlavor) {
@Override
public boolean isAvailable(Clipboard clipboard) {
return clipboard.isDataFlavorAvailable(DataFlavor.stringFlavor);
}
},
IMAGE(DataFlavor.imageFlavor) {
@Override
public boolean isAvailable(Clipboard clipboard) {
return clipboard.isDataFlavorAvailable(DataFlavor.imageFlavor);
}
},
FILELIST(DataFlavor.javaFileListFlavor) {
@Override
public boolean isAvailable(Clipboard clipboard) {
return clipboard.isDataFlavorAvailable(DataFlavor.javaFileListFlavor);
}
};
private final DataFlavor dataFlavor;
Contents(DataFlavor dataFlavor) {
this.dataFlavor = dataFlavor;
}
public DataFlavor getDataFlavor() {
return dataFlavor;
}
public abstract boolean isAvailable(Clipboard clipboard);
}
Loading…
Cancel
Save