简体   繁体   中英

What is the significance of HashMap<String,Object>.toMap

I am developing an Android App and I am stuck with something. I am using Loopback as my backend framework, in which I have to pass a hashMap, but Android Studio is showing me error that I should convert it into toMap . Below is my piece of code, I have google but doesn't find the solution of Why should we have to use toMap .

HashMap<String,Object>vehicleInfoObj = new HashMap<>();

customerQuoteRepository.createCustomerQuote(ctx, vehicleInfo.toMap(), customerQuote.toMap(), new ObjectCallback<CustomerQuote>() {
        @Override
        public void onBefore() {
            super.onBefore();
            mainActivity.startProgressBar(mainActivity.progressBar);
        }

        @Override
        public void onSuccess(CustomerQuote object) {
            super.onSuccess(object);

        }


        @Override
        public void onError(Throwable t) {
            super.onError(t);
        }

        @Override
        public void onFinally() {
            super.onFinally();
            mainActivity.startProgressBar(mainActivity.progressBar);
        }
    });

}

There is no toMap() method in the Java Map API. But there is one in the loopback-sdk eg here . The signature of createCustomerQuote expects a Map<String, ? extends Object> Map<String, ? extends Object> - that's why you have to use toMap() .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM