Rename enum from 'FILELIST' to 'FILE'

pull/2/head
Hammy 3 years ago
parent a1156a4cef
commit 738e108976

@ -12,7 +12,7 @@ import me.goudham.domain.OldClipboardContent;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import static me.goudham.Contents.FILELIST; import static me.goudham.Contents.FILE;
import static me.goudham.Contents.IMAGE; import static me.goudham.Contents.IMAGE;
import static me.goudham.Contents.TEXT; import static me.goudham.Contents.TEXT;
@ -70,8 +70,8 @@ class ClipboardUtils {
List<File> fileList = null; List<File> fileList = null;
try { try {
if (clipboardContents.isDataFlavorSupported(FILELIST.getDataFlavor())) { if (clipboardContents.isDataFlavorSupported(FILE.getDataFlavor())) {
fileList = (List<File>) clipboardContents.getTransferData(FILELIST.getDataFlavor()); fileList = (List<File>) clipboardContents.getTransferData(FILE.getDataFlavor());
} }
} catch (UnsupportedFlavorException | IOException exp) { } catch (UnsupportedFlavorException | IOException exp) {
logger.error("Exception Thrown When Retrieving File Content", exp); logger.error("Exception Thrown When Retrieving File Content", exp);
@ -95,8 +95,8 @@ class ClipboardUtils {
} else if (contents.isDataFlavorSupported(IMAGE.getDataFlavor())) { } else if (contents.isDataFlavorSupported(IMAGE.getDataFlavor())) {
BufferedImage bufferedImage = convertToBufferedImage((Image) contents.getTransferData(IMAGE.getDataFlavor())); BufferedImage bufferedImage = convertToBufferedImage((Image) contents.getTransferData(IMAGE.getDataFlavor()));
myClipboardContent.setOldContent(new MyBufferedImage(bufferedImage)); myClipboardContent.setOldContent(new MyBufferedImage(bufferedImage));
} else if (contents.isDataFlavorSupported(FILELIST.getDataFlavor())) { } else if (contents.isDataFlavorSupported(FILE.getDataFlavor())) {
myClipboardContent.setOldContent(contents.getTransferData(FILELIST.getDataFlavor())); myClipboardContent.setOldContent(contents.getTransferData(FILE.getDataFlavor()));
} }
} catch (UnsupportedFlavorException | IOException exp) { } catch (UnsupportedFlavorException | IOException exp) {
logger.error("Exception Thrown When Retrieving Clipboard Contents", exp); logger.error("Exception Thrown When Retrieving Clipboard Contents", exp);
@ -119,8 +119,8 @@ class ClipboardUtils {
oldClipboardContent = new OldClipboardContent((String) oldContents.getTransferData(TEXT.getDataFlavor())); oldClipboardContent = new OldClipboardContent((String) oldContents.getTransferData(TEXT.getDataFlavor()));
} else if (oldContents.isDataFlavorSupported(IMAGE.getDataFlavor())) { } else if (oldContents.isDataFlavorSupported(IMAGE.getDataFlavor())) {
oldClipboardContent = new OldClipboardContent(convertToBufferedImage((Image) oldContents.getTransferData(IMAGE.getDataFlavor()))); oldClipboardContent = new OldClipboardContent(convertToBufferedImage((Image) oldContents.getTransferData(IMAGE.getDataFlavor())));
} else if (oldContents.isDataFlavorSupported(FILELIST.getDataFlavor())) { } else if (oldContents.isDataFlavorSupported(FILE.getDataFlavor())) {
oldClipboardContent = new OldClipboardContent((List<File>) oldContents.getTransferData(FILELIST.getDataFlavor())); oldClipboardContent = new OldClipboardContent((List<File>) oldContents.getTransferData(FILE.getDataFlavor()));
} }
} catch (UnsupportedFlavorException | IOException exp) { } catch (UnsupportedFlavorException | IOException exp) {
logger.error("Exception Thrown When Retrieving Clipboard Contents", exp); logger.error("Exception Thrown When Retrieving Clipboard Contents", exp);

@ -16,7 +16,7 @@ enum Contents {
return clipboard.isDataFlavorAvailable(DataFlavor.imageFlavor); return clipboard.isDataFlavorAvailable(DataFlavor.imageFlavor);
} }
}, },
FILELIST(DataFlavor.javaFileListFlavor) { FILE(DataFlavor.javaFileListFlavor) {
@Override @Override
public boolean isAvailable(Clipboard clipboard) { public boolean isAvailable(Clipboard clipboard) {
return clipboard.isDataFlavorAvailable(DataFlavor.javaFileListFlavor); return clipboard.isDataFlavorAvailable(DataFlavor.javaFileListFlavor);

@ -11,7 +11,7 @@ import java.util.concurrent.TimeUnit;
import me.goudham.domain.OldClipboardContent; import me.goudham.domain.OldClipboardContent;
import static java.lang.Thread.sleep; import static java.lang.Thread.sleep;
import static me.goudham.Contents.FILELIST; import static me.goudham.Contents.FILE;
import static me.goudham.Contents.IMAGE; import static me.goudham.Contents.IMAGE;
import static me.goudham.Contents.TEXT; import static me.goudham.Contents.TEXT;
@ -31,7 +31,7 @@ class MacClipboardListener extends ClipboardListener implements Runnable {
* @param myClipboardContents {@link MyClipboardContent[]} of Unknown {@link Class} containing previous contents * @param myClipboardContents {@link MyClipboardContent[]} of Unknown {@link Class} containing previous contents
*/ */
void checkText(Transferable newClipboardContents, MyClipboardContent<?>[] myClipboardContents) { void checkText(Transferable newClipboardContents, MyClipboardContent<?>[] myClipboardContents) {
if (TEXT.isAvailable(clipboard) && !FILELIST.isAvailable(clipboard)) { if (TEXT.isAvailable(clipboard) && !FILE.isAvailable(clipboard)) {
String newStringContent = clipboardUtils.getStringContent(newClipboardContents); String newStringContent = clipboardUtils.getStringContent(newClipboardContents);
if (newStringContent == null) return; if (newStringContent == null) return;
@ -77,7 +77,7 @@ class MacClipboardListener extends ClipboardListener implements Runnable {
* @param myClipboardContents {@link MyClipboardContent[]} of Unknown {@link Class} containing previous contents * @param myClipboardContents {@link MyClipboardContent[]} of Unknown {@link Class} containing previous contents
*/ */
void checkFiles(Transferable newClipboardContents, MyClipboardContent<?>[] myClipboardContents) { void checkFiles(Transferable newClipboardContents, MyClipboardContent<?>[] myClipboardContents) {
if (FILELIST.isAvailable(clipboard)) { if (FILE.isAvailable(clipboard)) {
List<File> fileListContent = clipboardUtils.getFileContent(newClipboardContents); List<File> fileListContent = clipboardUtils.getFileContent(newClipboardContents);
if (fileListContent == null) return; if (fileListContent == null) return;

@ -13,7 +13,7 @@ import me.goudham.domain.OldClipboardContent;
import static java.lang.Thread.currentThread; import static java.lang.Thread.currentThread;
import static java.lang.Thread.sleep; import static java.lang.Thread.sleep;
import static me.goudham.Contents.FILELIST; import static me.goudham.Contents.FILE;
import static me.goudham.Contents.IMAGE; import static me.goudham.Contents.IMAGE;
import static me.goudham.Contents.TEXT; import static me.goudham.Contents.TEXT;
@ -47,7 +47,7 @@ class WindowsOrUnixClipboardListener extends ClipboardListener implements Runnab
OldClipboardContent oldClipboardContent = clipboardUtils.getOldClipboardContent(oldClipboardContents); OldClipboardContent oldClipboardContent = clipboardUtils.getOldClipboardContent(oldClipboardContents);
if (isTextMonitored()) { if (isTextMonitored()) {
if (TEXT.isAvailable(oldClipboard) && !FILELIST.isAvailable(oldClipboard)) { if (TEXT.isAvailable(oldClipboard) && !FILE.isAvailable(oldClipboard)) {
String stringContent = clipboardUtils.getStringContent(newClipboardContents); String stringContent = clipboardUtils.getStringContent(newClipboardContents);
if (!stringContent.equals(oldClipboardContent.getOldText())) { if (!stringContent.equals(oldClipboardContent.getOldText())) {
eventManager.notifyTextEvent(oldClipboardContent, stringContent); eventManager.notifyTextEvent(oldClipboardContent, stringContent);
@ -66,7 +66,7 @@ class WindowsOrUnixClipboardListener extends ClipboardListener implements Runnab
} }
if (isFileMonitored()) { if (isFileMonitored()) {
if (FILELIST.isAvailable(oldClipboard)) { if (FILE.isAvailable(oldClipboard)) {
List<File> fileList = clipboardUtils.getFileContent(newClipboardContents); List<File> fileList = clipboardUtils.getFileContent(newClipboardContents);
if (!fileList.equals(oldClipboardContent.getOldFiles())) { if (!fileList.equals(oldClipboardContent.getOldFiles())) {
eventManager.notifyFilesEvent(oldClipboardContent, fileList); eventManager.notifyFilesEvent(oldClipboardContent, fileList);

@ -19,7 +19,7 @@ import org.mockito.Mock;
import org.mockito.MockitoAnnotations; import org.mockito.MockitoAnnotations;
import org.slf4j.Logger; import org.slf4j.Logger;
import static me.goudham.Contents.FILELIST; import static me.goudham.Contents.FILE;
import static me.goudham.Contents.IMAGE; import static me.goudham.Contents.IMAGE;
import static me.goudham.Contents.TEXT; import static me.goudham.Contents.TEXT;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
@ -114,10 +114,10 @@ class ClipboardUtilsTest {
void failToGetFileContent() throws IOException, UnsupportedFlavorException { void failToGetFileContent() throws IOException, UnsupportedFlavorException {
List<File> expectedFileContent = null; List<File> expectedFileContent = null;
String expectedExceptionMessage = "Exception Thrown When Retrieving File Content"; String expectedExceptionMessage = "Exception Thrown When Retrieving File Content";
Throwable expectedException = new UnsupportedFlavorException(FILELIST.getDataFlavor()); Throwable expectedException = new UnsupportedFlavorException(FILE.getDataFlavor());
when(transferableMock.isDataFlavorSupported(FILELIST.getDataFlavor())).thenReturn(true); when(transferableMock.isDataFlavorSupported(FILE.getDataFlavor())).thenReturn(true);
when(transferableMock.getTransferData(FILELIST.getDataFlavor())).thenThrow(expectedException); when(transferableMock.getTransferData(FILE.getDataFlavor())).thenThrow(expectedException);
List<File> actualFileContent = sut.getFileContent(transferableMock); List<File> actualFileContent = sut.getFileContent(transferableMock);
@ -170,7 +170,7 @@ class ClipboardUtilsTest {
return Stream.of( return Stream.of(
Arguments.of(string, TEXT.getDataFlavor(), string, null, null), Arguments.of(string, TEXT.getDataFlavor(), string, null, null),
Arguments.of(bufferedImage, IMAGE.getDataFlavor(), null, bufferedImage, null), Arguments.of(bufferedImage, IMAGE.getDataFlavor(), null, bufferedImage, null),
Arguments.of(files, FILELIST.getDataFlavor(), null, null, files) Arguments.of(files, FILE.getDataFlavor(), null, null, files)
); );
} }
@ -197,7 +197,7 @@ class ClipboardUtilsTest {
return Stream.of( return Stream.of(
Arguments.of(new MyClipboardContent<>(string), string, TEXT.getDataFlavor()), Arguments.of(new MyClipboardContent<>(string), string, TEXT.getDataFlavor()),
Arguments.of(new MyClipboardContent<>(myBufferedImage), bufferedImage, IMAGE.getDataFlavor()), Arguments.of(new MyClipboardContent<>(myBufferedImage), bufferedImage, IMAGE.getDataFlavor()),
Arguments.of(new MyClipboardContent<>(files), files, FILELIST.getDataFlavor()) Arguments.of(new MyClipboardContent<>(files), files, FILE.getDataFlavor())
); );
} }
} }
Loading…
Cancel
Save