mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-16 04:58:46 +00:00
#1021 enforce Checkstyle rules in the build
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.roleobject;
|
||||
|
||||
import java.util.Optional;
|
||||
@@ -29,51 +30,52 @@ import java.util.Optional;
|
||||
*/
|
||||
public abstract class Customer {
|
||||
|
||||
/**
|
||||
* Add specific role @see {@link Role}
|
||||
*
|
||||
* @param role to add
|
||||
* @return true if the operation has been successful otherwise false
|
||||
*/
|
||||
public abstract boolean addRole(Role role);
|
||||
/**
|
||||
* Add specific role @see {@link Role}.
|
||||
* @param role to add
|
||||
* @return true if the operation has been successful otherwise false
|
||||
*/
|
||||
public abstract boolean addRole(Role role);
|
||||
|
||||
/**
|
||||
* Check specific role @see {@link Role}
|
||||
*
|
||||
* @param role to check
|
||||
* @return true if the role exists otherwise false
|
||||
*/
|
||||
/**
|
||||
* Check specific role @see {@link Role}.
|
||||
* @param role to check
|
||||
* @return true if the role exists otherwise false
|
||||
*/
|
||||
|
||||
public abstract boolean hasRole(Role role);
|
||||
public abstract boolean hasRole(Role role);
|
||||
|
||||
/**
|
||||
* Remove specific role @see {@link Role}
|
||||
*
|
||||
* @param role to remove
|
||||
* @return true if the operation has been successful otherwise false
|
||||
*/
|
||||
public abstract boolean remRole(Role role);
|
||||
/**
|
||||
* Remove specific role @see {@link Role}.
|
||||
* @param role to remove
|
||||
* @return true if the operation has been successful otherwise false
|
||||
*/
|
||||
public abstract boolean remRole(Role role);
|
||||
|
||||
/**
|
||||
* Get specific instance associated with this role @see {@link Role}
|
||||
*
|
||||
* @param role to get
|
||||
* @param expectedRole instance class expected to get
|
||||
* @return optional with value if the instance exists and corresponds expected class
|
||||
*/
|
||||
public abstract <T extends Customer> Optional<T> getRole(Role role, Class<T> expectedRole);
|
||||
/**
|
||||
* Get specific instance associated with this role @see {@link Role}.
|
||||
* @param role to get
|
||||
* @param expectedRole instance class expected to get
|
||||
* @return optional with value if the instance exists and corresponds expected class
|
||||
*/
|
||||
public abstract <T extends Customer> Optional<T> getRole(Role role, Class<T> expectedRole);
|
||||
|
||||
|
||||
public static Customer newCustomer() {
|
||||
return new CustomerCore();
|
||||
}
|
||||
|
||||
public static Customer newCustomer(Role... role) {
|
||||
Customer customer = newCustomer();
|
||||
for (Role r : role) {
|
||||
customer.addRole(r);
|
||||
}
|
||||
return customer;
|
||||
public static Customer newCustomer() {
|
||||
return new CustomerCore();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create {@link Customer} with given roles.
|
||||
* @param role roles
|
||||
* @return Customer
|
||||
*/
|
||||
public static Customer newCustomer(Role... role) {
|
||||
Customer customer = newCustomer();
|
||||
for (Role r : role) {
|
||||
customer.addRole(r);
|
||||
}
|
||||
return customer;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user