src/Class.js
function addReference(name, target, sourceCardinality, opposite, oppositeCardinality, associated, errorCallback, oppositeErrorCallback) {
  this.references[name] = { type: target || Type.JSMFAny
                          , cardinality: Cardinality.check(sourceCardinality)
                          }
  if (opposite !== undefined) {
    this.references[name].opposite = opposite
    target.references[opposite] =
          { type: this
          , cardinality: oppositeCardinality === undefined && target.references[opposite] !== undefined ?
              target.references[opposite].cardinality :
              Cardinality.check(oppositeCardinality)
          , opposite: name
          , errorCallback: oppositeErrorCallback === undefined && target.references[opposite] !== undefined
              ? target.references[opposite].oppositeErrorCallback
              : this.errorCallback
          }
  }
  if (associated !== undefined) {
    this.references[name].associated = associated
    if (opposite !== undefined) {
      target.references[opposite].associated = associated
    }
  }
  this.references[name].errorCallback = errorCallback || this.errorCallback
}
function addReference(name, target, sourceCardinality, opposite, oppositeCardinality, associated, errorCallback, oppositeErrorCallback) {
  this.references[name] = { type: target || Type.JSMFAny
                          , cardinality: Cardinality.check(sourceCardinality)
                          }
  if (opposite !== undefined) {
    this.references[name].opposite = opposite
    target.references[opposite] =
          { type: this
          , cardinality: oppositeCardinality === undefined && target.references[opposite] !== undefined ?
              target.references[opposite].cardinality :
              Cardinality.check(oppositeCardinality)
          , opposite: name
          , errorCallback: oppositeErrorCallback === undefined && target.references[opposite] !== undefined
              ? target.references[opposite].oppositeErrorCallback
              : this.errorCallback
          }
  }
  if (associated !== undefined) {
    this.references[name].associated = associated
    if (opposite !== undefined) {
      target.references[opposite].associated = associated
    }
  }
  this.references[name].errorCallback = errorCallback || this.errorCallback
}
function addReference ( name , target , sourceCardinality , opposite , oppositeCardinality , associated , errorCallback , oppositeErrorCallback ) { this . references [ name ] = { type : target || Type . JSMFAny , cardinality : Cardinality . check ( sourceCardinality ) } if ( opposite !== undefined ) { this . references [ name ] . opposite = opposite target . references [ opposite ] = { type : this , cardinality : oppositeCardinality === undefined && target . references [ opposite ] !== undefined ? target . references [ opposite ] . cardinality : Cardinality . check ( oppositeCardinality ) , opposite : name , errorCallback : oppositeErrorCallback === undefined && target . references [ opposite ] !== undefined ? target . references [ opposite ] . oppositeErrorCallback : this . errorCallback } } if ( associated !== undefined ) { this . references [ name ] . associated = associated if ( opposite !== undefined ) { target . references [ opposite ] . associated = associated } } this . references [ name ] . errorCallback = errorCallback || this . errorCallback }
Add a reference to the Class
@method
@memberof Class~ClassInstance
@param {string} name - The reference name
@param {Class} target - The target class. Note that {@link Class} and {@link Model}
can be targeted as well, even if they are not formally
instances of {@link Class}.
@param {Cardinality} sourceCardinality - The cardinality of the reference
@param {string} opposite - The name of the ooposite reference if any,
it can be an existing or a new reference name.
@param {Cardinality} oppositeCardinality - The cardinality of the opposite reference,
not used if opposite is not set.
@param {Class} associated - The type of the associated data linked to this reference
@param {Function} errorCallback - Defines what to do when wrong types are assigned
@param {Function} oppositeErrorCallback - Defines what to do when wrong types are
assigned to the opposite reference
Add a reference to the Class