SquirrelJME/SquirrelJME

View on GitHub
modules/tool-classfile/src/main/java/net/multiphasicapps/classfile/MethodFlag.java

Summary

Maintainability
A
0 mins
Test Coverage
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the Mozilla Public License Version 2.0.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package net.multiphasicapps.classfile;

import cc.squirreljme.runtime.cldc.debug.Debugging;

/**
 * These are flags which are used by methods.
 *
 * @since 2016/04/23
 */
public enum MethodFlag
    implements MemberFlag
{
    /** Public method. */
    PUBLIC,
    
    /** Private method. */
    PRIVATE,
    
    /** Protected method. */
    PROTECTED,
    
    /** Static method. */
    STATIC,
    
    /** Final method. */
    FINAL,
    
    /** Synchronized method. */
    SYNCHRONIZED,
    
    /** Bridge method. */
    BRIDGE,
    
    /** Variable argument method. */
    VARARGS,
    
    /** Native method. */
    NATIVE,
    
    /** Abstract method. */
    ABSTRACT,
    
    /** Strict floating point method. */
    STRICT,
    
    /** Synthetic method. */
    SYNTHETIC,
    
    /* End. */
    ;
    
    /**
     * Returns the bit mask which is used for this flag.
     *
     * @return The bit mask used for the flag.
     * @since 2017/07/07
     */
    @Override
    public final int javaBitMask()
    {
        switch (this)
        {
            case PUBLIC:        return 0x0001;
            case PRIVATE:        return 0x0002;
            case PROTECTED:        return 0x0004;
            case STATIC:        return 0x0008;
            case FINAL:            return 0x0010;
            case SYNCHRONIZED:    return 0x0020;
            case BRIDGE:        return 0x0040;
            case VARARGS:        return 0x0080;
            case NATIVE:        return 0x0100;
            case ABSTRACT:        return 0x0400;
            case STRICT:        return 0x0800;
            case SYNTHETIC:        return 0x1000;

            default:
                throw Debugging.oops();
        }
    }
}