From d54e29051f85c6f2dbcabc9d04ac931309a0b602 Mon Sep 17 00:00:00 2001 From: nikhilbarar Date: Wed, 13 Jun 2018 02:54:09 +0530 Subject: [PATCH] #466: Fix Checkstyle Issues --- monitor-object/pom.xml | 24 +++++++ .../com/iluwatar/monitor/AbstractMonitor.java | 26 ++++++- .../java/com/iluwatar/monitor/Assertion.java | 22 ++++++ .../java/com/iluwatar/monitor/Condition.java | 22 ++++++ .../java/com/iluwatar/monitor/Monitor.java | 71 +++++++------------ .../com/iluwatar/monitor/MonitorListener.java | 25 +++++++ .../iluwatar/monitor/RunnableWithResult.java | 31 +++++++- .../java/com/iluwatar/monitor/Semaphore.java | 22 ++++++ .../com/iluwatar/monitor/TrueAssertion.java | 24 ++++++- .../com/iluwatar/monitor/examples/Queue.java | 22 ++++++ .../monitor/examples/VoteInterface.java | 24 ++++++- .../monitor/examples/VoteMonitor.java | 22 ++++++ .../com/iluwatar/monitor/AssertionTest.java | 24 ++++++- .../iluwatar/monitor/ThreadSignalTest.java | 30 ++++++-- .../test/java/com/iluwatar/monitor/Voter.java | 22 ++++++ .../java/com/iluwatar/monitor/Voter0.java | 22 ++++++ .../java/com/iluwatar/monitor/Voter1.java | 22 ++++++ .../java/com/iluwatar/monitor/Voter2.java | 22 ++++++ 18 files changed, 420 insertions(+), 57 deletions(-) diff --git a/monitor-object/pom.xml b/monitor-object/pom.xml index 011300547..d5da9ff54 100644 --- a/monitor-object/pom.xml +++ b/monitor-object/pom.xml @@ -1,4 +1,28 @@ + 4.0.0 diff --git a/monitor-object/src/main/java/com/iluwatar/monitor/AbstractMonitor.java b/monitor-object/src/main/java/com/iluwatar/monitor/AbstractMonitor.java index dd1b512e9..922ec7e3c 100644 --- a/monitor-object/src/main/java/com/iluwatar/monitor/AbstractMonitor.java +++ b/monitor-object/src/main/java/com/iluwatar/monitor/AbstractMonitor.java @@ -1,3 +1,25 @@ +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.monitor; import java.util.ArrayList; @@ -135,7 +157,7 @@ public abstract class AbstractMonitor { * Create a condition queue with no associated checked Assertion. */ protected Condition makeCondition() { - return makeCondition(null, TrueAssertion.singleton); + return makeCondition(null, TrueAssertion.SINGLETON); } /** @@ -150,7 +172,7 @@ public abstract class AbstractMonitor { * Create a condition queue with no associated checked Assertion. */ protected Condition makeCondition(String name) { - return makeCondition(name, TrueAssertion.singleton); + return makeCondition(name, TrueAssertion.SINGLETON); } /** Register a listener. */ diff --git a/monitor-object/src/main/java/com/iluwatar/monitor/Assertion.java b/monitor-object/src/main/java/com/iluwatar/monitor/Assertion.java index b77586c10..c1107a50e 100644 --- a/monitor-object/src/main/java/com/iluwatar/monitor/Assertion.java +++ b/monitor-object/src/main/java/com/iluwatar/monitor/Assertion.java @@ -1 +1,23 @@ +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.monitor; /** * Assertions that may be checked from time to time. */ public abstract class Assertion { private static final String DEFAULTMESSAGE = "Assertion Failure"; protected String message = DEFAULTMESSAGE; /** This method says whether the assertion is true. */ public abstract boolean isTrue(); /** Throw an AssertionError if the assertion is not true. */ public void check() { check(isTrue(), message); } /** Throw an AssertionError if the parameter is not true. */ public static void check(boolean b) { check(b, DEFAULTMESSAGE); } /** Throw an AssertionError if the boolean parameter is not true. */ public static void check(boolean b, String message) { if (!b) { throw new AssertionError(message); } } } \ No newline at end of file diff --git a/monitor-object/src/main/java/com/iluwatar/monitor/Condition.java b/monitor-object/src/main/java/com/iluwatar/monitor/Condition.java index be104770f..88d99c68f 100644 --- a/monitor-object/src/main/java/com/iluwatar/monitor/Condition.java +++ b/monitor-object/src/main/java/com/iluwatar/monitor/Condition.java @@ -1 +1,23 @@ +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.monitor; /** * A condition queue. * Uses the signal and wait discipline (SW) or signal and leave (SL). * Each Condition object is associated with a single {@link Assertion} object * and a single AbstractMonitor object. To construct a condition * use the makeCondition methods from * {@link AbstractMonitor} or {@link Monitor} * Threads can wait for the assertion represented by the Assertion object to * become true by calling method await(). Threads can indicate that * the assertion has become true by calling either method signal() * (SW) or signalAndLeave() (SL). All these methods check the * assertion and the monitor's invariant as appropriate. * Threads which wait on a Condition may supply a priority. In the absence of * priority, waiting is fair -- in fact first-in last-out (FIFO). * Each of the await(), signal(), and * signalAndLeave() methods have corresponding conditional * versions, which first check the assertion before awaiting or signalling. * These are: conditionalAwait(), conditionalSignal(), * and conditionalSignalAndLeave(). * Conditions also support a {@link #count} accessor to determine the number of * threads waiting on the condition. * Condition objects are intended to be used only by the thread which occupies * the monitor which created them. */ public class Condition { private final AbstractMonitor homeMonitor; private final Assertion assertion; private final Semaphore queue; private volatile int count; private final String name; Condition(String name, AbstractMonitor homeMonitor, Assertion assertion) { this.name = name; this.homeMonitor = homeMonitor; this.assertion = assertion; this.queue = new Semaphore(0); this.count = 0; } public String getName() { return name; } /** * Just like await, but with a priority. Threads awaiting with a lesser priority * value are re-admitted to the monitor in preference to threads awaiting with a * greater priority value. When priority values are the same, the order is FIFO. * * @param priority * Lower value means more urgent. * @throws AssertionError * if the current thread is not the occupant. * @throws AssertionError * if the invariant is not true to start * @throws AssertionError * if the assertion is not true on return * @see #await() */ public void await(int priority) { homeMonitor.notifyCallAwait(this); Assertion.check(homeMonitor.occupant == Thread.currentThread(), "Thread is not occupant"); count += 1; Assertion.check(homeMonitor.invariant(), "Invariant of monitor " + homeMonitor.getName()); homeMonitor.occupant = null; homeMonitor.entrance.release(); queue.acquire(priority); count -= 1; homeMonitor.occupant = Thread.currentThread(); // It's not clear that the following check is needed anymore, // as there is now a check made on the signal. assertion.check(); homeMonitor.notifyReturnFromAwait(this); } /** * Wait until a condition is signalled. The thread waits outside the monitor * until the condition is signalled. * Precondition: Increasing the count by 1 must make the invariant true. This * thread is in the monitor. * Postcondition: The assertion associated with this condition queue. This * thread is in the monitor. * Note: threads are queued in a FIFO manner unless a priority is used; * cond.await() is equivalent to cond.await( Integer.MAX_VALUE * ). * * @throws AssertionError * if the current thread is not the occupant. * @throws AssertionError * if the invariant is not true to start * @throws AssertionError * if the assertion is not true on return */ public void await() { await(Integer.MAX_VALUE); } /** * Wait only if the condition is not already true. * * @throws AssertionError * if neither the invariant nor the assertion associated with this * object is true * @throws AssertionError * if the current thread is not the occupant. * @throws AssertionError * if the assertion is not true on return * @see #await() */ public void conditionalAwait() { conditionalAwait(Integer.MAX_VALUE); } /** * Just like conditionalAwait, but with a priority. * * @param priority * Lower value means more urgent. * @throws AssertionError * if neither the invariant nor the assertion associated with this * object is true * @throws AssertionError * if the current thread is not the occupant. * @throws AssertionError * if the assertion is not true on return * @see #conditionalAwait() * @see #await( int priority ) * */ public void conditionalAwait(int priority) { if (!assertion.isTrue()) { await(priority); } } /** * Signal this condition if there is a waiting thread. * Allows one thread that was waiting on the condition to reenter the monitor. * Consequently the signalling thread waits outside. The signalling thread is * allowed back into the monitor, once the monitor is again unoccupied. Threads * which have signalled wait with a higher than normal priority and thus are * allowed in ahead of other threads that are waiting to enter the monitor * (e.g., those waiting in {@link AbstractMonitor#enter()}). * If there is no waiting thread, then this is a no-op, but the invariant is * still checked, as it is a postcondition. * Preconditions: * * Postcondition: * * * @throws AssertionError * if the current thread is not the occupant. * @throws AssertionError * if there is a waiting thread and the assertion is false (after * decreasing the count by 1). * @throws AssertionError * if invariant is false on return. * */ public void signal() { Assertion.check(homeMonitor.occupant == Thread.currentThread(), "Thread is not occupant"); if (count > 0) { try { count -= 1; assertion.check(); } finally { count += 1; } homeMonitor.notifySignallerLeavesTemporarily(this); homeMonitor.notifySignallerAwakesAwaitingThread(this); homeMonitor.occupant = null; queue.release(); homeMonitor.entrance.acquire(0); // Priority 0 puts the signaller ahead of others. homeMonitor.occupant = Thread.currentThread(); homeMonitor.notifySignallerReenters(this); } Assertion.check(homeMonitor.invariant(), "Invariant of monitor " + homeMonitor.getName()); } /** * Allows one thread which was waiting on the condition to reenter the monitor. * This thread (the one calling signalAndLeave) leaves the monitor immediately. * Preconditions: * * Postcondition: This thread is not in the monitor. * * @throws AssertionError * if the current thread is not the occupant. * @throws AssertionError * if there is a waiting thread and the assertion is false (after * decreasing the count by 1). * @throws AssertionError * if there is no waiting thread and the invariant is false. * @see #signal() */ public void signalAndLeave() { Assertion.check(homeMonitor.occupant == Thread.currentThread(), "Thread is not occupant"); if (count > 0) { try { count -= 1; assertion.check(); } finally { count += 1; } homeMonitor.notifySignallerAwakesAwaitingThread(this); homeMonitor.occupant = null; queue.release(); } else { Assertion.check(homeMonitor.invariant(), "Invariant of monitor " + homeMonitor.getName()); homeMonitor.occupant = null; homeMonitor.entrance.release(); } homeMonitor.notifySignallerLeavesMonitor(this); } /** * Signal if there is a waiting thread, then leave the monitor. Allows one * thread which was waiting on the condition to reenter the monitor. This thread * (the one calling signalAndLeave) leaves the monitor immediately. * Preconditions: * * Postcondition: This thread is not in the monitor. * * @param result * A value to return. * @return The value of the result parameter. * @throws AssertionError * if the current thread is not the occupant. * @throws AssertionError * if there is a waiting thread and the assertion is false (after * decreasing the count by 1). * @throws AssertionError * there is no waiting thread and the invariant is false. */ public T signalAndLeave(T result) { signalAndLeave(); return result; } /** * Signal this condition if its assertion is true and there is a waiting thread. * More precisely the condition is only signalled if its assertion would be true * after the count is decreased by 1 and there is a waiting tread. * In such a case, the signalling thread waits outside. The signalling thread is * allowed back into the monitor, once the monitor is again unoccupied. Threads * which have signalled wait with a higher than normal priority and thus are * allowed in ahead of other threads that are waiting to enter the monitor * (e.g., those waiting in {@link AbstractMonitor#enter()}). * If the there are no awaiting threads, or the condition's assertion would not * be true after the count were decreased by one, this method is essentially a * no-op, although the invariant is still checked in such a case. * Preconditions: *
    *
  • If isEmpty(), the monitor's invariant must be true.
  • *
  • This thread is in the monitor.
  • *
