public String check(mxGraph graph,Object edge,Object source,Object target,int sourceOut,int targetIn){
  mxIGraphModel model=graph.getModel();
  Object sourceValue=model.getValue(source);
  Object targetValue=model.getValue(target);
  StringBuffer error=new StringBuffer();
  if ((this.source && checkType(graph,sourceValue,type,attr,value)) || (!this.source && checkType(graph,targetValue,type,attr,value))) {
    if (!isUnlimited()) {
      int m=getMaxValue();
      if (m == 0 || (this.source && sourceOut >= m) || (!this.source && targetIn >= m)) {
        error.append(countError + "\n");
      }
    }
    if (validNeighbors != null) {
      boolean isValid=!validNeighborsAllowed;
      Iterator<String> it=validNeighbors.iterator();
      while (it.hasNext()) {
        String tmp=it.next();
        if (this.source && checkType(graph,targetValue,tmp)) {
          isValid=validNeighborsAllowed;
          break;
        }
 else         if (!this.source && checkType(graph,sourceValue,tmp)) {
          isValid=validNeighborsAllowed;
          break;
        }
      }
      if (!isValid) {
        error.append(typeError + "\n");
      }
    }
  }
  return (error.length() > 0) ? error.toString() : null;
}

public String check ( mxGraph graph , Object edge , Object source , Object target , int sourceOut , int targetIn ) { mxIGraphModel model = graph . getModel ( ) ; Object sourceValue = model . getValue ( source ) ; Object targetValue = model . getValue ( target ) ; StringBuffer error = new StringBuffer ( ) ; if ( ( this . source && checkType ( graph , sourceValue , type , attr , value ) ) || ( ! this . source && checkType ( graph , targetValue , type , attr , value ) ) ) { if ( ! isUnlimited ( ) ) { int m = getMaxValue ( ) ; if ( m == 0 || ( this . source && sourceOut >= m ) || ( ! this . source && targetIn >= m ) ) { error . append ( countError + "\n" ) ; } } if ( validNeighbors != null ) { boolean isValid = ! validNeighborsAllowed ; Iterator < String > it = validNeighbors . iterator ( ) ; while ( it . hasNext ( ) ) { String tmp = it . next ( ) ; if ( this . source && checkType ( graph , targetValue , tmp ) ) { isValid = validNeighborsAllowed ; break ; } else if ( ! this . source && checkType ( graph , sourceValue , tmp ) ) { isValid = validNeighborsAllowed ; break ; } } if ( ! isValid ) { error . append ( typeError + "\n" ) ; } } } return ( error . length ( ) > 0 ) ? error . toString ( ) : null ; }
function : check checks the multiplicity for the given arguments and returns the error for the given connection or null if the multiplicity does not apply . parameters : graph - reference to the enclosing graph instance . edge - cell that represents the edge to validate . source - cell that represents the source terminal . target - cell that represents the target terminal . sourceout - number of outgoing edges from the source terminal . targetin - number of incoming edges for the target terminal .
