Created
June 2, 2014 07:59
-
-
Save raindev/8e2c17589404684582a0 to your computer and use it in GitHub Desktop.
Invalid Java enum declaration shown as good code in Intellij IDEA
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
package test; | |
import java.util.Collection; | |
import java.util.Collections; | |
import static java.util.Arrays.asList; | |
import static java.util.Collections.unmodifiableCollection; | |
public enum State { | |
STATE1 { | |
private Collection<State> accessibleFrom = unmodifiableCollection( asList( STATE2 ) ); | |
@Override | |
public Collection<State> accessibleFrom() { | |
return accessibleFrom; | |
} | |
}, | |
STATE2 { | |
private Collection<State> accessibleFrom = unmodifiableCollection( asList( STATE1, STATE3 ) ); | |
@Override | |
public Collection<State> accessibleFrom() { | |
return accessibleFrom; | |
} | |
}, | |
STATE3 { | |
private Collection<State> accessibleFrom = Collections.emptyList(); | |
@Override | |
public Collection<State> accessibleFrom() { | |
return accessibleFrom; | |
} | |
}; | |
public abstract Collection<State> accessibleFrom(); | |
public boolean accessibleFrom( State state ) { | |
return state == this || accessibleFrom().contains( state ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment