Issue #72

Reverse of enumeration items with int constructor

Added by Michael Dahlke about 7 years ago. Updated about 7 years ago.

Status:FeedbackStart date:20 August 2012
Priority:MediumDue date:
Assignee:-% Done:

0%

Category:-
Target version:-

Description

Good morning,

I just noticed the following anomaly when doing a reverse on the following enumeration:

/**
 * Denotes a section of a multi-section device (implement, sensor or alike).
 */

public enum Section
{

    /**
     * Relevant to all sections (average or alike).
     */
    ALL (-1),

    /**
     * Center section.
     */
    CENTER (0),

    /**
     * Innermost left section
     */
    LEFT_1 (1),

    /**
     * Section left of {@link #LEFT_1}
     */
    LEFT_2 (3),

    /**
     * Section left of {@link #LEFT_2}
     */
    LEFT_3 (5),

    /**
     * Section left of {@link #LEFT_3}
     */
    LEFT_4 (7),


    /**
     * Innermost right section
     */
    RIGHT_1 (2),

    /**
     * Section right of {@link #RIGHT_1}
     */
    RIGHT_2 (4),

    /**
     * Section right of {@link #RIGHT_2}
     */
    RIGHT_3 (6),

    /**
     * Section right of {@link #RIGHT_3}
     */
    RIGHT_4 (8);


    public final int sectionId;


    private Section (int sectionId)
    {
        this.sectionId = sectionId;
    }


    public static Section fromSectionId (int sectionId)
    {
        for (Section section : Section.values ()) {
            if (section.sectionId == sectionId) {
                return section;
            }
        }

        return null;
    }
}

The source above cannot be processed because of the -1 literal given as constructor parameter for the ALL item.

Changing the literal from -1 to 0xFFFFFFFF does work however.

Best regards,

Michael

History

#1 Updated by Christophe Malgouyres about 7 years ago

  • Status changed from New to Feedback

I’m unable to reproduce this error with JavaDesigner 2.1.00, could you please confirm you’re working with this version?

Also available in: Atom PDF