Kotlin vs Java
private String value;
public synchronized String getValue() {
if (value == null) {
value = "Something";
}
return value;
}
val lazyValue: String by lazy {
"Something"
}
final ObjectMapper mapper = new ObjectMapper(); // jackson's objectmapper
final MyPojo pojo = mapper.convertValue(map, MyPojo.class);
// https://stackoverflow.com/a/16430704/2441104
class User(val map: Map<String, Any?>) {
val name: String by map
val age: Int by map
}
public class PCLNewsAgency {
private String news;
private PropertyChangeSupport support;
public PCLNewsAgency() {
support = new PropertyChangeSupport(this);
}
public void addPropertyChangeListener(PropertyChangeListener pcl) {
support.addPropertyChangeListener(pcl);
}
public void removePropertyChangeListener(PropertyChangeListener pcl) {
support.removePropertyChangeListener(pcl);
}
public void setNews(String value) {
support.firePropertyChange("news", this.news, value);
this.news = value;
}
}
class User {
var name: String by Delegates.observable("") {
prop, old, new ->
println("$old -> $new")
}
}