src/Class.js
function Class(name, superClasses, attributes, references, flexible) {
  /** The generic class instances Class
   * @constructor
   * @param {Object} attr The initial values of the instance
   */
  function ClassInstance(attr) {
    Object.defineProperties(this,
      { __jsmf__: {value: elementMeta(ClassInstance)}
      })
    createAttributes(this, ClassInstance)
    createReferences(this, ClassInstance)
    _.forEach(attr, (v,k) => {this[k] = v})
  }
  Object.defineProperties(ClassInstance.prototype, {
    conformsTo: {value: function () { return conformsTo(this) }, enumerable: false},
    getAssociated : {value: getAssociated, enumerable: false}
  })
  superClasses = superClasses || []
  superClasses = _.isArray(superClasses) ? superClasses : [superClasses]
  Object.assign(ClassInstance, {__name: name, superClasses, attributes: {}, references: {}})
  ClassInstance.errorCallback = flexible
    ? onError.silent
    : onError.throw
  Object.defineProperty(ClassInstance, '__jsmf__', {value: classMeta()})
  populateClassFunction(ClassInstance)
  if (attributes !== undefined) { ClassInstance.addAttributes(attributes)}
  if (references !== undefined) { ClassInstance.addReferences(references)}
  return ClassInstance
}
function Class(name, superClasses, attributes, references, flexible) {
  /** The generic class instances Class
   * @constructor
   * @param {Object} attr The initial values of the instance
   */
  function ClassInstance(attr) {
    Object.defineProperties(this,
      { __jsmf__: {value: elementMeta(ClassInstance)}
      })
    createAttributes(this, ClassInstance)
    createReferences(this, ClassInstance)
    _.forEach(attr, (v,k) => {this[k] = v})
  }
  Object.defineProperties(ClassInstance.prototype, {
    conformsTo: {value: function () { return conformsTo(this) }, enumerable: false},
    getAssociated : {value: getAssociated, enumerable: false}
  })
  superClasses = superClasses || []
  superClasses = _.isArray(superClasses) ? superClasses : [superClasses]
  Object.assign(ClassInstance, {__name: name, superClasses, attributes: {}, references: {}})
  ClassInstance.errorCallback = flexible
    ? onError.silent
    : onError.throw
  Object.defineProperty(ClassInstance, '__jsmf__', {value: classMeta()})
  populateClassFunction(ClassInstance)
  if (attributes !== undefined) { ClassInstance.addAttributes(attributes)}
  if (references !== undefined) { ClassInstance.addReferences(references)}
  return ClassInstance
}
function Class ( name , superClasses , attributes , references , flexible ) { /** The generic class instances Class
   * @constructor
   * @param {Object} attr The initial values of the instance
   */ function ClassInstance ( attr ) { Object . defineProperties ( this , { __jsmf__ : { value : elementMeta ( ClassInstance ) } } ) createAttributes ( this , ClassInstance ) createReferences ( this , ClassInstance ) _ . forEach ( attr , ( v , k ) => { this [ k ] = v } ) } Object . defineProperties ( ClassInstance . prototype , { conformsTo : { value : function ( ) { return conformsTo ( this ) } , enumerable : false } , getAssociated : { value : getAssociated , enumerable : false } } ) superClasses = superClasses || [ ] superClasses = _ . isArray ( superClasses ) ? superClasses : [ superClasses ] Object . assign ( ClassInstance , { __name : name , superClasses , attributes : { } , references : { } } ) ClassInstance . errorCallback = flexible ? onError . silent : onError . throw Object . defineProperty ( ClassInstance , '__jsmf__' , { value : classMeta ( ) } ) populateClassFunction ( ClassInstance ) if ( attributes !== undefined ) { ClassInstance . addAttributes ( attributes ) } if ( references !== undefined ) { ClassInstance . addReferences ( references ) } return ClassInstance }
Creation of a JSMF Class.

The attributes are given in a key value manner: the key is the name of the
attribute, the valu its type.

The references are also given in a key / value way. The name of the
references are the keys, the value can has the following attrivutes:
- type: The target type of the reference
- cardinality: the cardinality of the reference
- opposite: the name of the opposite reference
- oppositeCardinality: the cardinality of the opposite reference
- associated: the type of the associated data.

@constructor
@param {string} name - Name of the class
@param {Class[]} superClasses - The superclasses of the current class
@param {Object} attributes - the attributes of the class.
@param {Object} attributes - the references of the class.

@property {string} __name the name of the class
@property {Class[]} superClasses - the superclasses of this JSMF class
@property {Object[]} attributes - the attributes of the class
@property {Object[]} references - the references of the class
@returns {Class~ClassInstance}
Creation of a JSMF Class .