001    package org.bukkit;
002    
003    /**
004     * An enum to specify a rotation based orientation, like that on a clock.
005     * <p>
006     * It represents how something is viewed, as opposed to cardinal directions.
007     */
008    public enum Rotation {
009    
010        /**
011         * No rotation
012         */
013        NONE,
014        /**
015         * Rotated clockwise by 90 degrees
016         */
017        CLOCKWISE,
018        /**
019         * Flipped upside-down, a 180 degree rotation
020         */
021        FLIPPED,
022        /**
023         * Rotated counter-clockwise by 90 degrees
024         */
025        COUNTER_CLOCKWISE,
026        ;
027    
028        private static final Rotation [] rotations = values();
029    
030        /**
031         * Rotate clockwise by 90 degrees.
032         *
033         * @return the relative rotation
034         */
035        public Rotation rotateClockwise() {
036            return rotations[(this.ordinal() + 1) & 0x3];
037        }
038    
039        /**
040         * Rotate counter-clockwise by 90 degrees.
041         *
042         * @return the relative rotation
043         */
044        public Rotation rotateCounterClockwise() {
045            return rotations[(this.ordinal() - 1) & 0x3];
046        }
047    }