Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package mixing;
- import java.util.ArrayList;
- import java.util.List;
- public aspect Interaction {
- public static final long TIMEPERIODMS = 2000;
- private List<Long> timeSlots = new ArrayList<>();
- pointcut callTimeSlotAvailable(long i): args(i) && call(* ExampleScenario.Consumer.timeSlotAvailable(long));
- boolean around(long startTime) : callTimeSlotAvailable(startTime) {
- boolean available = true;
- for (Long timeSlotStart : timeSlots) {
- System.out.println(Long.toString(startTime) + " " + Long.toString(timeSlotStart + TIMEPERIODMS));
- if (
- // Requested time slot starts in current time slot
- (startTime >= timeSlotStart && startTime <= timeSlotStart + TIMEPERIODMS) ||
- // Requested time slot ends in current time slot
- (startTime + TIMEPERIODMS >= timeSlotStart && startTime + TIMEPERIODMS <= timeSlotStart + TIMEPERIODMS)) {
- available = false;
- }
- }
- if (available) {
- this.timeSlots.add(startTime);
- }
- return available;
- }
- }
Add Comment
Please, Sign In to add comment