Skip to content
This repository has been archived by the owner on Jul 23, 2022. It is now read-only.

IllegalStateException: Missing required properties #53

Closed
ghost opened this issue Jul 16, 2018 · 2 comments
Closed

IllegalStateException: Missing required properties #53

ghost opened this issue Jul 16, 2018 · 2 comments

Comments

@ghost
Copy link

ghost commented Jul 16, 2018

Below is my code, kindly provide support to resolve this issue.

@AutoValue
public abstract class PaymentHistoryViewModelNew implements Parcelable {

    public abstract String paidAmount();

    public abstract String numberOfPayments();

    public abstract List<PaymentItemViewModelNew> paymentViewModels();


    public static Builder builder() {
        return new AutoValue_PaymentHistoryViewModelNew.Builder();
    }

    public static PaymentHistoryViewModelNew from(PaymentHistoryResponse paymentHistoryResponse, String paidAmount) {
        List<PaymentItemViewModelNew> list = new ArrayList<>();

        if (paymentHistoryResponse.payments != null) {
            Collections.sort(paymentHistoryResponse.payments, new Comparator<Payment>() {
                @Override
                public int compare(Payment thisPayment, Payment otherPayment) {
                    Date thisPaymentDate = DateHelper.parseDate(thisPayment.date, DateHelper.DATE_API_FORMAT);
                    Date otherPaymentDate = DateHelper.parseDate(otherPayment.date, DateHelper.DATE_API_FORMAT);
                    if (thisPaymentDate != null && otherPaymentDate != null) {
                        return otherPaymentDate.compareTo(thisPaymentDate);
                    }
                    return 0;
                }
            });

            for (Payment payment : paymentHistoryResponse.payments) {
                list.add(PaymentItemViewModelNew.builder().build().from(payment));
            }
        }

        return builder()
                .numberOfPayments(NumberUtils.formatTimes(list.size()))
                .paidAmount(paidAmount)
                .paymentViewModels(list)
                .build();
    }

    @AutoValue.Builder
    public abstract static class Builder {
        public abstract Builder paidAmount(String amount);

        public abstract Builder numberOfPayments(String amount);

        public abstract Builder paymentViewModels(List<PaymentItemViewModelNew> list);

        public abstract PaymentHistoryViewModelNew build();
    }
}
@gabrielittner
Copy link
Owner

Can you post the full stacktrace?

@gabrielittner
Copy link
Owner

Closing until there is more information.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant