UNPKG

bugcore

Version:

bugcore is a JavaScript library that provides a foundational architecture for object oriented JS

126 lines (94 loc) 3.49 kB
/* * Copyright (c) 2016 airbug Inc. http://airbug.com * * bugcore may be freely distributed under the MIT license. */ //------------------------------------------------------------------------------- // Annotations //------------------------------------------------------------------------------- //@Export('GraphNode') //@Require('Class') //@Require('Obj') //------------------------------------------------------------------------------- // Context //------------------------------------------------------------------------------- require('bugpack').context("*", function(bugpack) { //------------------------------------------------------------------------------- // BugPack //------------------------------------------------------------------------------- var Class = bugpack.require('Class'); var Obj = bugpack.require('Obj'); //------------------------------------------------------------------------------- // Declare Class //------------------------------------------------------------------------------- /** * @class * @extends {Obj} */ var GraphNode = Class.extend(Obj, { _name: "GraphNode", //------------------------------------------------------------------------------- // Constructor //------------------------------------------------------------------------------- /** * @constructs * @param {*} value */ _constructor: function(value) { this._super(); //------------------------------------------------------------------------------- // Private Properties //------------------------------------------------------------------------------- /** * @private * @type {*} */ this.value = value; }, //------------------------------------------------------------------------------- // Getters and Setters //------------------------------------------------------------------------------- /** * @return {*} */ getValue: function() { return this.value; }, //------------------------------------------------------------------------------- // Obj Methods //------------------------------------------------------------------------------- /** * @param {*} value * @return {boolean} */ equals: function(value) { if (Class.doesExtend(value, GraphNode)) { return Obj.equals(value.getValue(), this.value); } return false; }, /** * @return {number} */ hashCode: function() { if (!this._hashCode) { this._hashCode = Obj.hashCode("[GraphNode]" + Obj.hashCode(this.value)); } return this._hashCode; }, /** * @return {string} */ toString: function() { var output = ""; output += "{\n"; output += " " + this.value.toString() + "\n"; output += "}\n"; return output; } }); //------------------------------------------------------------------------------- // Exports //------------------------------------------------------------------------------- bugpack.export('GraphNode', GraphNode); });