* Postcondition: *
    *
  • The monitor's invariant. *
  • This thread is in the monitor. *
* * @throws AssertionError * if the current thread is not the occupant. * @throws AssertionError * if invariant is false on return. * @see #signal() */ public void conditionalSignal() { Assertion.check(homeMonitor.occupant == Thread.currentThread(), "Thread is not occupant"); if (count > 0) { boolean wouldBeTrue; count -= 1; wouldBeTrue = assertion.isTrue(); count += 1; if (wouldBeTrue) { homeMonitor.notifySignallerAwakesAwaitingThread(this); homeMonitor.notifySignallerLeavesTemporarily(this); homeMonitor.occupant = null; queue.release(); homeMonitor.entrance.acquire(); homeMonitor.occupant = Thread.currentThread(); homeMonitor.notifySignallerReenters(this); } } Assertion.check(homeMonitor.invariant(), "Invariant of monitor " + homeMonitor.getName()); } /** * Signal this condition if its assertion is true and there is a waiting thread; * leave regardless. * More precisely the condition is only signalled if the assertion would be true * after the count is decreased by 1 and there is a waiting thread. * This thread (the one calling signalAndLeave) leaves the monitor immediately. * Preconditions: *
    *
  • If isEmpty() or the assertion would be false after decreasing the count * by 1, the monitor's invariant must be true.
  • *
  • This thread is in the monitor.
  • *
