Guest User

Untitled

a guest
Jan 22nd, 2018
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. package mixing;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.List;
  5.  
  6. public aspect Interaction {
  7.  
  8. public static final long TIMEPERIODMS = 2000;
  9. private List<Long> timeSlots = new ArrayList<>();
  10.  
  11. pointcut callTimeSlotAvailable(long i): args(i) && call(* ExampleScenario.Consumer.timeSlotAvailable(long));
  12.  
  13. boolean around(long startTime) : callTimeSlotAvailable(startTime) {
  14. boolean available = true;
  15.  
  16. for (Long timeSlotStart : timeSlots) {
  17. System.out.println(Long.toString(startTime) + " " + Long.toString(timeSlotStart + TIMEPERIODMS));
  18. if (
  19. // Requested time slot starts in current time slot
  20. (startTime >= timeSlotStart && startTime <= timeSlotStart + TIMEPERIODMS) ||
  21. // Requested time slot ends in current time slot
  22. (startTime + TIMEPERIODMS >= timeSlotStart && startTime + TIMEPERIODMS <= timeSlotStart + TIMEPERIODMS)) {
  23. available = false;
  24. }
  25. }
  26.  
  27. if (available) {
  28. this.timeSlots.add(startTime);
  29. }
  30.  
  31. return available;
  32. }
  33. }
Add Comment
Please, Sign In to add comment