java.lang.Object
java.lang.Record
tech.deplant.java4ever.framework.OnchainConfig
public record OnchainConfig(Artifact<String,String> artifact, OnchainConfig.OnchainInfo info)
extends Record
The type Onchain config.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordThe type Onchain info.static final recordThe type Saved contract. -
Constructor Summary
ConstructorsConstructorDescriptionOnchainConfig(Artifact<String, String> artifact, OnchainConfig.OnchainInfo info) Creates an instance of aOnchainConfigrecord class. -
Method Summary
Modifier and TypeMethodDescriptionaddContract(String name, Contract contract) Adds OwnedContract object to config with a given name as a key.addKeys(String name, Credentials keys) Add keys credentials.artifact()Returns the value of theartifactrecord component.<T extends AbstractContract>
TContract t.<T extends AbstractContract>
TContract t.static OnchainConfigEmpty onchain config.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.info()Returns the value of theinforecord component.Keys credentials.static OnchainConfigLoad onchain config.static OnchainConfigLOAD_IF_EXISTS(String serializationPath) Load if exists onchain config.voidsync()Flushes this config to file on serializationPath()final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
OnchainConfig
Creates an instance of aOnchainConfigrecord class.- Parameters:
artifact- the value for theartifactrecord componentinfo- the value for theinforecord component
-
-
Method Details
-
LOAD_IF_EXISTS
Load if exists onchain config.- Parameters:
serializationPath- the serialization path- Returns:
- the onchain config
- Throws:
IOException- the io exception
-
EMPTY
Empty onchain config.- Parameters:
serializationPath- the serialization path- Returns:
- the onchain config
- Throws:
IOException- the io exception
-
LOAD
public static OnchainConfig LOAD(String serializationPath) throws com.fasterxml.jackson.core.JsonProcessingException Load onchain config.- Parameters:
serializationPath- the serialization path- Returns:
- the onchain config
- Throws:
com.fasterxml.jackson.core.JsonProcessingException- the json processing exception
-
keys
Keys credentials.- Parameters:
keysName- the keys name- Returns:
- the credentials
-
contract
public <T extends AbstractContract> T contract(Class<T> clazz, int contextId, String contractName, String keysName) throws com.fasterxml.jackson.core.JsonProcessingException Contract t.- Type Parameters:
T- the type parameter- Parameters:
clazz- the clazzcontextId- the context idcontractName- the contract namekeysName- the keys name- Returns:
- the t
- Throws:
com.fasterxml.jackson.core.JsonProcessingException- the json processing exception
-
contract
public <T extends AbstractContract> T contract(Class<T> clazz, int contextId, String contractName) throws com.fasterxml.jackson.core.JsonProcessingException Contract t.- Type Parameters:
T- the type parameter- Parameters:
clazz- the clazzcontextId- the context idcontractName- the contract name- Returns:
- the t
- Throws:
com.fasterxml.jackson.core.JsonProcessingException- the json processing exception
-
addContract
Adds OwnedContract object to config with a given name as a key.- Parameters:
name- key for finding contract in config latercontract- contract object- Returns:
- OwnedContract that we successfully putted to config
- Throws:
IOException- can be thrown by the call of sync() method
-
addKeys
Add keys credentials.- Parameters:
name- the namekeys- the keys- Returns:
- the credentials
- Throws:
IOException- the io exception
-
sync
Flushes this config to file on serializationPath()- Throws:
IOException- can be thrown by work with File
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
artifact
-
info
Returns the value of theinforecord component.- Returns:
- the value of the
inforecord component
-