Rishi
Rishi

Reputation: 151

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);
        }
    });

}

Upvotes: 0

Views: 106

Answers (1)

Murat Karag&#246;z
Murat Karag&#246;z

Reputation: 37604

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

Upvotes: 2

Related Questions