Enforce specific Map implementation in Immutables

Viewed 77

I am using Immutables Java library, how can I enforce a specific map implementation, without having to use a specific reference?

@Immutable
public interface ConfigIF {
  Map<String, String> getOptions();
}

If I use the above code the concrete Map is a LinkedHashMap.

@Immutable
public interface ConfigIF {
  TreeMap<String, String> getOptions();
}

If I use the above code both the reference and the implementations are TreeMap.

Is there a way to specify Map as a reference but enforce TreeMap as concrete type?

1 Answers
Related