Skip to content

Instantly share code, notes, and snippets.

@bdkosher
Created April 29, 2020 00:39
Show Gist options
  • Save bdkosher/663c8b9b5b799083f142a5fc9667f1cb to your computer and use it in GitHub Desktop.
Save bdkosher/663c8b9b5b799083f142a5fc9667f1cb to your computer and use it in GitHub Desktop.
Some of this is now irrelevant in our Java 14+ world
package gov.uspto.iqs;
import java.time.DayOfWeek;
import java.util.Arrays;
public class SadCompiler {
int sadInstanceOf(Object o) {
if (o instanceof List) {
return ((List) o).size();
}
return -1;
}
String sadEnumSwitch(DayOfWeek dayOfWeek) {
switch (dayOfWeek) {
case MONDAY:
return "you can fall apart";
case TUESDAY:
case WEDNESDAY:
return "break my heart";
case THURSDAY:
return "doesn't even start. It's";
case FRIDAY:
return "I'm in love";
case SATURDAY:
return "wait";
case SUNDAY:
return "always comes too late";
default:
return null;
}
}
String sadIfElse(boolean condition) {
if (condition) {
return "OK";
} else if (!condition) {
return "Also OK";
} else {
return "Hmm...";
}
}
boolean sadTernaryAutoboxing(Object o) {
return o == null ? null : true;
}
public static void main(String[] args) {
SadCompiler sad = new SadCompiler();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment