/**
* @param {String} name
*
* @properties={typeid:24,uuid:"AACFB629-BDC1-4250-BCFA-E564C686153E"}
*/
function BaseEntity(name) {
/**
* Storing name as a protected instance variable
* @protected
*/
this.name = name
}
/**
* Self executing function (IIFE) to setup the prototype of BaseEntity when the scope in which the functions reside gets instantiated
*
* @private
* @SuppressWarnings(unused)
* @properties={typeid:35,uuid:"13635962-8720-4666-9955-6D8BEF94CE38",variableType:-4}
*/
var initBaseEntity = (function() {
//Setting the prototype of BaseEntity to an object with a set of methods
BaseEntity.prototype = {
publicMethod: function() {},
/**
* This is bananas
* @protected
*/
protectedMethod: function() {},
/**
* and this
too
* @deprecated
*/
deprecatedMethod: function() {}
}
//Extending the previously set prototype object with another method
BaseEntity.prototype.getName = function() {
return this.name
}
}())
/**
* The extends tag signals the build system that public & protected members added through super constructor are known to code completion and the build system<br>
* <br>
* The constructor tag takes care of removing the inconsistent return value warning<br>
* <br>
*
* @constructor
* @extends {BaseEntity}
* @param {String} name
* @param {String} type
*
* @properties={typeid:24,uuid:"1D55BCFC-CEE2-4445-95E7-792152E36876"}
{String} type
*/
function ExtendedEntity(name, type) {
//Fail-save for when the ExtendedEntity gets called without the 'new' keyword
if (! (this instanceof ExtendedEntity)) {
return new ExtendedEntity(name, type)
}
//Calling the BaseEntity constructor, so that the logic defined in the constructor is invoked
BaseEntity.call(this, name)
/**@protected*/
this.type = type
}
/**
* Self executing function (IIFE) to setup the prototype of ExtendedEntity when the scope in which the functions reside gets instantiated
*
* @private
* @SuppressWarnings(unused)
* @properties={typeid:35,uuid:"8F148031-763B-47B8-A69C-35458EDB6857",variableType:-4}
*/
var initExtendedEntity = (function() {
/* Setting the prototype of ExtendedEntity to an object that has BaseEntity.prototype as prototype
* BaseEntity.prototype is not used directly as prototype for ExtendedEntity, as this would mean that any additions made to
* the prototype of ExtendedEntity would actually be made on the prototype of BaseEntity
*/
ExtendedEntity.prototype = Object.create(BaseEntity.prototype, {})
//Properly set the constructor
ExtendedEntity.prototype.constructor = ExtendedEntity
ExtendedEntity.prototype.getType = function() {
return this.type
}
}())
/**
* @properties={typeid:24,uuid:"586D324D-F1D9-474B-B4EE-E9238E73F80E"}
*/
function test() {
var x = new ExtendedEntity('Servoy', 'company')
application.output(x.getName()) //Yields 'Servoy'
application.output(x.getType()) //Yields 'company'
//These bits of code will result in warnings
x.protectedMethod()
x.deprecatedMethod()
x.name
x.type
} |