diff --git a/packages/@scope/jsii-calc-lib/lib/duplicate-inherited-prop.ts b/packages/@scope/jsii-calc-lib/lib/duplicate-inherited-prop.ts new file mode 100644 index 0000000000..f7107bf5d4 --- /dev/null +++ b/packages/@scope/jsii-calc-lib/lib/duplicate-inherited-prop.ts @@ -0,0 +1,19 @@ +// This is half of the contraption, the rest is in jsii-calc +// +// @see https://github.com/aws/jsii/issues/2256 + +/** + * This struct is intentionally private. Any type that implements it will get + * a copy of it's properties hoisted in by jsii. + */ +interface InternalDiamondTip { + readonly hoistedTop?: string; +} + +export interface DiamondLeft extends InternalDiamondTip { + readonly left?: number; +} + +export interface DiamondRight extends InternalDiamondTip { + readonly right?: boolean; +} diff --git a/packages/@scope/jsii-calc-lib/lib/index.ts b/packages/@scope/jsii-calc-lib/lib/index.ts index b4268904dd..7ffa4c17bd 100644 --- a/packages/@scope/jsii-calc-lib/lib/index.ts +++ b/packages/@scope/jsii-calc-lib/lib/index.ts @@ -110,3 +110,4 @@ export interface IThreeLevelsInterface extends base.IBaseInterface { } export * as submodule from './submodule'; +export * from './duplicate-inherited-prop'; diff --git a/packages/@scope/jsii-calc-lib/test/assembly.jsii b/packages/@scope/jsii-calc-lib/test/assembly.jsii index 87898e58f2..bb45ca914f 100644 --- a/packages/@scope/jsii-calc-lib/test/assembly.jsii +++ b/packages/@scope/jsii-calc-lib/test/assembly.jsii @@ -133,6 +133,102 @@ } }, "types": { + "@scope/jsii-calc-lib.DiamondLeft": { + "assembly": "@scope/jsii-calc-lib", + "datatype": true, + "docs": { + "stability": "deprecated" + }, + "fqn": "@scope/jsii-calc-lib.DiamondLeft", + "kind": "interface", + "locationInModule": { + "filename": "lib/duplicate-inherited-prop.ts", + "line": 13 + }, + "name": "DiamondLeft", + "properties": [ + { + "abstract": true, + "docs": { + "stability": "deprecated" + }, + "immutable": true, + "locationInModule": { + "filename": "lib/duplicate-inherited-prop.ts", + "line": 10 + }, + "name": "hoistedTop", + "optional": true, + "type": { + "primitive": "string" + } + }, + { + "abstract": true, + "docs": { + "stability": "deprecated" + }, + "immutable": true, + "locationInModule": { + "filename": "lib/duplicate-inherited-prop.ts", + "line": 14 + }, + "name": "left", + "optional": true, + "type": { + "primitive": "number" + } + } + ] + }, + "@scope/jsii-calc-lib.DiamondRight": { + "assembly": "@scope/jsii-calc-lib", + "datatype": true, + "docs": { + "stability": "deprecated" + }, + "fqn": "@scope/jsii-calc-lib.DiamondRight", + "kind": "interface", + "locationInModule": { + "filename": "lib/duplicate-inherited-prop.ts", + "line": 17 + }, + "name": "DiamondRight", + "properties": [ + { + "abstract": true, + "docs": { + "stability": "deprecated" + }, + "immutable": true, + "locationInModule": { + "filename": "lib/duplicate-inherited-prop.ts", + "line": 10 + }, + "name": "hoistedTop", + "optional": true, + "type": { + "primitive": "string" + } + }, + { + "abstract": true, + "docs": { + "stability": "deprecated" + }, + "immutable": true, + "locationInModule": { + "filename": "lib/duplicate-inherited-prop.ts", + "line": 18 + }, + "name": "right", + "optional": true, + "type": { + "primitive": "boolean" + } + } + ] + }, "@scope/jsii-calc-lib.EnumFromScopedModule": { "assembly": "@scope/jsii-calc-lib", "docs": { @@ -776,5 +872,5 @@ } }, "version": "0.0.0", - "fingerprint": "7STgxc8/b+pajng4R4fEptbcOF2aQJBiQkO4bMAWpI4=" + "fingerprint": "YlmxPtOusVTgKe2YUzZDpB4UnmnU3zZ0UUdXwSDcgOo=" } diff --git a/packages/jsii-calc/lib/duplicate-inherited-prop.ts b/packages/jsii-calc/lib/duplicate-inherited-prop.ts new file mode 100644 index 0000000000..eaa048ed8f --- /dev/null +++ b/packages/jsii-calc/lib/duplicate-inherited-prop.ts @@ -0,0 +1,9 @@ +import { DiamondLeft, DiamondRight } from '@scope/jsii-calc-lib'; + +// This is half of the contraption, the rest is in @scope/jsii-calc-lib. +// +// @see https://github.com/aws/jsii/issues/2256 + +export interface DiamondBottom extends DiamondLeft, DiamondRight { + readonly bottom?: Date; +} diff --git a/packages/jsii-calc/lib/index.ts b/packages/jsii-calc/lib/index.ts index ea90d06d22..a167c46687 100644 --- a/packages/jsii-calc/lib/index.ts +++ b/packages/jsii-calc/lib/index.ts @@ -2,6 +2,7 @@ export * from './calculator'; export * from './compliance'; export * from './date'; export * from './documented'; +export * from './duplicate-inherited-prop'; export * from './erasures'; export * from './nested-class'; export * from './stability'; diff --git a/packages/jsii-calc/test/assembly.jsii b/packages/jsii-calc/test/assembly.jsii index 59bb5b1e7f..1a10a78b12 100644 --- a/packages/jsii-calc/test/assembly.jsii +++ b/packages/jsii-calc/test/assembly.jsii @@ -209,7 +209,7 @@ "jsii-calc.submodule": { "locationInModule": { "filename": "lib/index.ts", - "line": 10 + "line": 11 }, "readme": { "markdown": "Read you, read me\n=================\n\nThis is the readme of the `jsii-calc.submodule` module.\n" @@ -3821,6 +3821,42 @@ } ] }, + "jsii-calc.DiamondBottom": { + "assembly": "jsii-calc", + "datatype": true, + "docs": { + "stability": "stable" + }, + "fqn": "jsii-calc.DiamondBottom", + "interfaces": [ + "@scope/jsii-calc-lib.DiamondLeft", + "@scope/jsii-calc-lib.DiamondRight" + ], + "kind": "interface", + "locationInModule": { + "filename": "lib/duplicate-inherited-prop.ts", + "line": 7 + }, + "name": "DiamondBottom", + "properties": [ + { + "abstract": true, + "docs": { + "stability": "stable" + }, + "immutable": true, + "locationInModule": { + "filename": "lib/duplicate-inherited-prop.ts", + "line": 8 + }, + "name": "bottom", + "optional": true, + "type": { + "primitive": "date" + } + } + ] + }, "jsii-calc.DiamondInheritanceBaseLevelStruct": { "assembly": "jsii-calc", "datatype": true, @@ -14441,5 +14477,5 @@ } }, "version": "3.20.120", - "fingerprint": "DELAKIDgUwCEVXhZflQBdllcDRnscledlYW0UXrjzbM=" + "fingerprint": "DPUvV1cBxUeRNl5GK1DVzpU7/802/Hb8znpxKRttRUk=" } diff --git a/packages/jsii-pacmak/lib/targets/java.ts b/packages/jsii-pacmak/lib/targets/java.ts index 78185e5de3..80e64f9f90 100644 --- a/packages/jsii-pacmak/lib/targets/java.ts +++ b/packages/jsii-pacmak/lib/targets/java.ts @@ -833,6 +833,8 @@ class JavaGenerator extends Generator { } protected onEndInterface(ifc: spec.InterfaceType) { + this.emitMultiplyInheritedOptionalProperties(ifc); + if (ifc.datatype) { this.emitDataType(ifc); } else { @@ -883,6 +885,9 @@ class JavaGenerator extends Generator { this.addJavaDocs(prop); this.emitStabilityAnnotations(prop); if (prop.optional) { + if (prop.overrides) { + this.code.line('@Override'); + } this.code.openBlock(`default ${getterType} get${propName}()`); this.code.line('return null;'); this.code.closeBlock(); @@ -896,6 +901,9 @@ class JavaGenerator extends Generator { this.code.line(); this.addJavaDocs(prop); if (prop.optional) { + if (prop.overrides) { + this.code.line('@Override'); + } this.code.line('@software.amazon.jsii.Optional'); this.code.openBlock( `default void set${propName}(final ${type} value)`, @@ -911,6 +919,61 @@ class JavaGenerator extends Generator { } } + /** + * Emits a local default implementation for optional properties inherited from + * multiple distinct parent types. This remvoes the default method dispatch + * ambiguity that would otherwise exist. + * + * @param ifc the interface to be processed. + + * + * @see https://github.com/aws/jsii/issues/2256 + */ + private emitMultiplyInheritedOptionalProperties(ifc: spec.InterfaceType) { + if (ifc.interfaces == null || ifc.interfaces.length <= 1) { + // Nothing to do if we don't have parent interfaces, or if we have exactly one + return; + } + const inheritedOptionalProps = ifc.interfaces + .map(allOptionalProps.bind(this)) + // Calculate how many direct parents brought a given optional property + .reduce((histogram, entry) => { + for (const [name, spec] of Object.entries(entry)) { + histogram[name] = histogram[name] ?? { spec, count: 0 }; + histogram[name].count += 1; + } + return histogram; + }, {} as Record); + + const localProps = new Set(ifc.properties?.map((prop) => prop.name) ?? []); + for (const { spec, count } of Object.values(inheritedOptionalProps)) { + if (count < 2 || localProps.has(spec.name)) { + continue; + } + this.onInterfaceProperty(ifc, spec); + } + + function allOptionalProps(this: JavaGenerator, fqn: string) { + const type = this.findType(fqn) as spec.InterfaceType; + const result: Record = {}; + for (const prop of type.properties ?? []) { + // Adding artifical "overrides" here for code-gen quality's sake. + result[prop.name] = { ...prop, overrides: type.fqn }; + } + // Include optional properties of all super interfaces in the result + for (const base of type.interfaces ?? []) { + for (const [name, prop] of Object.entries( + allOptionalProps.call(this, base), + )) { + if (!(name in result)) { + result[name] = prop; + } + } + } + return result; + } + } + private emitPackageInfo(mod: spec.Assembly) { if (!mod.docs) { return; diff --git a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-dotnet.test.ts.snap b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-dotnet.test.ts.snap index 3a20c9ef13..f1edad3773 100644 --- a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-dotnet.test.ts.snap +++ b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-dotnet.test.ts.snap @@ -547,7 +547,11 @@ exports[`Generated code for "@scope/jsii-calc-lib": / 1`] = ` ┃ ┗━ 📁 Tests ┃ ┣━ 📁 CalculatorNamespace ┃ ┃ ┗━ 📁 LibNamespace + ┃ ┃ ┣━ 📄 DiamondLeft.cs + ┃ ┃ ┣━ 📄 DiamondRight.cs ┃ ┃ ┣━ 📄 EnumFromScopedModule.cs + ┃ ┃ ┣━ 📄 IDiamondLeft.cs + ┃ ┃ ┣━ 📄 IDiamondRight.cs ┃ ┃ ┣━ 📄 IDoublable.cs ┃ ┃ ┣━ 📄 IFriendly.cs ┃ ┃ ┣━ 📄 IMyFirstStruct.cs @@ -613,6 +617,88 @@ exports[`Generated code for "@scope/jsii-calc-lib": /dotnet/Amazon.JSII. +`; + +exports[`Generated code for "@scope/jsii-calc-lib": /dotnet/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId/Amazon/JSII/Tests/CalculatorNamespace/LibNamespace/DiamondLeft.cs 1`] = ` +using Amazon.JSII.Runtime.Deputy; + +#pragma warning disable CS0672,CS0809,CS1591 + +namespace Amazon.JSII.Tests.CalculatorNamespace.LibNamespace +{ + /// + /// Stability: Deprecated + /// + [JsiiByValue(fqn: "@scope/jsii-calc-lib.DiamondLeft")] + public class DiamondLeft : Amazon.JSII.Tests.CalculatorNamespace.LibNamespace.IDiamondLeft + { + /// + /// Stability: Deprecated + /// + [JsiiOptional] + [JsiiProperty(name: "hoistedTop", typeJson: "{\\"primitive\\":\\"string\\"}", isOptional: true, isOverride: true)] + [System.Obsolete()] + public string? HoistedTop + { + get; + set; + } + + /// + /// Stability: Deprecated + /// + [JsiiOptional] + [JsiiProperty(name: "left", typeJson: "{\\"primitive\\":\\"number\\"}", isOptional: true, isOverride: true)] + [System.Obsolete()] + public double? Left + { + get; + set; + } + } +} + +`; + +exports[`Generated code for "@scope/jsii-calc-lib": /dotnet/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId/Amazon/JSII/Tests/CalculatorNamespace/LibNamespace/DiamondRight.cs 1`] = ` +using Amazon.JSII.Runtime.Deputy; + +#pragma warning disable CS0672,CS0809,CS1591 + +namespace Amazon.JSII.Tests.CalculatorNamespace.LibNamespace +{ + /// + /// Stability: Deprecated + /// + [JsiiByValue(fqn: "@scope/jsii-calc-lib.DiamondRight")] + public class DiamondRight : Amazon.JSII.Tests.CalculatorNamespace.LibNamespace.IDiamondRight + { + /// + /// Stability: Deprecated + /// + [JsiiOptional] + [JsiiProperty(name: "hoistedTop", typeJson: "{\\"primitive\\":\\"string\\"}", isOptional: true, isOverride: true)] + [System.Obsolete()] + public string? HoistedTop + { + get; + set; + } + + /// + /// Stability: Deprecated + /// + [JsiiOptional] + [JsiiProperty(name: "right", typeJson: "{\\"primitive\\":\\"boolean\\"}", isOptional: true, isOverride: true)] + [System.Obsolete()] + public bool? Right + { + get; + set; + } + } +} + `; exports[`Generated code for "@scope/jsii-calc-lib": /dotnet/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId/Amazon/JSII/Tests/CalculatorNamespace/LibNamespace/EnumFromScopedModule.cs 1`] = ` @@ -622,6 +708,7 @@ using Amazon.JSII.Runtime.Deputy; namespace Amazon.JSII.Tests.CalculatorNamespace.LibNamespace { + /// (deprecated) Check that enums from \\@scoped packages can be references. /// /// See awslabs/jsii#138 @@ -649,6 +736,166 @@ namespace Amazon.JSII.Tests.CalculatorNamespace.LibNamespace `; +exports[`Generated code for "@scope/jsii-calc-lib": /dotnet/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId/Amazon/JSII/Tests/CalculatorNamespace/LibNamespace/IDiamondLeft.cs 1`] = ` +using Amazon.JSII.Runtime.Deputy; + +#pragma warning disable CS0672,CS0809,CS1591 + +namespace Amazon.JSII.Tests.CalculatorNamespace.LibNamespace +{ + /// + /// Stability: Deprecated + /// + [JsiiInterface(nativeType: typeof(IDiamondLeft), fullyQualifiedName: "@scope/jsii-calc-lib.DiamondLeft")] + [System.Obsolete()] + public interface IDiamondLeft + { + /// + /// Stability: Deprecated + /// + [JsiiProperty(name: "hoistedTop", typeJson: "{\\"primitive\\":\\"string\\"}", isOptional: true)] + [System.Obsolete()] + [Amazon.JSII.Runtime.Deputy.JsiiOptional] + string? HoistedTop + { + get + { + return null; + } + } + + /// + /// Stability: Deprecated + /// + [JsiiProperty(name: "left", typeJson: "{\\"primitive\\":\\"number\\"}", isOptional: true)] + [System.Obsolete()] + [Amazon.JSII.Runtime.Deputy.JsiiOptional] + double? Left + { + get + { + return null; + } + } + + /// + /// Stability: Deprecated + /// + [JsiiTypeProxy(nativeType: typeof(IDiamondLeft), fullyQualifiedName: "@scope/jsii-calc-lib.DiamondLeft")] + [System.Obsolete()] + internal sealed class _Proxy : DeputyBase, Amazon.JSII.Tests.CalculatorNamespace.LibNamespace.IDiamondLeft + { + private _Proxy(ByRefValue reference): base(reference) + { + } + + /// + /// Stability: Deprecated + /// + [JsiiOptional] + [JsiiProperty(name: "hoistedTop", typeJson: "{\\"primitive\\":\\"string\\"}", isOptional: true)] + [System.Obsolete()] + public string? HoistedTop + { + get => GetInstanceProperty(); + } + + /// + /// Stability: Deprecated + /// + [JsiiOptional] + [JsiiProperty(name: "left", typeJson: "{\\"primitive\\":\\"number\\"}", isOptional: true)] + [System.Obsolete()] + public double? Left + { + get => GetInstanceProperty(); + } + } + } +} + +`; + +exports[`Generated code for "@scope/jsii-calc-lib": /dotnet/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId/Amazon/JSII/Tests/CalculatorNamespace/LibNamespace/IDiamondRight.cs 1`] = ` +using Amazon.JSII.Runtime.Deputy; + +#pragma warning disable CS0672,CS0809,CS1591 + +namespace Amazon.JSII.Tests.CalculatorNamespace.LibNamespace +{ + /// + /// Stability: Deprecated + /// + [JsiiInterface(nativeType: typeof(IDiamondRight), fullyQualifiedName: "@scope/jsii-calc-lib.DiamondRight")] + [System.Obsolete()] + public interface IDiamondRight + { + /// + /// Stability: Deprecated + /// + [JsiiProperty(name: "hoistedTop", typeJson: "{\\"primitive\\":\\"string\\"}", isOptional: true)] + [System.Obsolete()] + [Amazon.JSII.Runtime.Deputy.JsiiOptional] + string? HoistedTop + { + get + { + return null; + } + } + + /// + /// Stability: Deprecated + /// + [JsiiProperty(name: "right", typeJson: "{\\"primitive\\":\\"boolean\\"}", isOptional: true)] + [System.Obsolete()] + [Amazon.JSII.Runtime.Deputy.JsiiOptional] + bool? Right + { + get + { + return null; + } + } + + /// + /// Stability: Deprecated + /// + [JsiiTypeProxy(nativeType: typeof(IDiamondRight), fullyQualifiedName: "@scope/jsii-calc-lib.DiamondRight")] + [System.Obsolete()] + internal sealed class _Proxy : DeputyBase, Amazon.JSII.Tests.CalculatorNamespace.LibNamespace.IDiamondRight + { + private _Proxy(ByRefValue reference): base(reference) + { + } + + /// + /// Stability: Deprecated + /// + [JsiiOptional] + [JsiiProperty(name: "hoistedTop", typeJson: "{\\"primitive\\":\\"string\\"}", isOptional: true)] + [System.Obsolete()] + public string? HoistedTop + { + get => GetInstanceProperty(); + } + + /// + /// Stability: Deprecated + /// + [JsiiOptional] + [JsiiProperty(name: "right", typeJson: "{\\"primitive\\":\\"boolean\\"}", isOptional: true)] + [System.Obsolete()] + public bool? Right + { + get => GetInstanceProperty(); + } + } + } +} + +`; + exports[`Generated code for "@scope/jsii-calc-lib": /dotnet/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId/Amazon/JSII/Tests/CalculatorNamespace/LibNamespace/IDoublable.cs 1`] = ` using Amazon.JSII.Runtime.Deputy; @@ -1811,6 +2058,7 @@ exports[`Generated code for "jsii-calc": / 1`] = ` ┃ ┃ ┣━ 📄 Base.cs ┃ ┃ ┗━ 📄 Derived.cs ┃ ┣━ 📄 DerivedStruct.cs + ┃ ┣━ 📄 DiamondBottom.cs ┃ ┣━ 📄 DiamondInheritanceBaseLevelStruct.cs ┃ ┣━ 📄 DiamondInheritanceFirstMidLevelStruct.cs ┃ ┣━ 📄 DiamondInheritanceSecondMidLevelStruct.cs @@ -1850,6 +2098,7 @@ exports[`Generated code for "jsii-calc": / 1`] = ` ┃ ┣━ 📄 IDeprecatedInterface.cs ┃ ┣━ 📄 IDeprecatedStruct.cs ┃ ┣━ 📄 IDerivedStruct.cs + ┃ ┣━ 📄 IDiamondBottom.cs ┃ ┣━ 📄 IDiamondInheritanceBaseLevelStruct.cs ┃ ┣━ 📄 IDiamondInheritanceFirstMidLevelStruct.cs ┃ ┣━ 📄 IDiamondInheritanceSecondMidLevelStruct.cs @@ -4623,6 +4872,64 @@ namespace Amazon.JSII.Tests.CalculatorNamespace `; +exports[`Generated code for "jsii-calc": /dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/DiamondBottom.cs 1`] = ` +using Amazon.JSII.Runtime.Deputy; + +#pragma warning disable CS0672,CS0809,CS1591 + +namespace Amazon.JSII.Tests.CalculatorNamespace +{ + [JsiiByValue(fqn: "jsii-calc.DiamondBottom")] + public class DiamondBottom : Amazon.JSII.Tests.CalculatorNamespace.IDiamondBottom + { + [JsiiOptional] + [JsiiProperty(name: "bottom", typeJson: "{\\"primitive\\":\\"date\\"}", isOptional: true, isOverride: true)] + public System.DateTime? Bottom + { + get; + set; + } + + /// + /// Stability: Deprecated + /// + [JsiiOptional] + [JsiiProperty(name: "hoistedTop", typeJson: "{\\"primitive\\":\\"string\\"}", isOptional: true, isOverride: true)] + [System.Obsolete()] + public string? HoistedTop + { + get; + set; + } + + /// + /// Stability: Deprecated + /// + [JsiiOptional] + [JsiiProperty(name: "left", typeJson: "{\\"primitive\\":\\"number\\"}", isOptional: true, isOverride: true)] + [System.Obsolete()] + public double? Left + { + get; + set; + } + + /// + /// Stability: Deprecated + /// + [JsiiOptional] + [JsiiProperty(name: "right", typeJson: "{\\"primitive\\":\\"boolean\\"}", isOptional: true, isOverride: true)] + [System.Obsolete()] + public bool? Right + { + get; + set; + } + } +} + +`; + exports[`Generated code for "jsii-calc": /dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/DiamondInheritanceBaseLevelStruct.cs 1`] = ` using Amazon.JSII.Runtime.Deputy; @@ -6427,6 +6734,78 @@ namespace Amazon.JSII.Tests.CalculatorNamespace `; +exports[`Generated code for "jsii-calc": /dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IDiamondBottom.cs 1`] = ` +using Amazon.JSII.Runtime.Deputy; + +#pragma warning disable CS0672,CS0809,CS1591 + +namespace Amazon.JSII.Tests.CalculatorNamespace +{ + [JsiiInterface(nativeType: typeof(IDiamondBottom), fullyQualifiedName: "jsii-calc.DiamondBottom")] + public interface IDiamondBottom : Amazon.JSII.Tests.CalculatorNamespace.LibNamespace.IDiamondLeft, Amazon.JSII.Tests.CalculatorNamespace.LibNamespace.IDiamondRight + { + [JsiiProperty(name: "bottom", typeJson: "{\\"primitive\\":\\"date\\"}", isOptional: true)] + [Amazon.JSII.Runtime.Deputy.JsiiOptional] + System.DateTime? Bottom + { + get + { + return null; + } + } + + [JsiiTypeProxy(nativeType: typeof(IDiamondBottom), fullyQualifiedName: "jsii-calc.DiamondBottom")] + internal sealed class _Proxy : DeputyBase, Amazon.JSII.Tests.CalculatorNamespace.IDiamondBottom + { + private _Proxy(ByRefValue reference): base(reference) + { + } + + [JsiiOptional] + [JsiiProperty(name: "bottom", typeJson: "{\\"primitive\\":\\"date\\"}", isOptional: true)] + public System.DateTime? Bottom + { + get => GetInstanceProperty(); + } + + /// + /// Stability: Deprecated + /// + [JsiiOptional] + [JsiiProperty(name: "hoistedTop", typeJson: "{\\"primitive\\":\\"string\\"}", isOptional: true)] + [System.Obsolete()] + public string? HoistedTop + { + get => GetInstanceProperty(); + } + + /// + /// Stability: Deprecated + /// + [JsiiOptional] + [JsiiProperty(name: "left", typeJson: "{\\"primitive\\":\\"number\\"}", isOptional: true)] + [System.Obsolete()] + public double? Left + { + get => GetInstanceProperty(); + } + + /// + /// Stability: Deprecated + /// + [JsiiOptional] + [JsiiProperty(name: "right", typeJson: "{\\"primitive\\":\\"boolean\\"}", isOptional: true)] + [System.Obsolete()] + public bool? Right + { + get => GetInstanceProperty(); + } + } + } +} + +`; + exports[`Generated code for "jsii-calc": /dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/IDiamondInheritanceBaseLevelStruct.cs 1`] = ` using Amazon.JSII.Runtime.Deputy; diff --git a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-go.test.ts.snap b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-go.test.ts.snap index 01ff4fcda4..1a8b46fc5a 100644 --- a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-go.test.ts.snap +++ b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-go.test.ts.snap @@ -503,6 +503,80 @@ import ( "github.com/aws/jsii/jsii-calc/go/scopejsiicalcbaseofbase/v2" ) +// DiamondLeftIface is the public interface for the custom type DiamondLeft +// Deprecated. +type DiamondLeftIface interface { + GetHoistedTop() string + GetLeft() float64 +} + +// Deprecated. +// Struct proxy +type DiamondLeft struct { + // Deprecated. + HoistedTop string \`json:"hoistedTop"\` + // Deprecated. + Left float64 \`json:"left"\` +} + +func (d *DiamondLeft) GetHoistedTop() string { + var returns string + _jsii_.Get( + d, + "hoistedTop", + &returns, + ) + return returns +} + +func (d *DiamondLeft) GetLeft() float64 { + var returns float64 + _jsii_.Get( + d, + "left", + &returns, + ) + return returns +} + + +// DiamondRightIface is the public interface for the custom type DiamondRight +// Deprecated. +type DiamondRightIface interface { + GetHoistedTop() string + GetRight() bool +} + +// Deprecated. +// Struct proxy +type DiamondRight struct { + // Deprecated. + HoistedTop string \`json:"hoistedTop"\` + // Deprecated. + Right bool \`json:"right"\` +} + +func (d *DiamondRight) GetHoistedTop() string { + var returns string + _jsii_.Get( + d, + "hoistedTop", + &returns, + ) + return returns +} + +func (d *DiamondRight) GetRight() bool { + var returns bool + _jsii_.Get( + d, + "right", + &returns, + ) + return returns +} + + // Check that enums from \\@scoped packages can be references. // // See awslabs/jsii#138 @@ -931,6 +1005,16 @@ import ( ) func init() { + _jsii_.RegisterStruct( + "@scope/jsii-calc-lib.DiamondLeft", + reflect.TypeOf((*DiamondLeft)(nil)).Elem(), + reflect.TypeOf((*DiamondLeftIface)(nil)).Elem(), + ) + _jsii_.RegisterStruct( + "@scope/jsii-calc-lib.DiamondRight", + reflect.TypeOf((*DiamondRight)(nil)).Elem(), + reflect.TypeOf((*DiamondRightIface)(nil)).Elem(), + ) _jsii_.RegisterEnum( "@scope/jsii-calc-lib.EnumFromScopedModule", reflect.TypeOf((*EnumFromScopedModule)(nil)).Elem(), @@ -4870,6 +4954,66 @@ func (d *DerivedStruct) GetOptionalArray() []string { } +// DiamondBottomIface is the public interface for the custom type DiamondBottom +type DiamondBottomIface interface { + GetHoistedTop() string + GetLeft() float64 + GetRight() bool + GetBottom() string +} + +// Struct proxy +type DiamondBottom struct { + // Deprecated. + HoistedTop string \`json:"hoistedTop"\` + // Deprecated. + Left float64 \`json:"left"\` + // Deprecated. + Right bool \`json:"right"\` + Bottom string \`json:"bottom"\` +} + +func (d *DiamondBottom) GetHoistedTop() string { + var returns string + _jsii_.Get( + d, + "hoistedTop", + &returns, + ) + return returns +} + +func (d *DiamondBottom) GetLeft() float64 { + var returns float64 + _jsii_.Get( + d, + "left", + &returns, + ) + return returns +} + +func (d *DiamondBottom) GetRight() bool { + var returns bool + _jsii_.Get( + d, + "right", + &returns, + ) + return returns +} + +func (d *DiamondBottom) GetBottom() string { + var returns string + _jsii_.Get( + d, + "bottom", + &returns, + ) + return returns +} + + // DiamondInheritanceBaseLevelStructIface is the public interface for the custom type DiamondInheritanceBaseLevelStruct type DiamondInheritanceBaseLevelStructIface interface { GetBaseLevelProperty() string @@ -13221,6 +13365,11 @@ func init() { reflect.TypeOf((*DerivedStruct)(nil)).Elem(), reflect.TypeOf((*DerivedStructIface)(nil)).Elem(), ) + _jsii_.RegisterStruct( + "jsii-calc.DiamondBottom", + reflect.TypeOf((*DiamondBottom)(nil)).Elem(), + reflect.TypeOf((*DiamondBottomIface)(nil)).Elem(), + ) _jsii_.RegisterStruct( "jsii-calc.DiamondInheritanceBaseLevelStruct", reflect.TypeOf((*DiamondInheritanceBaseLevelStruct)(nil)).Elem(), diff --git a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-java.test.ts.snap b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-java.test.ts.snap index 267236b642..8352797c12 100644 --- a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-java.test.ts.snap +++ b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-java.test.ts.snap @@ -994,6 +994,8 @@ exports[`Generated code for "@scope/jsii-calc-lib": / 1`] = ` ┃ ┃ ┗━ 📄 Reflector.java ┃ ┗━ 📁 lib ┃ ┣━ 📄 $Module.java + ┃ ┣━ 📄 DiamondLeft.java + ┃ ┣━ 📄 DiamondRight.java ┃ ┣━ 📄 EnumFromScopedModule.java ┃ ┣━ 📄 IDoublable.java ┃ ┣━ 📄 IFriendly.java @@ -1687,6 +1689,338 @@ public final class $Module extends JsiiModule { `; +exports[`Generated code for "@scope/jsii-calc-lib": /java/src/main/java/software/amazon/jsii/tests/calculator/lib/DiamondLeft.java 1`] = ` +package software.amazon.jsii.tests.calculator.lib; + +/** + */ +@javax.annotation.Generated(value = "jsii-pacmak") +@software.amazon.jsii.Jsii(module = software.amazon.jsii.tests.calculator.lib.$Module.class, fqn = "@scope/jsii-calc-lib.DiamondLeft") +@software.amazon.jsii.Jsii.Proxy(DiamondLeft.Jsii$Proxy.class) +@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Deprecated) +@Deprecated +public interface DiamondLeft extends software.amazon.jsii.JsiiSerializable { + + /** + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Deprecated) + @Deprecated + default @org.jetbrains.annotations.Nullable java.lang.String getHoistedTop() { + return null; + } + + /** + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Deprecated) + @Deprecated + default @org.jetbrains.annotations.Nullable java.lang.Number getLeft() { + return null; + } + + /** + * @return a {@link Builder} of {@link DiamondLeft} + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Deprecated) + @Deprecated + static Builder builder() { + return new Builder(); + } + /** + * A builder for {@link DiamondLeft} + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Deprecated) + @Deprecated + public static final class Builder implements software.amazon.jsii.Builder { + private java.lang.String hoistedTop; + private java.lang.Number left; + + /** + * Sets the value of {@link DiamondLeft#getHoistedTop} + * @param hoistedTop the value to be set. + * @return {@code this} + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Deprecated) + @Deprecated + public Builder hoistedTop(java.lang.String hoistedTop) { + this.hoistedTop = hoistedTop; + return this; + } + + /** + * Sets the value of {@link DiamondLeft#getLeft} + * @param left the value to be set. + * @return {@code this} + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Deprecated) + @Deprecated + public Builder left(java.lang.Number left) { + this.left = left; + return this; + } + + /** + * Builds the configured instance. + * @return a new instance of {@link DiamondLeft} + * @throws NullPointerException if any required attribute was not provided + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Deprecated) + @Deprecated + @Override + public DiamondLeft build() { + return new Jsii$Proxy(hoistedTop, left); + } + } + + /** + * An implementation for {@link DiamondLeft} + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Deprecated) + @Deprecated + @software.amazon.jsii.Internal + final class Jsii$Proxy extends software.amazon.jsii.JsiiObject implements DiamondLeft { + private final java.lang.String hoistedTop; + private final java.lang.Number left; + + /** + * Constructor that initializes the object based on values retrieved from the JsiiObject. + * @param objRef Reference to the JSII managed object. + */ + protected Jsii$Proxy(final software.amazon.jsii.JsiiObjectRef objRef) { + super(objRef); + this.hoistedTop = software.amazon.jsii.Kernel.get(this, "hoistedTop", software.amazon.jsii.NativeType.forClass(java.lang.String.class)); + this.left = software.amazon.jsii.Kernel.get(this, "left", software.amazon.jsii.NativeType.forClass(java.lang.Number.class)); + } + + /** + * Constructor that initializes the object based on literal property values passed by the {@link Builder}. + */ + protected Jsii$Proxy(final java.lang.String hoistedTop, final java.lang.Number left) { + super(software.amazon.jsii.JsiiObject.InitializationMode.JSII); + this.hoistedTop = hoistedTop; + this.left = left; + } + + @Override + public final java.lang.String getHoistedTop() { + return this.hoistedTop; + } + + @Override + public final java.lang.Number getLeft() { + return this.left; + } + + @Override + @software.amazon.jsii.Internal + public com.fasterxml.jackson.databind.JsonNode $jsii$toJson() { + final com.fasterxml.jackson.databind.ObjectMapper om = software.amazon.jsii.JsiiObjectMapper.INSTANCE; + final com.fasterxml.jackson.databind.node.ObjectNode data = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode(); + + if (this.getHoistedTop() != null) { + data.set("hoistedTop", om.valueToTree(this.getHoistedTop())); + } + if (this.getLeft() != null) { + data.set("left", om.valueToTree(this.getLeft())); + } + + final com.fasterxml.jackson.databind.node.ObjectNode struct = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode(); + struct.set("fqn", om.valueToTree("@scope/jsii-calc-lib.DiamondLeft")); + struct.set("data", data); + + final com.fasterxml.jackson.databind.node.ObjectNode obj = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode(); + obj.set("$jsii.struct", struct); + + return obj; + } + + @Override + public final boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + DiamondLeft.Jsii$Proxy that = (DiamondLeft.Jsii$Proxy) o; + + if (this.hoistedTop != null ? !this.hoistedTop.equals(that.hoistedTop) : that.hoistedTop != null) return false; + return this.left != null ? this.left.equals(that.left) : that.left == null; + } + + @Override + public final int hashCode() { + int result = this.hoistedTop != null ? this.hoistedTop.hashCode() : 0; + result = 31 * result + (this.left != null ? this.left.hashCode() : 0); + return result; + } + } +} + +`; + +exports[`Generated code for "@scope/jsii-calc-lib": /java/src/main/java/software/amazon/jsii/tests/calculator/lib/DiamondRight.java 1`] = ` +package software.amazon.jsii.tests.calculator.lib; + +/** + */ +@javax.annotation.Generated(value = "jsii-pacmak") +@software.amazon.jsii.Jsii(module = software.amazon.jsii.tests.calculator.lib.$Module.class, fqn = "@scope/jsii-calc-lib.DiamondRight") +@software.amazon.jsii.Jsii.Proxy(DiamondRight.Jsii$Proxy.class) +@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Deprecated) +@Deprecated +public interface DiamondRight extends software.amazon.jsii.JsiiSerializable { + + /** + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Deprecated) + @Deprecated + default @org.jetbrains.annotations.Nullable java.lang.String getHoistedTop() { + return null; + } + + /** + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Deprecated) + @Deprecated + default @org.jetbrains.annotations.Nullable java.lang.Boolean getRight() { + return null; + } + + /** + * @return a {@link Builder} of {@link DiamondRight} + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Deprecated) + @Deprecated + static Builder builder() { + return new Builder(); + } + /** + * A builder for {@link DiamondRight} + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Deprecated) + @Deprecated + public static final class Builder implements software.amazon.jsii.Builder { + private java.lang.String hoistedTop; + private java.lang.Boolean right; + + /** + * Sets the value of {@link DiamondRight#getHoistedTop} + * @param hoistedTop the value to be set. + * @return {@code this} + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Deprecated) + @Deprecated + public Builder hoistedTop(java.lang.String hoistedTop) { + this.hoistedTop = hoistedTop; + return this; + } + + /** + * Sets the value of {@link DiamondRight#getRight} + * @param right the value to be set. + * @return {@code this} + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Deprecated) + @Deprecated + public Builder right(java.lang.Boolean right) { + this.right = right; + return this; + } + + /** + * Builds the configured instance. + * @return a new instance of {@link DiamondRight} + * @throws NullPointerException if any required attribute was not provided + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Deprecated) + @Deprecated + @Override + public DiamondRight build() { + return new Jsii$Proxy(hoistedTop, right); + } + } + + /** + * An implementation for {@link DiamondRight} + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Deprecated) + @Deprecated + @software.amazon.jsii.Internal + final class Jsii$Proxy extends software.amazon.jsii.JsiiObject implements DiamondRight { + private final java.lang.String hoistedTop; + private final java.lang.Boolean right; + + /** + * Constructor that initializes the object based on values retrieved from the JsiiObject. + * @param objRef Reference to the JSII managed object. + */ + protected Jsii$Proxy(final software.amazon.jsii.JsiiObjectRef objRef) { + super(objRef); + this.hoistedTop = software.amazon.jsii.Kernel.get(this, "hoistedTop", software.amazon.jsii.NativeType.forClass(java.lang.String.class)); + this.right = software.amazon.jsii.Kernel.get(this, "right", software.amazon.jsii.NativeType.forClass(java.lang.Boolean.class)); + } + + /** + * Constructor that initializes the object based on literal property values passed by the {@link Builder}. + */ + protected Jsii$Proxy(final java.lang.String hoistedTop, final java.lang.Boolean right) { + super(software.amazon.jsii.JsiiObject.InitializationMode.JSII); + this.hoistedTop = hoistedTop; + this.right = right; + } + + @Override + public final java.lang.String getHoistedTop() { + return this.hoistedTop; + } + + @Override + public final java.lang.Boolean getRight() { + return this.right; + } + + @Override + @software.amazon.jsii.Internal + public com.fasterxml.jackson.databind.JsonNode $jsii$toJson() { + final com.fasterxml.jackson.databind.ObjectMapper om = software.amazon.jsii.JsiiObjectMapper.INSTANCE; + final com.fasterxml.jackson.databind.node.ObjectNode data = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode(); + + if (this.getHoistedTop() != null) { + data.set("hoistedTop", om.valueToTree(this.getHoistedTop())); + } + if (this.getRight() != null) { + data.set("right", om.valueToTree(this.getRight())); + } + + final com.fasterxml.jackson.databind.node.ObjectNode struct = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode(); + struct.set("fqn", om.valueToTree("@scope/jsii-calc-lib.DiamondRight")); + struct.set("data", data); + + final com.fasterxml.jackson.databind.node.ObjectNode obj = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode(); + obj.set("$jsii.struct", struct); + + return obj; + } + + @Override + public final boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + DiamondRight.Jsii$Proxy that = (DiamondRight.Jsii$Proxy) o; + + if (this.hoistedTop != null ? !this.hoistedTop.equals(that.hoistedTop) : that.hoistedTop != null) return false; + return this.right != null ? this.right.equals(that.right) : that.right == null; + } + + @Override + public final int hashCode() { + int result = this.hoistedTop != null ? this.hoistedTop.hashCode() : 0; + result = 31 * result + (this.right != null ? this.right.hashCode() : 0); + return result; + } + } +} + +`; + exports[`Generated code for "@scope/jsii-calc-lib": /java/src/main/java/software/amazon/jsii/tests/calculator/lib/EnumFromScopedModule.java 1`] = ` package software.amazon.jsii.tests.calculator.lib; @@ -2508,6 +2842,8 @@ package software.amazon.jsii.tests.calculator.lib; `; exports[`Generated code for "@scope/jsii-calc-lib": /java/src/main/resources/software/amazon/jsii/tests/calculator/lib/$Module.txt 1`] = ` +@scope/jsii-calc-lib.DiamondLeft=software.amazon.jsii.tests.calculator.lib.DiamondLeft +@scope/jsii-calc-lib.DiamondRight=software.amazon.jsii.tests.calculator.lib.DiamondRight @scope/jsii-calc-lib.EnumFromScopedModule=software.amazon.jsii.tests.calculator.lib.EnumFromScopedModule @scope/jsii-calc-lib.IDoublable=software.amazon.jsii.tests.calculator.lib.IDoublable @scope/jsii-calc-lib.IFriendly=software.amazon.jsii.tests.calculator.lib.IFriendly @@ -2586,6 +2922,7 @@ exports[`Generated code for "jsii-calc": / 1`] = ` ┃ ┃ ┣━ 📄 Base.java ┃ ┃ ┗━ 📄 Derived.java ┃ ┣━ 📄 DerivedStruct.java + ┃ ┣━ 📄 DiamondBottom.java ┃ ┣━ 📄 DiamondInheritanceBaseLevelStruct.java ┃ ┣━ 📄 DiamondInheritanceFirstMidLevelStruct.java ┃ ┣━ 📄 DiamondInheritanceSecondMidLevelStruct.java @@ -6642,6 +6979,218 @@ public interface DerivedStruct extends software.amazon.jsii.JsiiSerializable, so `; +exports[`Generated code for "jsii-calc": /java/src/main/java/software/amazon/jsii/tests/calculator/DiamondBottom.java 1`] = ` +package software.amazon.jsii.tests.calculator; + +/** + */ +@javax.annotation.Generated(value = "jsii-pacmak") +@software.amazon.jsii.Jsii(module = software.amazon.jsii.tests.calculator.$Module.class, fqn = "jsii-calc.DiamondBottom") +@software.amazon.jsii.Jsii.Proxy(DiamondBottom.Jsii$Proxy.class) +@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) +public interface DiamondBottom extends software.amazon.jsii.JsiiSerializable, software.amazon.jsii.tests.calculator.lib.DiamondLeft, software.amazon.jsii.tests.calculator.lib.DiamondRight { + + /** + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + default @org.jetbrains.annotations.Nullable java.time.Instant getBottom() { + return null; + } + + /** + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Deprecated) + @Deprecated + @Override + default @org.jetbrains.annotations.Nullable java.lang.String getHoistedTop() { + return null; + } + + /** + * @return a {@link Builder} of {@link DiamondBottom} + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + static Builder builder() { + return new Builder(); + } + /** + * A builder for {@link DiamondBottom} + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + public static final class Builder implements software.amazon.jsii.Builder { + private java.time.Instant bottom; + private java.lang.String hoistedTop; + private java.lang.Number left; + private java.lang.Boolean right; + + /** + * Sets the value of {@link DiamondBottom#getBottom} + * @param bottom the value to be set. + * @return {@code this} + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + public Builder bottom(java.time.Instant bottom) { + this.bottom = bottom; + return this; + } + + /** + * Sets the value of {@link DiamondBottom#getHoistedTop} + * @param hoistedTop the value to be set. + * @return {@code this} + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Deprecated) + @Deprecated + public Builder hoistedTop(java.lang.String hoistedTop) { + this.hoistedTop = hoistedTop; + return this; + } + + /** + * Sets the value of {@link DiamondBottom#getLeft} + * @param left the value to be set. + * @return {@code this} + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Deprecated) + @Deprecated + public Builder left(java.lang.Number left) { + this.left = left; + return this; + } + + /** + * Sets the value of {@link DiamondBottom#getRight} + * @param right the value to be set. + * @return {@code this} + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Deprecated) + @Deprecated + public Builder right(java.lang.Boolean right) { + this.right = right; + return this; + } + + /** + * Builds the configured instance. + * @return a new instance of {@link DiamondBottom} + * @throws NullPointerException if any required attribute was not provided + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + @Override + public DiamondBottom build() { + return new Jsii$Proxy(bottom, hoistedTop, left, right); + } + } + + /** + * An implementation for {@link DiamondBottom} + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + @software.amazon.jsii.Internal + final class Jsii$Proxy extends software.amazon.jsii.JsiiObject implements DiamondBottom { + private final java.time.Instant bottom; + private final java.lang.String hoistedTop; + private final java.lang.Number left; + private final java.lang.Boolean right; + + /** + * Constructor that initializes the object based on values retrieved from the JsiiObject. + * @param objRef Reference to the JSII managed object. + */ + protected Jsii$Proxy(final software.amazon.jsii.JsiiObjectRef objRef) { + super(objRef); + this.bottom = software.amazon.jsii.Kernel.get(this, "bottom", software.amazon.jsii.NativeType.forClass(java.time.Instant.class)); + this.hoistedTop = software.amazon.jsii.Kernel.get(this, "hoistedTop", software.amazon.jsii.NativeType.forClass(java.lang.String.class)); + this.left = software.amazon.jsii.Kernel.get(this, "left", software.amazon.jsii.NativeType.forClass(java.lang.Number.class)); + this.right = software.amazon.jsii.Kernel.get(this, "right", software.amazon.jsii.NativeType.forClass(java.lang.Boolean.class)); + } + + /** + * Constructor that initializes the object based on literal property values passed by the {@link Builder}. + */ + protected Jsii$Proxy(final java.time.Instant bottom, final java.lang.String hoistedTop, final java.lang.Number left, final java.lang.Boolean right) { + super(software.amazon.jsii.JsiiObject.InitializationMode.JSII); + this.bottom = bottom; + this.hoistedTop = hoistedTop; + this.left = left; + this.right = right; + } + + @Override + public final java.time.Instant getBottom() { + return this.bottom; + } + + @Override + public final java.lang.String getHoistedTop() { + return this.hoistedTop; + } + + @Override + public final java.lang.Number getLeft() { + return this.left; + } + + @Override + public final java.lang.Boolean getRight() { + return this.right; + } + + @Override + @software.amazon.jsii.Internal + public com.fasterxml.jackson.databind.JsonNode $jsii$toJson() { + final com.fasterxml.jackson.databind.ObjectMapper om = software.amazon.jsii.JsiiObjectMapper.INSTANCE; + final com.fasterxml.jackson.databind.node.ObjectNode data = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode(); + + if (this.getBottom() != null) { + data.set("bottom", om.valueToTree(this.getBottom())); + } + if (this.getHoistedTop() != null) { + data.set("hoistedTop", om.valueToTree(this.getHoistedTop())); + } + if (this.getLeft() != null) { + data.set("left", om.valueToTree(this.getLeft())); + } + if (this.getRight() != null) { + data.set("right", om.valueToTree(this.getRight())); + } + + final com.fasterxml.jackson.databind.node.ObjectNode struct = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode(); + struct.set("fqn", om.valueToTree("jsii-calc.DiamondBottom")); + struct.set("data", data); + + final com.fasterxml.jackson.databind.node.ObjectNode obj = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode(); + obj.set("$jsii.struct", struct); + + return obj; + } + + @Override + public final boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + DiamondBottom.Jsii$Proxy that = (DiamondBottom.Jsii$Proxy) o; + + if (this.bottom != null ? !this.bottom.equals(that.bottom) : that.bottom != null) return false; + if (this.hoistedTop != null ? !this.hoistedTop.equals(that.hoistedTop) : that.hoistedTop != null) return false; + if (this.left != null ? !this.left.equals(that.left) : that.left != null) return false; + return this.right != null ? this.right.equals(that.right) : that.right == null; + } + + @Override + public final int hashCode() { + int result = this.bottom != null ? this.bottom.hashCode() : 0; + result = 31 * result + (this.hoistedTop != null ? this.hoistedTop.hashCode() : 0); + result = 31 * result + (this.left != null ? this.left.hashCode() : 0); + result = 31 * result + (this.right != null ? this.right.hashCode() : 0); + return result; + } + } +} + +`; + exports[`Generated code for "jsii-calc": /java/src/main/java/software/amazon/jsii/tests/calculator/DiamondInheritanceBaseLevelStruct.java 1`] = ` package software.amazon.jsii.tests.calculator; @@ -7067,6 +7616,11 @@ public interface DiamondInheritanceTopLevelStruct extends software.amazon.jsii.J @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) @org.jetbrains.annotations.NotNull java.lang.String getTopLevelProperty(); + /** + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + @org.jetbrains.annotations.NotNull java.lang.String getBaseLevelProperty(); + /** * @return a {@link Builder} of {@link DiamondInheritanceTopLevelStruct} */ @@ -21366,6 +21920,7 @@ jsii-calc.DeprecatedStruct=software.amazon.jsii.tests.calculator.DeprecatedStruc jsii-calc.DerivedClassHasNoProperties.Base=software.amazon.jsii.tests.calculator.derived_class_has_no_properties.Base jsii-calc.DerivedClassHasNoProperties.Derived=software.amazon.jsii.tests.calculator.derived_class_has_no_properties.Derived jsii-calc.DerivedStruct=software.amazon.jsii.tests.calculator.DerivedStruct +jsii-calc.DiamondBottom=software.amazon.jsii.tests.calculator.DiamondBottom jsii-calc.DiamondInheritanceBaseLevelStruct=software.amazon.jsii.tests.calculator.DiamondInheritanceBaseLevelStruct jsii-calc.DiamondInheritanceFirstMidLevelStruct=software.amazon.jsii.tests.calculator.DiamondInheritanceFirstMidLevelStruct jsii-calc.DiamondInheritanceSecondMidLevelStruct=software.amazon.jsii.tests.calculator.DiamondInheritanceSecondMidLevelStruct diff --git a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.ts.snap b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.ts.snap index 690b74944b..5d121cd82b 100644 --- a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.ts.snap +++ b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.ts.snap @@ -627,6 +627,110 @@ from ._jsii import * import scope.jsii_calc_base +@jsii.data_type( + jsii_type="@scope/jsii-calc-lib.DiamondLeft", + jsii_struct_bases=[], + name_mapping={"hoisted_top": "hoistedTop", "left": "left"}, +) +class DiamondLeft: + def __init__( + self, + *, + hoisted_top: typing.Optional[builtins.str] = None, + left: typing.Optional[jsii.Number] = None, + ) -> None: + ''' + :param hoisted_top: + :param left: + + :stability: deprecated + ''' + self._values: typing.Dict[str, typing.Any] = {} + if hoisted_top is not None: + self._values["hoisted_top"] = hoisted_top + if left is not None: + self._values["left"] = left + + @builtins.property + def hoisted_top(self) -> typing.Optional[builtins.str]: + ''' + :stability: deprecated + ''' + result = self._values.get("hoisted_top") + return typing.cast(typing.Optional[builtins.str], result) + + @builtins.property + def left(self) -> typing.Optional[jsii.Number]: + ''' + :stability: deprecated + ''' + result = self._values.get("left") + return typing.cast(typing.Optional[jsii.Number], result) + + def __eq__(self, rhs: typing.Any) -> builtins.bool: + return isinstance(rhs, self.__class__) and rhs._values == self._values + + def __ne__(self, rhs: typing.Any) -> builtins.bool: + return not (rhs == self) + + def __repr__(self) -> str: + return "DiamondLeft(%s)" % ", ".join( + k + "=" + repr(v) for k, v in self._values.items() + ) + + +@jsii.data_type( + jsii_type="@scope/jsii-calc-lib.DiamondRight", + jsii_struct_bases=[], + name_mapping={"hoisted_top": "hoistedTop", "right": "right"}, +) +class DiamondRight: + def __init__( + self, + *, + hoisted_top: typing.Optional[builtins.str] = None, + right: typing.Optional[builtins.bool] = None, + ) -> None: + ''' + :param hoisted_top: + :param right: + + :stability: deprecated + ''' + self._values: typing.Dict[str, typing.Any] = {} + if hoisted_top is not None: + self._values["hoisted_top"] = hoisted_top + if right is not None: + self._values["right"] = right + + @builtins.property + def hoisted_top(self) -> typing.Optional[builtins.str]: + ''' + :stability: deprecated + ''' + result = self._values.get("hoisted_top") + return typing.cast(typing.Optional[builtins.str], result) + + @builtins.property + def right(self) -> typing.Optional[builtins.bool]: + ''' + :stability: deprecated + ''' + result = self._values.get("right") + return typing.cast(typing.Optional[builtins.bool], result) + + def __eq__(self, rhs: typing.Any) -> builtins.bool: + return isinstance(rhs, self.__class__) and rhs._values == self._values + + def __ne__(self, rhs: typing.Any) -> builtins.bool: + return not (rhs == self) + + def __repr__(self) -> str: + return "DiamondRight(%s)" % ", ".join( + k + "=" + repr(v) for k, v in self._values.items() + ) + + @jsii.enum(jsii_type="@scope/jsii-calc-lib.EnumFromScopedModule") class EnumFromScopedModule(enum.Enum): '''(deprecated) Check that enums from @scoped packages can be references. @@ -1042,6 +1146,8 @@ class Number( __all__ = [ + "DiamondLeft", + "DiamondRight", "EnumFromScopedModule", "IDoublable", "IFriendly", @@ -2998,6 +3104,84 @@ class DerivedStruct(scope.jsii_calc_lib.MyFirstStruct): ) +@jsii.data_type( + jsii_type="jsii-calc.DiamondBottom", + jsii_struct_bases=[ + scope.jsii_calc_lib.DiamondLeft, scope.jsii_calc_lib.DiamondRight + ], + name_mapping={ + "hoisted_top": "hoistedTop", + "left": "left", + "right": "right", + "bottom": "bottom", + }, +) +class DiamondBottom(scope.jsii_calc_lib.DiamondLeft, scope.jsii_calc_lib.DiamondRight): + def __init__( + self, + *, + hoisted_top: typing.Optional[builtins.str] = None, + left: typing.Optional[jsii.Number] = None, + right: typing.Optional[builtins.bool] = None, + bottom: typing.Optional[datetime.datetime] = None, + ) -> None: + ''' + :param hoisted_top: + :param left: + :param right: + :param bottom: + ''' + self._values: typing.Dict[str, typing.Any] = {} + if hoisted_top is not None: + self._values["hoisted_top"] = hoisted_top + if left is not None: + self._values["left"] = left + if right is not None: + self._values["right"] = right + if bottom is not None: + self._values["bottom"] = bottom + + @builtins.property + def hoisted_top(self) -> typing.Optional[builtins.str]: + ''' + :stability: deprecated + ''' + result = self._values.get("hoisted_top") + return typing.cast(typing.Optional[builtins.str], result) + + @builtins.property + def left(self) -> typing.Optional[jsii.Number]: + ''' + :stability: deprecated + ''' + result = self._values.get("left") + return typing.cast(typing.Optional[jsii.Number], result) + + @builtins.property + def right(self) -> typing.Optional[builtins.bool]: + ''' + :stability: deprecated + ''' + result = self._values.get("right") + return typing.cast(typing.Optional[builtins.bool], result) + + @builtins.property + def bottom(self) -> typing.Optional[datetime.datetime]: + result = self._values.get("bottom") + return typing.cast(typing.Optional[datetime.datetime], result) + + def __eq__(self, rhs: typing.Any) -> builtins.bool: + return isinstance(rhs, self.__class__) and rhs._values == self._values + + def __ne__(self, rhs: typing.Any) -> builtins.bool: + return not (rhs == self) + + def __repr__(self) -> str: + return "DiamondBottom(%s)" % ", ".join( + k + "=" + repr(v) for k, v in self._values.items() + ) + + @jsii.data_type( jsii_type="jsii-calc.DiamondInheritanceBaseLevelStruct", jsii_struct_bases=[], @@ -8641,6 +8825,7 @@ __all__ = [ "DeprecatedEnum", "DeprecatedStruct", "DerivedStruct", + "DiamondBottom", "DiamondInheritanceBaseLevelStruct", "DiamondInheritanceFirstMidLevelStruct", "DiamondInheritanceSecondMidLevelStruct", diff --git a/packages/jsii-reflect/test/__snapshots__/jsii-tree.test.ts.snap b/packages/jsii-reflect/test/__snapshots__/jsii-tree.test.ts.snap index c3bd857f99..4001a1e815 100644 --- a/packages/jsii-reflect/test/__snapshots__/jsii-tree.test.ts.snap +++ b/packages/jsii-reflect/test/__snapshots__/jsii-tree.test.ts.snap @@ -2064,6 +2064,15 @@ exports[`jsii-tree --all 1`] = ` │ │ ├── abstract │ │ ├── immutable │ │ └── type: Optional> + │ ├─┬ interface DiamondBottom (stable) + │ │ ├─┬ interfaces + │ │ │ ├── DiamondLeft + │ │ │ └── DiamondRight + │ │ └─┬ members + │ │ └─┬ bottom property (stable) + │ │ ├── abstract + │ │ ├── immutable + │ │ └── type: Optional │ ├─┬ interface DiamondInheritanceBaseLevelStruct (stable) │ │ └─┬ members │ │ └─┬ baseLevelProperty property (stable) @@ -2755,6 +2764,26 @@ exports[`jsii-tree --all 1`] = ` │ └─┬ toString() method (deprecated) │ ├── abstract │ └── returns: string + ├─┬ interface DiamondLeft (deprecated) + │ └─┬ members + │ ├─┬ hoistedTop property (deprecated) + │ │ ├── abstract + │ │ ├── immutable + │ │ └── type: Optional + │ └─┬ left property (deprecated) + │ ├── abstract + │ ├── immutable + │ └── type: Optional + ├─┬ interface DiamondRight (deprecated) + │ └─┬ members + │ ├─┬ hoistedTop property (deprecated) + │ │ ├── abstract + │ │ ├── immutable + │ │ └── type: Optional + │ └─┬ right property (deprecated) + │ ├── abstract + │ ├── immutable + │ └── type: Optional ├─┬ interface IDoublable (deprecated) │ └─┬ members │ └─┬ doubleValue property (deprecated) @@ -3033,6 +3062,10 @@ exports[`jsii-tree --inheritance 1`] = ` │ ├─┬ interface DerivedStruct │ │ └─┬ interfaces │ │ └── MyFirstStruct + │ ├─┬ interface DiamondBottom + │ │ └─┬ interfaces + │ │ ├── DiamondLeft + │ │ └── DiamondRight │ ├── interface DiamondInheritanceBaseLevelStruct │ ├─┬ interface DiamondInheritanceFirstMidLevelStruct │ │ └─┬ interfaces @@ -3163,6 +3196,8 @@ exports[`jsii-tree --inheritance 1`] = ` │ └── base: Base ├─┬ class Operation │ └── base: NumericValue + ├── interface DiamondLeft + ├── interface DiamondRight ├── interface IDoublable ├── interface IFriendly ├─┬ interface IThreeLevelsInterface @@ -4084,6 +4119,9 @@ exports[`jsii-tree --members 1`] = ` │ │ ├── anotherOptional property │ │ ├── optionalAny property │ │ └── optionalArray property + │ ├─┬ interface DiamondBottom + │ │ └─┬ members + │ │ └── bottom property │ ├─┬ interface DiamondInheritanceBaseLevelStruct │ │ └─┬ members │ │ └── baseLevelProperty property @@ -4410,6 +4448,14 @@ exports[`jsii-tree --members 1`] = ` │ └─┬ members │ ├── () initializer │ └── toString() method + ├─┬ interface DiamondLeft + │ └─┬ members + │ ├── hoistedTop property + │ └── left property + ├─┬ interface DiamondRight + │ └─┬ members + │ ├── hoistedTop property + │ └── right property ├─┬ interface IDoublable │ └─┬ members │ └── doubleValue property @@ -4648,6 +4694,7 @@ exports[`jsii-tree --types 1`] = ` │ ├── interface ConfusingToJacksonStruct │ ├── interface DeprecatedStruct │ ├── interface DerivedStruct + │ ├── interface DiamondBottom │ ├── interface DiamondInheritanceBaseLevelStruct │ ├── interface DiamondInheritanceFirstMidLevelStruct │ ├── interface DiamondInheritanceSecondMidLevelStruct @@ -4748,6 +4795,8 @@ exports[`jsii-tree --types 1`] = ` ├── class Number ├── class NumericValue ├── class Operation + ├── interface DiamondLeft + ├── interface DiamondRight ├── interface IDoublable ├── interface IFriendly ├── interface IThreeLevelsInterface diff --git a/packages/jsii-reflect/test/__snapshots__/tree.test.ts.snap b/packages/jsii-reflect/test/__snapshots__/tree.test.ts.snap index d9751a15c6..912f35b07f 100644 --- a/packages/jsii-reflect/test/__snapshots__/tree.test.ts.snap +++ b/packages/jsii-reflect/test/__snapshots__/tree.test.ts.snap @@ -2145,6 +2145,15 @@ exports[`showAll 1`] = ` │ │ ├── abstract │ │ ├── immutable │ │ └── type: Optional> + │ ├─┬ interface DiamondBottom + │ │ ├─┬ interfaces + │ │ │ ├── DiamondLeft + │ │ │ └── DiamondRight + │ │ └─┬ members + │ │ └─┬ bottom property + │ │ ├── abstract + │ │ ├── immutable + │ │ └── type: Optional │ ├─┬ interface DiamondInheritanceBaseLevelStruct │ │ └─┬ members │ │ └─┬ baseLevelProperty property @@ -2836,6 +2845,26 @@ exports[`showAll 1`] = ` │ └─┬ toString() method │ ├── abstract │ └── returns: string + ├─┬ interface DiamondLeft + │ └─┬ members + │ ├─┬ hoistedTop property + │ │ ├── abstract + │ │ ├── immutable + │ │ └── type: Optional + │ └─┬ left property + │ ├── abstract + │ ├── immutable + │ └── type: Optional + ├─┬ interface DiamondRight + │ └─┬ members + │ ├─┬ hoistedTop property + │ │ ├── abstract + │ │ ├── immutable + │ │ └── type: Optional + │ └─┬ right property + │ ├── abstract + │ ├── immutable + │ └── type: Optional ├─┬ interface IDoublable │ └─┬ members │ └─┬ doubleValue property @@ -3101,6 +3130,7 @@ exports[`types 1`] = ` │ ├── interface ConfusingToJacksonStruct │ ├── interface DeprecatedStruct │ ├── interface DerivedStruct + │ ├── interface DiamondBottom │ ├── interface DiamondInheritanceBaseLevelStruct │ ├── interface DiamondInheritanceFirstMidLevelStruct │ ├── interface DiamondInheritanceSecondMidLevelStruct @@ -3201,6 +3231,8 @@ exports[`types 1`] = ` ├── class Number ├── class NumericValue ├── class Operation + ├── interface DiamondLeft + ├── interface DiamondRight ├── interface IDoublable ├── interface IFriendly ├── interface IThreeLevelsInterface