mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-10-12 14:14:57 +00:00
docs: update monostate
This commit is contained in:
1 parent
36a9eea769
commit
de1dd7f82a
3 files changed
+74
-69
No files matched your search
@@ -25,13 +25,7 @@
|
||||
package com.iluwatar.monostate;
|
||||
|
||||
/**
|
||||
* The Request class. A {@link Server} can handle an instance of a Request.
|
||||
* The Request record. A {@link Server} can handle an instance of a Request.
|
||||
*/
|
||||
|
||||
public class Request {
|
||||
public final String value;
|
||||
|
||||
public Request(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
public record Request(String value) {}
|
||||
@@ -24,6 +24,7 @@
|
||||
*/
|
||||
package com.iluwatar.monostate;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
@@ -31,6 +32,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
* in a simplistic Round Robin fashion.
|
||||
*/
|
||||
@Slf4j
|
||||
@Getter
|
||||
public class Server {
|
||||
|
||||
public final String host;
|
||||
@@ -46,16 +48,8 @@ public class Server {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public void serve(Request request) {
|
||||
LOGGER.info("Server ID {} associated to host : {} and port {}. Processed request with value {}",
|
||||
id, host, port, request.value);
|
||||
id, host, port, request.value());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user