mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-15 06:58:41 +00:00
* Added Lockable-Object pattern. Closes #1282. * Refactor method name. * Refactor sonar lint bugs. * Added tests and enum Constants. * Increase coverage. * Changed @Data to Getters and Setters. * Iluwatar's comment on pull request #1702. * Fixed codes mells. * Incremented wait time to 3 seconds. * Reduced wait time to 2 seconds. * Cleaned Code Smells. * Incremented wait time, removed cool down. * Refactored README.md file. Co-authored-by: Subhrodip Mohanta <subhrodipmohanta@gmail.com>
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
package com.iluwatar.lockableobject;
|
||||
|
||||
import com.iluwatar.lockableobject.domain.Creature;
|
||||
|
||||
/** This interface describes the methods to be supported by a lockable-object. */
|
||||
public interface Lockable {
|
||||
|
||||
/**
|
||||
* Checks if the object is locked.
|
||||
*
|
||||
* @return true if it is locked.
|
||||
*/
|
||||
boolean isLocked();
|
||||
|
||||
/**
|
||||
* locks the object with the creature as the locker.
|
||||
*
|
||||
* @param creature as the locker.
|
||||
* @return true if the object was locked successfully.
|
||||
*/
|
||||
boolean lock(Creature creature);
|
||||
|
||||
/**
|
||||
* Unlocks the object.
|
||||
*
|
||||
* @param creature as the locker.
|
||||
*/
|
||||
void unlock(Creature creature);
|
||||
|
||||
/**
|
||||
* Gets the locker.
|
||||
*
|
||||
* @return the Creature that holds the object. Returns null if no one is locking.
|
||||
*/
|
||||
Creature getLocker();
|
||||
|
||||
/**
|
||||
* Returns the name of the object.
|
||||
*
|
||||
* @return the name of the object.
|
||||
*/
|
||||
String getName();
|
||||
}
|
||||
Reference in New Issue
Block a user