Introduction

JOII comes with a Reflection API that allows you to extract and read metadata from Class definitions. The Reflection API is not exposed to the global namespace but is confined within the JOII object.

// Create a simple class to inspect.
var MyClass = Class({ final: true }, {
    'public string name' : 'Bob',
    'public number age'  : 42,

    'public setData' : function(name, age) {
        this.setName(name);
        this.setAge(age);
    }
});

// Create a reflector based on 'MyClass'
var reflector = new JOII.Reflection.Class(MyClass);

reflector.hasProperty('name');  // true
reflector.hasMethod('setData'); // true

// Lets inspect the method 'setData'
var method = reflector.getMethod('setData');

method.getName();               // "setData"
method.getParameters();         // ["name", "age"]
method.getType();               // "function"
method.isPublic();              // true
method.isFinal();               // false
// ...