PP.checkInterface

Syntax

checkInterface(obj, inter);

Parameters

obj. Class object to be checked.

inter. Interface or interfaces array to be checked on if they are implemented with the specified class.

Description

The checkInterface method throws an error if the specified class does not implement selected interfaces.

Comments

If the class does not implement the selected interfaces, this method throws an error that looks as follows: Exception. Source:  Message: <Class name> is not implemented <Interface name>.

Example

To execute the example, add a link to PP.js scenario file to HTML page. Create an object of the PP.Ui.Button class and check it for implementation of the PP.Ui.IContentEditable and PP.IDataSource interfaces:

// Create a button
var button = new PP.Ui.Button({
    Width: 100,
    Height: 100
});
try {
    // Check if the button implements the PP.Ui.IContentEditable interface
    PP.checkInterface(button, PP.Ui.IContentEditable);
    console.log("The PP.Ui.Button class implements the PP.Ui.IContentEditable interface");
} catch (error) {
    console.log(error);
};
try {
    // Check if the button implements the PP.IDataSource interface
    PP.checkInterface(button, PP.IDataSource);
    console.log("The PP.Ui.Button class implements the PP.IDataSource interface");
} catch (error) {
    console.log(error);
};

After executing the example the object of the PP.Ui.Button class is checked if it implements the PP.Ui.IContentEditable and PP.IDataSource interfaces. An exception was thrown, because the button does not implement the PP.IDataSource interface. The check results and error text are shown in the browser console:

The PP.Ui.Button class implements the interface PP.Ui.IContentEditable
Exception. Source:  Message: Button is not implemented IDataSource

See also:

PP