forked from corda/corda
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'private/master' into feature/tudor_cons…
…traints # Conflicts: # core/src/main/kotlin/net/corda/core/transactions/LedgerTransaction.kt # core/src/main/kotlin/net/corda/core/transactions/TransactionBuilder.kt # core/src/main/kotlin/net/corda/core/utilities/KotlinUtils.kt # node/src/test/kotlin/net/corda/node/services/persistence/NodeAttachmentServiceTest.kt
- Loading branch information
Showing
37 changed files
with
1,079 additions
and
268 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
core/src/main/kotlin/net/corda/core/contracts/BelongsToContract.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package net.corda.core.contracts | ||
import kotlin.reflect.KClass | ||
/** | ||
* This annotation is required by any [ContractState] which needs to ensure that it is only ever processed as part of a | ||
* [TransactionState] referencing the specified [Contract]. It may be omitted in the case that the [ContractState] class | ||
* is defined as an inner class of its owning [Contract] class, in which case the "X belongs to Y" relationship is taken | ||
* to be implicitly declared. | ||
* | ||
* During verification of transactions, prior to their being written into the ledger, all input and output states are | ||
* checked to ensure that their [ContractState]s match with their [Contract]s as specified either by this annotation, or | ||
* by their inner/outer class relationship. | ||
* | ||
* The transaction will write a warning to the log if any mismatch is detected. | ||
* | ||
* @param value The class of the [Contract] to which states of the annotated [ContractState] belong. | ||
*/ | ||
@Retention(AnnotationRetention.RUNTIME) | ||
@Target(AnnotationTarget.CLASS) | ||
annotation class BelongsToContract(val value: KClass<out Contract>) | ||
/** | ||
* Obtain the typename of the required [ContractClass] associated with the target [ContractState], using the | ||
* [BelongsToContract] annotation by default, but falling through to checking the state's enclosing class if there is | ||
* one and it inherits from [Contract]. | ||
*/ | ||
val ContractState.requiredContractClassName: String? get() { | ||
val annotation = javaClass.getAnnotation(BelongsToContract::class.java) | ||
if (annotation != null) { | ||
return annotation.value.java.typeName | ||
} | ||
val enclosingClass = javaClass.enclosingClass ?: return null | ||
return if (Contract::class.java.isAssignableFrom(enclosingClass)) enclosingClass.typeName else null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.