Created
July 26, 2018 16:25
-
-
Save aploskov/c5f62b7cb0ad04956e27f8fe3a522476 to your computer and use it in GitHub Desktop.
Problem example for JetBrains.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Sort enum example problem for JetBrains support (try to "Sort content" inside the enum). | |
*/ | |
public class Main { | |
public static void main(String[] args) { | |
for (final Mode mode : Mode.values()) { | |
System.out.printf("%-16s { new: %5b, edit: %5b, confirm: %5b, yet another: %5b }\n", | |
mode.name(), | |
mode.isNew(), | |
mode.isEdit(), | |
mode.isConfirm(), | |
mode.isYetAnother()); | |
} | |
} | |
enum Mode { | |
/** | |
* Javadoc for NEW_ONE | |
*/ | |
NEW_ONE, | |
/** | |
* Javadoc for NEW_TWO | |
*/ | |
NEW_TWO, | |
/** | |
* Javadoc for NEW_THREE | |
*/ | |
NEW_THREE, | |
/** | |
* Javadoc for NEW_FOUR | |
*/ | |
NEW_FOUR, | |
/** | |
* Javadoc for EDIT_ONE | |
*/ | |
EDIT_ONE, | |
EDIT_TWO, | |
EDIT_THREE, | |
CONFIRM_ONE, | |
CONFIRM_TWO, | |
CONFIRM_THREE, | |
YET_ANOTHER_MODE; | |
public boolean isNew() { | |
return this.oneOf(NEW_ONE, | |
NEW_TWO, | |
NEW_THREE, | |
NEW_FOUR); | |
} | |
public boolean isEdit() { | |
return this.oneOf(EDIT_ONE, | |
EDIT_TWO, | |
EDIT_THREE); | |
} | |
public boolean isConfirm() { | |
return this.oneOf(CONFIRM_ONE, | |
CONFIRM_TWO, | |
CONFIRM_THREE); | |
} | |
public boolean isYetAnother() { | |
return this.equals(YET_ANOTHER_MODE); | |
} | |
private boolean oneOf(final Mode... modes) { | |
for (final Mode mode : modes) { | |
if (this.equals(mode)) { | |
return true; | |
} | |
} | |
return false; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment