12345678910111213141516171819202122232425262728293031323334353637 |
- package observerPattern.observer.impl;
- import observerPattern.observer.Observer;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- public class User implements Observer {
- private static final Logger log = LoggerFactory.getLogger(User.class);
- String name;
- Integer age;
- public User(String name, Integer age) {
- this.name = name;
- this.age = age;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public Integer getAge() {
- return age;
- }
- public void setAge(Integer age) {
- this.age = age;
- }
- @Override
- public void update(String message) {
- log.info("{}收到了消息: {}", name, message);
- }
- }
|