40 lines
875 B
Java
40 lines
875 B
Java
package org.stellar.sdk;
|
|
|
|
import org.stellar.sdk.xdr.MemoType;
|
|
import org.stellar.sdk.xdr.Uint64;
|
|
|
|
/**
|
|
* Represents MEMO_ID.
|
|
*/
|
|
public class MemoId extends Memo {
|
|
private long id;
|
|
|
|
public MemoId(long id) {
|
|
if (Long.compareUnsigned(id, 0) < 0) {
|
|
throw new IllegalArgumentException("id must be a positive number");
|
|
}
|
|
this.id = id;
|
|
}
|
|
|
|
public long getId() {
|
|
return id;
|
|
}
|
|
|
|
@Override
|
|
org.stellar.sdk.xdr.Memo toXdr() {
|
|
org.stellar.sdk.xdr.Memo memo = new org.stellar.sdk.xdr.Memo();
|
|
memo.setDiscriminant(MemoType.MEMO_ID);
|
|
Uint64 idXdr = new Uint64();
|
|
idXdr.setUint64(id);
|
|
memo.setId(idXdr);
|
|
return memo;
|
|
}
|
|
|
|
@Override
|
|
public boolean equals(Object o) {
|
|
if (this == o) return true;
|
|
if (o == null || getClass() != o.getClass()) return false;
|
|
MemoId memoId = (MemoId) o;
|
|
return id == memoId.id;
|
|
}
|
|
}
|