Esempio n. 1
0
 public boolean isValidExchange(SerialNumber serialNumber, Exchange request) {
   // create upper bound for calculation of average
   SerialNumber validityCheckBound =
       new SerialNumber(serialNumber.getSerialNumber().add(ADD_FOR_BOUND));
   // find the set of serial #'s strictly greater than serialNumber and <= validityCheckBound
   NavigableSet<SerialNumber> temp =
       getExclusiveToInclusiveSubset(
           request.getCompatibleProducts(), serialNumber, validityCheckBound);
   // find the st of serial #'s strictly greater than serialNumber and less than average
   // if empty, no compatible product exists
   return !(getExclusiveSubset(request, serialNumber, average(temp)).isEmpty());
 }
Esempio n. 2
0
 // returns validity of given serial number
 public static Boolean isValidSerialNumber(SerialNumber serialNumber) {
   // check whether even and the third bit is set
   return serialNumber.isOdd() && checkLowerBound(serialNumber);
 }