public static <T> Collection<T> collection(Object x) { if (x instanceof Collection) return (Collection<T>) x; return list(x); }
public <T> List<T> getList(String key, List<T> defaultValue) { Object x = get(key); if (x == null) return defaultValue; return Do.list(x); }
/** * Create new revision to be changed, signed sealed and then ready to approve. Created "revision" contract is a copy * of this contract, with all fields and references correctly set. After this call one need to change mutable * fields, add signing keys, seal it and then apss to Universa network for approval. * * @param keys initially added and signer keys. Role "creator" is set to these keys for new revision * @param transactional is {@link Transactional} section to create new revision with * @return new revision of this contract, identical to this one, to be modified. */ public Contract createRevision(Transactional transactional, PrivateKey... keys) { return createRevision(Do.list(keys), transactional); }
/** * Get object as list, or create empty list if it is empty * * @param key * @param <T> * @return list instance, not null. */ public <T> List<T> getOrCreateList(String key) { Object x = get(key); if (x == null) return new ArrayList<>(); return Do.list(x); }
public ArrayList<?> getArray(String key) { Object x = get(key); return x == null ? new ArrayList<>() : Do.list(x); }
@Override public Binder serialize(BiSerializer serializer) { Binder data = new Binder(); data.set("contract", contract.getPackedTransaction()); data.set("createdAt", serializer.serialize(createdAt)); data.set("subscriptions", serializer.serialize(Do.list(subscriptionsSet))); data.set("storages", serializer.serialize(Do.list(storagesSet))); data.set("nameRecords", serializer.serialize(Do.list(nameRecordsSet))); data.set("kvStore", serializer.serialize(kvStore)); return data; }
@Override public Binder serialize(BiSerializer serializer) { Binder data = new Binder(); data.set("name", serializer.serialize(name)); data.set("nameReduced", serializer.serialize(nameReduced)); data.set("description", serializer.serialize(description)); data.set("url", serializer.serialize(url)); data.set("expiresAt", serializer.serialize(expiresAt)); data.set("entries", serializer.serialize(Do.list(entries))); return data; }
refilledSlotContract.setCreator(Do.list(slotIssuerPublicKeys));