allowing ticket (non-fungible) objects to be created parsed, instead of requiring a parsing after the object is created
parent
b7e7ad755c
commit
f2da5be6fe
@ -1,11 +1,50 @@ |
||||
package io.awallet.crypto.alphawallet.repository.entity; |
||||
|
||||
import java.math.BigInteger; |
||||
import java.util.HashMap; |
||||
|
||||
import io.awallet.crypto.alphawallet.repository.AssetDefinition; |
||||
|
||||
/** |
||||
* Created by weiwu on 1/3/18. |
||||
* Created by weiwu on 1/3/18. Each NonFungibleToken is a |
||||
* non-fungible token identified by a byte32 tokenID (other forms of |
||||
* IDs may be added if tests proves that they can be more efficient). |
||||
*/ |
||||
|
||||
public interface NonFungibleToken { |
||||
void setField(String id, String name, String value); |
||||
String getFieldText(String id); |
||||
String getFieldName(String id); |
||||
public class NonFungibleToken { |
||||
public BigInteger id; |
||||
|
||||
public static final class Attribute { |
||||
public final String id; |
||||
public String name; |
||||
public String text; |
||||
public final BigInteger value; |
||||
public Attribute(String attributeId, String name, BigInteger value, String text) { |
||||
this.id = attributeId; |
||||
this.name = name; |
||||
this.text = text; |
||||
this.value = value; |
||||
} |
||||
} |
||||
|
||||
protected HashMap<String, Attribute> attributes; |
||||
|
||||
public Attribute getAttribute(String attributeId) { |
||||
return attributes.get(attributeId); |
||||
} |
||||
|
||||
public void setAttribute(String attributeId, Attribute attribute) { |
||||
attributes.put(attributeId, attribute); |
||||
} |
||||
|
||||
public NonFungibleToken(BigInteger tokenId, AssetDefinition ad){ |
||||
this(tokenId); |
||||
ad.parseField(tokenId, this); |
||||
} |
||||
|
||||
public NonFungibleToken(BigInteger tokenId) { |
||||
id = tokenId; |
||||
attributes = new HashMap(); |
||||
} |
||||
|
||||
} |
||||
|
Loading…
Reference in new issue