* Postcondition: *
    *
  • This thread is not in the monitor. *
* * @throws AssertionError * if the current thread is not the occupant. * @throws AssertionError * there is no waiting thread and the invariant is false. * @throws AssertionError * if there is a waiting thread and the assertion is false (after * decreasing the count by 1) and the invariant is false. * @see #signalAndLeave() * @see #conditionalSignal() * */ public void conditionalSignalAndLeave() { Assertion.check(homeMonitor.occupant == Thread.currentThread(), "Thread is not occupant"); if (count > 0) { boolean wouldBeTrue; count -= 1; wouldBeTrue = assertion.isTrue(); count += 1; if (wouldBeTrue) { homeMonitor.notifySignallerAwakesAwaitingThread(this); homeMonitor.notifySignallerLeavesMonitor(this); homeMonitor.occupant = null; queue.release(); } else { homeMonitor.notifySignallerLeavesMonitor(this); homeMonitor.leaveWithoutATrace(); } } else { homeMonitor.notifySignallerLeavesMonitor(this); homeMonitor.leaveWithoutATrace(); } } /** * Signal this condition if its assertion is true and there is a waiting thread. * Leave regardless. More precisely the condition is only signalled if the * assertion would be true after the count is decreased by 1. * This thread (the one calling signalAndLeave) leaves the monitor immediately. * Preconditions: *
    *
  • If isEmpty() or the assertion would be false after decreasing the count * by 1, the monitor's invariant must be true.
  • *
  • This thread is in the monitor.
  • *
