mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-14 22:58:36 +00:00
Java 11 migrate remaining q-r (#1121)
* Moves queue-load-leveling to Java 11 * Moves reactor to Java 11 * Moves reader-writer-lock to Java 11 * Moves repository to Java 11 * Moves resource-acquisition-is-initialization to Java 11 * Moves retry to Java 11 * Moves role-object to Java 11
This commit is contained in:
committed by
Ilkka Seppälä
parent
cd2a2e7711
commit
20ea465b7f
@@ -23,6 +23,7 @@
|
||||
|
||||
package com.iluwatar.roleobject;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
@@ -32,6 +33,7 @@ public abstract class Customer {
|
||||
|
||||
/**
|
||||
* Add specific role @see {@link Role}.
|
||||
*
|
||||
* @param role to add
|
||||
* @return true if the operation has been successful otherwise false
|
||||
*/
|
||||
@@ -39,6 +41,7 @@ public abstract class Customer {
|
||||
|
||||
/**
|
||||
* Check specific role @see {@link Role}.
|
||||
*
|
||||
* @param role to check
|
||||
* @return true if the role exists otherwise false
|
||||
*/
|
||||
@@ -47,6 +50,7 @@ public abstract class Customer {
|
||||
|
||||
/**
|
||||
* Remove specific role @see {@link Role}.
|
||||
*
|
||||
* @param role to remove
|
||||
* @return true if the operation has been successful otherwise false
|
||||
*/
|
||||
@@ -54,6 +58,7 @@ public abstract class Customer {
|
||||
|
||||
/**
|
||||
* 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
|
||||
@@ -67,14 +72,13 @@ public abstract class Customer {
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
var customer = newCustomer();
|
||||
Arrays.stream(role).forEach(customer::addRole);
|
||||
return customer;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user