Refactor STRING -> TEXT for increased readability

MYC-Refactor
Hammy
parent 96dac0ad5f
commit ee4e63166b

@ -12,7 +12,7 @@ import me.goudham.domain.MyClipboardContent;
import me.goudham.domain.OldClipboardContent;
import static me.goudham.domain.Contents.IMAGE;
import static me.goudham.domain.Contents.STRING;
import static me.goudham.domain.Contents.TEXT;
class ClipboardUtils {
@ -20,8 +20,8 @@ class ClipboardUtils {
MyClipboardContent<?> myClipboardContent = new MyClipboardContent<>();
try {
if (STRING.isAvailable(clipboard)) {
myClipboardContent.setOldContent(contents.getTransferData(STRING.getDataFlavor()));
if (TEXT.isAvailable(clipboard)) {
myClipboardContent.setOldContent(contents.getTransferData(TEXT.getDataFlavor()));
} else if (IMAGE.isAvailable(clipboard)) {
BufferedImage bufferedImage = convertToBufferedImage((Image) contents.getTransferData(IMAGE.getDataFlavor()));
myClipboardContent.setOldContent(new Dimension(bufferedImage.getWidth(), bufferedImage.getHeight()));
@ -37,8 +37,8 @@ class ClipboardUtils {
OldClipboardContent oldClipboardContent = null;
try {
if (oldContents.isDataFlavorSupported(STRING.getDataFlavor())) {
oldClipboardContent = new OldClipboardContent((String) oldContents.getTransferData(STRING.getDataFlavor()));
if (oldContents.isDataFlavorSupported(TEXT.getDataFlavor())) {
oldClipboardContent = new OldClipboardContent((String) oldContents.getTransferData(TEXT.getDataFlavor()));
} else if (oldContents.isDataFlavorSupported(IMAGE.getDataFlavor())) {
oldClipboardContent = new OldClipboardContent(convertToBufferedImage((Image) oldContents.getTransferData(IMAGE.getDataFlavor())));
}

@ -35,9 +35,9 @@ class EventManager {
*
* @param stringContent {@link String} to be consumed
*/
void notifyStringEvent(OldClipboardContent oldClipboardContent, String stringContent) {
void notifyTextEvent(OldClipboardContent oldClipboardContent, String stringContent) {
for (ClipboardEvent clipboardEvent : eventListeners) {
clipboardEvent.onCopyString(oldClipboardContent, stringContent);
clipboardEvent.onCopyText(oldClipboardContent, stringContent);
}
}

@ -9,7 +9,7 @@ import java.util.concurrent.TimeUnit;
import me.goudham.domain.MyClipboardContent;
import static me.goudham.domain.Contents.IMAGE;
import static me.goudham.domain.Contents.STRING;
import static me.goudham.domain.Contents.TEXT;
class MacClipboardListener extends ClipboardListener {
@ -23,7 +23,7 @@ class MacClipboardListener extends ClipboardListener {
*/
void checkText(Transferable newClipboardContents, MyClipboardContent<?>[] myClipboardContents) {
if (isTextMonitored()) {
if (STRING.isAvailable(clipboard)) {
if (TEXT.isAvailable(clipboard)) {
String newStringContent = getStringContent(newClipboardContents);
String oldStringContent = (String) myClipboardContents[0].getOldContent();
if (!newStringContent.equals(oldStringContent)) {
@ -41,7 +41,7 @@ class MacClipboardListener extends ClipboardListener {
* @param myClipboardContents {@link MyClipboardContent[]} of Unknown {@link Class} containing previous contents
*/
void checkImages(Transferable newClipboardContents, MyClipboardContent<?>[] myClipboardContents) {
if (isImagesMonitored()) {
if (isImageMonitored()) {
if (IMAGE.isAvailable(clipboard)) {
BufferedImage bufferedImageContent = getImageContent(newClipboardContents);
Dimension newDimensionContent = new Dimension(bufferedImageContent.getWidth(), bufferedImageContent.getHeight());

@ -4,7 +4,7 @@ import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.DataFlavor;
public enum Contents {
STRING(DataFlavor.stringFlavor) {
TEXT(DataFlavor.stringFlavor) {
@Override
public boolean isAvailable(Clipboard clipboard) {
return clipboard.isDataFlavorAvailable(DataFlavor.stringFlavor);

@ -6,7 +6,7 @@ import java.util.List;
import me.goudham.domain.OldClipboardContent;
public interface ClipboardEvent {
void onCopyString(OldClipboardContent oldContent, String newContent);
void onCopyText(OldClipboardContent oldContent, String newContent);
void onCopyImage(OldClipboardContent oldContent, BufferedImage newContent);
void onCopyFiles(OldClipboardContent oldContent, List<File> newContent);
}

Loading…
Cancel
Save