* Postcondition: *
    *
  • This thread is not in the monitor. *
* * @param result * A value to be returned. * @return The value of the result parameter. * @throws AssertionError * if the current thread is not the occupant. * @throws AssertionError * there is no waiting thread and the invariant is false. * @throws AssertionError * if there is a waiting thread and the assertion is false (after * decreasing the count by 1) and the invariant is false. * @see #conditionalSignalAndLeave() * */ public T conditionalSignalAndLeave(T result) { conditionalSignalAndLeave(); return result; } /** * Test if any thread is waiting on this condition. * * @return count() == 0 . * @throws AssertionError * if the current thread is not the occupant. */ public boolean isEmpty() { Assertion.check(homeMonitor.occupant == Thread.currentThread(), "Thread is not occupant"); return count == 0; } /** * How many threads are waiting on this condition. * * @return the number of Threads waiting on this condition. * @throws AssertionError * if the current thread is not the occupant. */ public int count() { Assertion.check(homeMonitor.occupant == Thread.currentThread(), "Thread is not occupant"); return count; } } \ No newline at end of file diff --git a/monitor-object/src/main/java/com/iluwatar/monitor/Monitor.java b/monitor-object/src/main/java/com/iluwatar/monitor/Monitor.java index bf2ed5915..1cd8fe590 100644 --- a/monitor-object/src/main/java/com/iluwatar/monitor/Monitor.java +++ b/monitor-object/src/main/java/com/iluwatar/monitor/Monitor.java @@ -1,3 +1,25 @@ +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.monitor; /** @@ -9,7 +31,7 @@ public final class Monitor extends AbstractMonitor { private Assertion invariant; public Monitor() { - this(TrueAssertion.singleton); + this(TrueAssertion.SINGLETON); } public Monitor(Assertion invariant) { @@ -17,7 +39,7 @@ public final class Monitor extends AbstractMonitor { } public Monitor(String name) { - this(name, TrueAssertion.singleton); + this(name, TrueAssertion.SINGLETON); } public Monitor(String name, Assertion invariant) { @@ -29,49 +51,4 @@ public final class Monitor extends AbstractMonitor { public boolean invariant() { return invariant.isTrue(); } - - @Override - public void enter() { - super.enter(); - } - - @Override - public void leave() { - super.leave(); - } - - @Override - public T leave(T result) { - return super.leave(result); - } - - @Override - public void doWithin(Runnable runnable) { - super.doWithin(runnable); - } - - @Override - public T doWithin(RunnableWithResult runnable) { - return super.doWithin(runnable); - } - - @Override - public Condition makeCondition() { - return super.makeCondition(); - } - - @Override - public Condition makeCondition(Assertion assertion) { - return super.makeCondition(assertion); - } - - @Override - public Condition makeCondition(String name) { - return super.makeCondition(name); - } - - @Override - public Condition makeCondition(String name, Assertion assertion) { - return super.makeCondition(name, assertion); - } } \ No newline at end of file diff --git a/monitor-object/src/main/java/com/iluwatar/monitor/MonitorListener.java b/monitor-object/src/main/java/com/iluwatar/monitor/MonitorListener.java index 120e9bf35..281a4b8b6 100644 --- a/monitor-object/src/main/java/com/iluwatar/monitor/MonitorListener.java +++ b/monitor-object/src/main/java/com/iluwatar/monitor/MonitorListener.java @@ -1,5 +1,30 @@ +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.monitor; +/** + * Interface for Monitor Listener which lists all methods required for a listener to monitor object + */ public interface MonitorListener { void nameThisThread(String name); diff --git a/monitor-object/src/main/java/com/iluwatar/monitor/RunnableWithResult.java b/monitor-object/src/main/java/com/iluwatar/monitor/RunnableWithResult.java index 48b4ea06d..9466fb722 100644 --- a/monitor-object/src/main/java/com/iluwatar/monitor/RunnableWithResult.java +++ b/monitor-object/src/main/java/com/iluwatar/monitor/RunnableWithResult.java @@ -1,5 +1,34 @@ +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.monitor; +/** + * Interface which contains the run method which is executed within the protection of the monitor. + * When the run method returns, if the thread still occupies the monitor, it leaves the monitor. + * Thus the signalAndLeave method may be called within the run method. + * + * @param the expected return value of the run method + */ public interface RunnableWithResult { - public T run(); + T run(); } diff --git a/monitor-object/src/main/java/com/iluwatar/monitor/Semaphore.java b/monitor-object/src/main/java/com/iluwatar/monitor/Semaphore.java index fe45eac11..b17e4152a 100644 --- a/monitor-object/src/main/java/com/iluwatar/monitor/Semaphore.java +++ b/monitor-object/src/main/java/com/iluwatar/monitor/Semaphore.java @@ -1 +1,23 @@ +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.monitor; import java.util.LinkedList; import java.util.ListIterator; /** * A FIFO semaphore. */ public class Semaphore { // Each queue element is a a single use semaphore class QueueElement { final int priority; volatile boolean enabled = false; QueueElement(int priority) { this.priority = priority; } synchronized void acquire() { while (!enabled) { try { wait(); } catch (InterruptedException e) { throw new RuntimeException("Unexpected interruption of " + "thread in monitor.Semaphore.acquire"); } } } synchronized void release() { enabled = true; notify(); } } volatile int s1; final LinkedList queue = new LinkedList(); // Invariant. All elements on the queue are in an unenabled state. /** Initialize the semaphore to a value greater or equal to 0. */ public Semaphore(int initialvalue) { Assertion.check(initialvalue >= 0); this.s1 = initialvalue; } /** * The P operation. If two threads are blocked at the same time, they will be * served in FIFO order. sem.acquire() is equivalent to acquire( * Integer.MAX_VALUE ). */ public void acquire() { acquire(Integer.MAX_VALUE); } /** * The P operation with a priority. * * @param priority * The larger the integer, the less urgent the priority. If two * thread are waiting with equal priority, they will complete acquire * in FIFO order. */ public void acquire(int priority) { QueueElement mine; synchronized (this) { if (s1 > 0) { --s1; return; } mine = new QueueElement(priority); if (priority == Integer.MAX_VALUE) { queue.add(mine); } else { ListIterator it = queue.listIterator(0); int i = 0; while (it.hasNext()) { QueueElement elem = it.next(); if (elem.priority > priority) { break; } ++i; } queue.add(i, mine); } } mine.acquire(); } /** The V operation. */ public synchronized void release() { QueueElement first = queue.poll(); if (first != null) { first.release(); } else { ++s1; } } } \ No newline at end of file diff --git a/monitor-object/src/main/java/com/iluwatar/monitor/TrueAssertion.java b/monitor-object/src/main/java/com/iluwatar/monitor/TrueAssertion.java index 82d6bb0e5..00a1e2422 100644 --- a/monitor-object/src/main/java/com/iluwatar/monitor/TrueAssertion.java +++ b/monitor-object/src/main/java/com/iluwatar/monitor/TrueAssertion.java @@ -1 +1,23 @@ -package com.iluwatar.monitor; /** * An assertion that is always true. */ public class TrueAssertion extends Assertion { public boolean isTrue() { return true; } public static final TrueAssertion singleton = new TrueAssertion(); } \ No newline at end of file +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package com.iluwatar.monitor; /** * An assertion that is always true. */ public class TrueAssertion extends Assertion { public boolean isTrue() { return true; } public static final TrueAssertion SINGLETON = new TrueAssertion(); } \ No newline at end of file diff --git a/monitor-object/src/main/java/com/iluwatar/monitor/examples/Queue.java b/monitor-object/src/main/java/com/iluwatar/monitor/examples/Queue.java index 18ecba2ff..acdbc45a2 100644 --- a/monitor-object/src/main/java/com/iluwatar/monitor/examples/Queue.java +++ b/monitor-object/src/main/java/com/iluwatar/monitor/examples/Queue.java @@ -1,3 +1,25 @@ +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.monitor.examples; import com.iluwatar.monitor.AbstractMonitor; diff --git a/monitor-object/src/main/java/com/iluwatar/monitor/examples/VoteInterface.java b/monitor-object/src/main/java/com/iluwatar/monitor/examples/VoteInterface.java index 54111ea54..bed768034 100644 --- a/monitor-object/src/main/java/com/iluwatar/monitor/examples/VoteInterface.java +++ b/monitor-object/src/main/java/com/iluwatar/monitor/examples/VoteInterface.java @@ -1,3 +1,25 @@ +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.monitor.examples; /** @@ -5,5 +27,5 @@ package com.iluwatar.monitor.examples; */ public interface VoteInterface { - public boolean castVoteAndWaitForResult(boolean vote); + boolean castVoteAndWaitForResult(boolean vote); } \ No newline at end of file diff --git a/monitor-object/src/main/java/com/iluwatar/monitor/examples/VoteMonitor.java b/monitor-object/src/main/java/com/iluwatar/monitor/examples/VoteMonitor.java index a58919e60..d8e888fcb 100644 --- a/monitor-object/src/main/java/com/iluwatar/monitor/examples/VoteMonitor.java +++ b/monitor-object/src/main/java/com/iluwatar/monitor/examples/VoteMonitor.java @@ -1,3 +1,25 @@ +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.monitor.examples; import com.iluwatar.monitor.AbstractMonitor; diff --git a/monitor-object/src/test/java/com/iluwatar/monitor/AssertionTest.java b/monitor-object/src/test/java/com/iluwatar/monitor/AssertionTest.java index 9f6a48372..fb8751d0f 100644 --- a/monitor-object/src/test/java/com/iluwatar/monitor/AssertionTest.java +++ b/monitor-object/src/test/java/com/iluwatar/monitor/AssertionTest.java @@ -1,3 +1,25 @@ +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.monitor; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -28,7 +50,7 @@ public class AssertionTest { @Test public void testAssertionError() { - assertThrows(NullPointerException.class, () -> { + assertThrows(AssertionError.class, () -> { Assertion a = new MyAssertion(); a.check(); varX = 1; diff --git a/monitor-object/src/test/java/com/iluwatar/monitor/ThreadSignalTest.java b/monitor-object/src/test/java/com/iluwatar/monitor/ThreadSignalTest.java index 553f88ac5..15ac519d8 100644 --- a/monitor-object/src/test/java/com/iluwatar/monitor/ThreadSignalTest.java +++ b/monitor-object/src/test/java/com/iluwatar/monitor/ThreadSignalTest.java @@ -1,13 +1,35 @@ +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.monitor; import static org.junit.jupiter.api.Assertions.assertEquals; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; - import com.iluwatar.monitor.examples.VoteInterface; import com.iluwatar.monitor.examples.VoteMonitor; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + /** * Test Case for Thread Signaling. */ @@ -20,7 +42,7 @@ public class ThreadSignalTest { /** * Setup method for Test Case. */ - @BeforeAll + @BeforeEach public void setUp() { VoteInterface vm = new VoteMonitor(3); v0 = new Voter0(vm); diff --git a/monitor-object/src/test/java/com/iluwatar/monitor/Voter.java b/monitor-object/src/test/java/com/iluwatar/monitor/Voter.java index 501405a00..549b906a5 100644 --- a/monitor-object/src/test/java/com/iluwatar/monitor/Voter.java +++ b/monitor-object/src/test/java/com/iluwatar/monitor/Voter.java @@ -1,3 +1,25 @@ +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.monitor; import com.iluwatar.monitor.examples.VoteInterface; diff --git a/monitor-object/src/test/java/com/iluwatar/monitor/Voter0.java b/monitor-object/src/test/java/com/iluwatar/monitor/Voter0.java index 60d2e312b..00332dbd8 100644 --- a/monitor-object/src/test/java/com/iluwatar/monitor/Voter0.java +++ b/monitor-object/src/test/java/com/iluwatar/monitor/Voter0.java @@ -1,3 +1,25 @@ +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.monitor; import com.iluwatar.monitor.examples.VoteInterface; diff --git a/monitor-object/src/test/java/com/iluwatar/monitor/Voter1.java b/monitor-object/src/test/java/com/iluwatar/monitor/Voter1.java index 291e13745..f342e37ac 100644 --- a/monitor-object/src/test/java/com/iluwatar/monitor/Voter1.java +++ b/monitor-object/src/test/java/com/iluwatar/monitor/Voter1.java @@ -1,3 +1,25 @@ +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.monitor; import com.iluwatar.monitor.examples.VoteInterface; diff --git a/monitor-object/src/test/java/com/iluwatar/monitor/Voter2.java b/monitor-object/src/test/java/com/iluwatar/monitor/Voter2.java index c672b693e..8975fc93b 100644 --- a/monitor-object/src/test/java/com/iluwatar/monitor/Voter2.java +++ b/monitor-object/src/test/java/com/iluwatar/monitor/Voter2.java @@ -1,3 +1,25 @@ +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.monitor; import com.iluwatar.monitor.examples.VoteInterface;