T - The class of the data.public class Block<T extends Serializable> extends Object implements Iterable<Block<T>>, Comparable<Block<T>>, Serializable
| Constructor and Description |
|---|
Block(T data)
Create the first block of the chain.
|
Block(T data,
Block<T> previous)
Create a new block in the chain.
|
| Modifier and Type | Method and Description |
|---|---|
static <T extends Serializable> |
compare(Block<T> firstChain,
Block<T> secondChain)
Compare two blocks and return the best one.
|
int |
compareTo(Block<T> o) |
boolean |
equals(Object obj) |
T |
getData()
Return the data contained in the block.
|
Block<T> |
getPrevious()
Return the previous block in the chain.
|
int |
hashCode() |
boolean |
isValid()
Check if the block is valid
|
boolean |
isWholeChainValid()
Check if the whole chain is valid
|
Iterator<Block<T>> |
iterator() |
java.util.stream.Stream<Block<T>> |
stream()
Returns a sequential Stream with this blockchain as its source.
|
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitforEach, spliteratorpublic Block(T data)
data - The data contained in the block.public T getData()
public Block<T> getPrevious()
public boolean isValid()
public java.util.stream.Stream<Block<T>> stream()
public boolean isWholeChainValid()
public Iterator<Block<T>> iterator()
iterator in interface Iterable<Block<T extends Serializable>>public int compareTo(Block<T> o)
compareTo in interface Comparable<Block<T extends Serializable>>public static <T extends Serializable> int compare(Block<T> firstChain, Block<T> secondChain)
firstChain - the first blockchain to comparesecondChain - the second blockchain to compareCopyright © 2017. All rights reserved.