Skip to content

Commit

Permalink
Merge branch 'master' into rmuller/fix-external-import-detection
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored May 14, 2020
2 parents 59d8b05 + 4635654 commit fd4f17b
Show file tree
Hide file tree
Showing 69 changed files with 949 additions and 468 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package software.amazon.jsii;

/**
* A superinterface common to instance builders.
*/
@FunctionalInterface
public interface Builder<T> {
/**
* Builds the instance given the current builder configuration.
*
* @return the built instance.
*/
T build();
}
16 changes: 15 additions & 1 deletion packages/@jsii/python-runtime/tests/test_compliance.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,11 @@
StructUnionConsumer,
SomeTypeJsii976,
StructParameterType,
AnonymousImplementationProvider
AnonymousImplementationProvider,
UpcasingReflectable,
)
from scope.jsii_calc_lib import IFriendly, EnumFromScopedModule, Number
from scope.jsii_calc_lib.submodule import IReflectable, ReflectableEntry


# Note: The names of these test functions have been chosen to map as closely to the
Expand Down Expand Up @@ -1168,3 +1170,15 @@ def test_collection_of_interfaces_map_of_structs():
def test_collection_of_interfaces_map_of_interfaces():
for elt in InterfaceCollections.map_of_interfaces().values():
assert getattr(elt, "ring") is not None


def test_dependency_submodule_types_are_usable():
subject = UpcasingReflectable({ 'foo': 'bar' })

assert UpcasingReflectable.REFLECTOR.as_map(subject) == { 'FOO': 'bar' }


def test_load_submodules():
from jsii_calc.submodule import nested_submodule
import jsii_calc.submodule

8 changes: 8 additions & 0 deletions packages/@jsii/spec/lib/assembly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,14 @@ export interface AssemblyConfiguration extends Targetable {
* An entity on which targets may be configured.
*/
export interface Targetable {
/**
* Submodules defined in this assembly, if any, associated with their
* designated targets configuration.
*
* @default none
*/
submodules?: { [fqn: string]: { targets?: AssemblyTargets } };

/**
* A map of target name to configuration, which is used when generating
* packages for various languages.
Expand Down
6 changes: 4 additions & 2 deletions packages/jsii-pacmak/lib/targets/java.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,7 @@ class JavaGenerator extends Generator {
this.code.line(` * A fluent builder for {@link ${builtType}}.`);
this.code.line(' */');
this.emitStabilityAnnotations(cls.initializer);
this.code.openBlock(`public static final class ${BUILDER_CLASS_NAME}`);
this.code.openBlock(`public static final class ${BUILDER_CLASS_NAME} implements software.amazon.jsii.Builder<${builtType}>`);

// Static factory method(s)
for (const params of computeOverrides(positionalParams)) {
Expand Down Expand Up @@ -1247,6 +1247,7 @@ class JavaGenerator extends Generator {
this.code.line(` * @returns a newly built instance of {@link ${builtType}}.`);
this.code.line(' */');
this.emitStabilityAnnotations(cls.initializer);
this.code.line('@Override');
this.code.openBlock(`public ${builtType} build()`);
const params = cls.initializer.parameters.map(param => {
if (param === firstStruct) {
Expand Down Expand Up @@ -1322,7 +1323,7 @@ class JavaGenerator extends Generator {
this.code.line(` * A builder for {@link ${classSpec.name}}`);
this.code.line(' */');
this.emitStabilityAnnotations(classSpec);
this.code.openBlock(`public static final class ${BUILDER_CLASS_NAME}`);
this.code.openBlock(`public static final class ${BUILDER_CLASS_NAME} implements software.amazon.jsii.Builder<${classSpec.name}>`);

props.forEach(prop => this.code.line(`private ${prop.fieldJavaType} ${prop.fieldName};`));
props.forEach(prop => this.emitBuilderSetter(prop, BUILDER_CLASS_NAME, classSpec.name));
Expand All @@ -1335,6 +1336,7 @@ class JavaGenerator extends Generator {
this.code.line(' * @throws NullPointerException if any required attribute was not provided');
this.code.line(' */');
this.emitStabilityAnnotations(classSpec);
this.code.line('@Override');
this.code.openBlock(`public ${classSpec.name} build()`);

const propFields = props.map(prop => prop.fieldName).join(', ');
Expand Down
Loading

0 comments on commit fd4f17b

Please sign in to comment.