from Stackoverflow
Hi there,
Compared to HashMap, LinkedHashMap guarantees input order.
In Spring Batch, I think HashMap is enough to save JobParameter, but I don't know why JobParameters used LinkedHashMap. What do you think about this?
Below are some of the implementations of JobParameters. Github Link
public class JobParameters implements Serializable {
private final Map<String,JobParameter> parameters;
public JobParameters() {
this.parameters = new LinkedHashMap<>();
}
public JobParameters(Map<String,JobParameter> parameters) {
this.parameters = new LinkedHashMap<>(parameters);
}
// ...
}
From what I've looked for, LinkedHashMap is more faster than HashMap in some features. ref
Have you decided to use LinkedHashMap simply for the above reasons?
I think, It seems good to use HashMap if ordering is not needed.
Using LinkedHashMap seems to have something to do with the order. It can cause misunderstanding.
What do you think about this?
Thanks.
from Stackoverflow
Hi there,
Compared to
HashMap,LinkedHashMapguarantees input order.In Spring Batch, I think
HashMapis enough to saveJobParameter, but I don't know whyJobParametersusedLinkedHashMap. What do you think about this?Below are some of the implementations of
JobParameters. Github LinkFrom what I've looked for,
LinkedHashMapis more faster thanHashMapin some features. refHave you decided to use
LinkedHashMapsimply for the above reasons?I think, It seems good to use
HashMapif ordering is not needed.Using
LinkedHashMapseems to have something to do with the order. It can cause misunderstanding.What do you think about this?
Thanks.