/** Returns a Comparison from the given result of a call to <code>Comparable.compareTo()</code> or <code>Comparator.compare</code>. */ @SuppressFBWarnings(value = "UC_USELESS_CONDITION", justification = "Throwing Unhandled keeps the full-enumeration more explicit.") public static Comparison from(int compareToResult) { if (compareToResult == 0) { return Comparison.EQUAL; } else if (compareToResult < 0) { return Comparison.LESSER; } else if (compareToResult > 0) { return Comparison.GREATER; } else { throw Unhandled.integerException(compareToResult); } } }
/** Returns a Comparison from the given result of a call to <code>Comparable.compareTo()</code> or <code>Comparator.compare</code>. */ @SuppressFBWarnings(value = "UC_USELESS_CONDITION", justification = "Throwing Unhandled keeps the full-enumeration more explicit.") public static Comparison from(int compareToResult) { if (compareToResult == 0) { return Comparison.EQUAL; } else if (compareToResult < 0) { return Comparison.LESSER; } else if (compareToResult > 0) { return Comparison.GREATER; } else { throw Unhandled.integerException(compareToResult); } } }
/** Returns a Comparison from the given result of a call to {@link Comparable#compareTo(Object)} or {@link Comparator#compare(Object, Object)}. */ @SuppressFBWarnings(value = "UC_USELESS_CONDITION", justification = "Throwing Unhandled keeps the full-enumeration more explicit.") @CheckReturnValue public static Comparison from(int compareToResult) { if (compareToResult == 0) { return Comparison.EQUAL; } else if (compareToResult < 0) { return Comparison.LESSER; } else if (compareToResult > 0) { return Comparison.GREATER; } else { throw Unhandled.integerException(compareToResult); } } }
@Override public void dragFinished(DragSourceEvent event) { Transfer selectedTransfer = findTransfer(event); data.forEach((transfer, value) -> { DropResult result; if (selectedTransfer == transfer) { // @formatter:off switch (event.detail) { case DND.DROP_MOVE: result = DropResult.MOVED; break; case DND.DROP_COPY: result = DropResult.COPIED; break; default: throw Unhandled.integerException(event.detail); } // @formatter:on } else { result = DropResult.NO_DROP; } handlers.get(transfer).handler.dropped(event, value, result); }); data.clear(); dragInProgress.set(false); } }
void writeBrandingPlugin(File ideDir) throws IOException { // load iconImg and splashImg BufferedImage iconImg, splashImg; int numSet = Booleans.countTrue(icon != null, splash != null); if (numSet == 0) { // nothing is set, use Goomph iconImg = BrandingProductPlugin.getGoomphIcon(); splashImg = BrandingProductPlugin.getGoomphSplash(); } else if (numSet == 1) { // anything is set, use it for everything iconImg = loadImg(Optional.ofNullable(icon).orElse(splash)); splashImg = iconImg; } else if (numSet == 2) { // both are set, use them each iconImg = loadImg(icon); splashImg = loadImg(splash); } else { throw Unhandled.integerException(numSet); } File branding = new File(ideDir, FileMisc.macContentsEclipse() + "dropins/com.diffplug.goomph.branding"); BrandingProductPlugin.create(branding, splashImg, iconImg, name, perspective, description); File bundlesInfo = new File(ideDir, FileMisc.macContentsEclipse() + "configuration/org.eclipse.equinox.simpleconfigurator/bundles.info"); FileMisc.modifyFile(bundlesInfo, content -> { return content + "com.diffplug.goomph.branding,1.0.0,dropins/com.diffplug.goomph.branding/,4,true" + System.lineSeparator(); }); }