public <T>T checkSynapses(SynapseParameterGetter<T> check,Polarity polarity){
  Collection<Synapse> synapses;
  Synapse prototype;
  if (Polarity.EXCITATORY == polarity) {
    synapses=exSynapseSet;
    prototype=excitatoryPrototype;
    if (useGroupLevelSettings || synapses.isEmpty()) {
      return check.getParameterFromSynapse(prototype);
    }
  }
 else   if (Polarity.INHIBITORY == polarity) {
    synapses=inSynapseSet;
    prototype=inhibitoryPrototype;
    if (useGroupLevelSettings || synapses.isEmpty()) {
      return check.getParameterFromSynapse(prototype);
    }
  }
 else {
    synapses=getAllSynapses();
    if (synapses.isEmpty()) {
      return null;
    }
  }
  Iterator<Synapse> synIter=synapses.iterator();
  T first=check.getParameterFromSynapse(synIter.next());
  while (synIter.hasNext()) {
    if (!first.equals(check.getParameterFromSynapse(synIter.next()))) {
      return null;
    }
  }
  return first;
}

public < T > T checkSynapses ( SynapseParameterGetter < T > check , Polarity polarity ) { Collection < Synapse > synapses ; Synapse prototype ; if ( Polarity . EXCITATORY == polarity ) { synapses = exSynapseSet ; prototype = excitatoryPrototype ; if ( useGroupLevelSettings || synapses . isEmpty ( ) ) { return check . getParameterFromSynapse ( prototype ) ; } } else if ( Polarity . INHIBITORY == polarity ) { synapses = inSynapseSet ; prototype = inhibitoryPrototype ; if ( useGroupLevelSettings || synapses . isEmpty ( ) ) { return check . getParameterFromSynapse ( prototype ) ; } } else { synapses = getAllSynapses ( ) ; if ( synapses . isEmpty ( ) ) { return null ; } } Iterator < Synapse > synIter = synapses . iterator ( ) ; T first = check . getParameterFromSynapse ( synIter . next ( ) ) ; while ( synIter . hasNext ( ) ) { if ( ! first . equals ( check . getParameterFromSynapse ( synIter . next ( ) ) ) ) { return null ; } } return first ; }
a generic method which takes in a functional interface and a polarity . it then performs that function on every synapse in the set ( s ) corresponding to the polarity parameter and returns a result matching the type specified by the passed function .
