public class UserConfigurationManager {
private String userName;
private String password;
private UserConfigurationManager() {
}
public UserConfigurationManager setUserName(String userName) {
this.userName = userName;
return this;
}
public UserConfigurationManager setPassword(String password) {
this.password = password;
return this;
}
public static UserConfigurationManager make(Consumer<UserConfigurationManager> consumer) {
System.out.println("making configuration..........");
UserConfigurationManager configurationManager = new UserConfigurationManager();
consumer.accept(configurationManager);
return configurationManager;
}
}
public class MainApp {
public static void main(String[] args) {
UserConfigurationManager.make(configManager -> configManager.setUserName("lokman").setPassword("12345"));
}
}
Note: Fluent pattern can be used to define Model in JPA
No comments:
Post a Comment