001package org.consensusj.analytics.service; 002 003import org.bitcoinj.base.Address; 004import org.bitcoinj.base.Sha256Hash; 005 006import java.util.ArrayList; 007import java.util.Collections; 008import java.util.List; 009 010/** 011 * Response format for Omni rich list queries. 012 * 013 * TODO: Jackson annotations? 014 */ 015public class TokenRichList<N extends Number & Comparable<? super N>, ID> { 016 private final int blockHeight; 017 private final Sha256Hash blockHash; 018 private final long timestamp; 019 private final ID currencyID; 020 private final List<TokenBalancePair<N>> richList; 021 private final N otherBalanceTotal; 022 023 public TokenRichList(int blockHeight, 024 Sha256Hash blockHash, 025 long timestamp, 026 ID currencyID, 027 List<TokenBalancePair<N>> richList, 028 N otherBalanceTotal) { 029 this.blockHeight = blockHeight; 030 this.blockHash = blockHash; 031 this.timestamp = timestamp; 032 this.currencyID = currencyID; 033 this.richList = Collections.unmodifiableList(new ArrayList<>(richList)); 034 this.otherBalanceTotal = otherBalanceTotal; 035 } 036 037 public static class TokenBalancePair<N extends Number & Comparable<? super N>> { 038 private final Address address; 039 private final N balance; 040 041 public TokenBalancePair(Address address, N balance) { 042 this.address = address; 043 this.balance = balance; 044 } 045 046 public Address getAddress() { 047 return address; 048 } 049 050 public N getBalance() { 051 return balance; 052 } 053 } 054 055 public int getBlockHeight() { 056 return blockHeight; 057 } 058 059 public Sha256Hash getBlockHash() { 060 return blockHash; 061 } 062 063 public long getTimestamp() { 064 return timestamp; 065 } 066 067 public ID getCurrencyID() { 068 return currencyID; 069 } 070 071 public List<TokenBalancePair<N>> getRichList() { 072 return richList; 073 } 074 075 public N getOtherBalanceTotal() { 076 return otherBalanceTotal; 077 } 078}