java - The method getOrDefault(String, String) is undefined for the type Map<String,String> -
in following code error @ return of namespacemap. don't know why. getordefault methode should defined in hashmap.class. tried create namespacemapper described in linked example https://www.intertech.com/blog/jaxb-tutorial-customized-namespace-prefixes-example-using-namespaceprefixmapper/
import java.util.hashmap; import java.util.map; import com.sun.xml.bind.marshaller.namespaceprefixmapper; public class fimsnamespaceprefixmapper extends namespaceprefixmapper { private map<string, string> namespacemap = new hashmap<>(); public fimsnamespaceprefixmapper() { namespacemap.put("http://base.fims.tv", "bms"); namespacemap.put("http://transformmedia.fims.tv", "tms"); } @override public string getpreferredprefix(string arg0, string arg1, boolean arg2) { return namespacemap.getordefault(arg0, arg1); }}
the getordefault
method introduced in java 8. check runtime version of java using running java -version
. if using lower java 8 (1.8), upgrade , code should work.
Comments
Post a Comment