@Override protected void onSource(WithSourcesDeclaration owner, SourceDeclaration declaration) { final StereotypeModel defaultStereotype = createStereotype(declaration.getName(), sourceParent); declaration.withStereotype(defaultStereotype); addConfigRefStereoTypesIfNeeded(declaration); } };
private Optional<SourceDeclaration> findMatchingSource(WithSourcesDeclaration<?>[] containerDeclarations, Element element) { for (WithSourcesDeclaration<?> declaration : containerDeclarations) { Optional<SourceDeclaration> sourceDeclaration = declaration.getMessageSources().stream() .filter(source -> { String name = source.getName(); String elementName = element.getSimpleName().toString(); String defaultNaming = hyphenize(elementName); return name.equals(defaultNaming) || getAlias(element).map(name::equals).orElse(name.equals(elementName)); }) .findFirst(); if (sourceDeclaration.isPresent()) { return sourceDeclaration; } } return Optional.empty(); }
@Override protected void onSource(WithSourcesDeclaration owner, SourceDeclaration declaration) { final StereotypeModel defaultStereotype = createStereotype(declaration.getName(), sourceParent); ifPresent(declaration.getModelProperty(ImplementingTypeModelProperty.class) .map(ImplementingTypeModelProperty::getType) .map(declaringType -> new TypeWrapper(declaringType, typeLoader)), type -> resolveStereotype(type, declaration, defaultStereotype), () -> declaration.withStereotype(defaultStereotype)); addConfigRefStereoTypesIfNeeded(declaration); }
private void addBackPressureParameter(ExtensionDeclaration extensionDeclaration, SourceDeclaration sourceDeclaration, BackPressureStrategyModelProperty property) { ParameterDeclaration parameter = new ParameterDeclaration(BACK_PRESSURE_STRATEGY_PARAMETER_NAME); parameter.setDescription(BACK_PRESSURE_STRATEGY_PARAMETER_DESCRIPTION); parameter.setRequired(false); parameter.setDefaultValue(property.getDefaultMode()); parameter.setExpressionSupport(NOT_SUPPORTED); parameter.setLayoutModel(LayoutModel.builder().tabName(ADVANCED_TAB).build()); MetadataType type = BaseTypeBuilder.create(JAVA).stringType() .id(format("%s-%s-backPressureStrategy", extensionDeclaration.getName(), sourceDeclaration.getName())) .with(new EnumAnnotation<>(property.getSupportedModes().stream().map(BackPressureMode::name).toArray(String[]::new))) .build(); parameter.setType(type, false); sourceDeclaration.getParameterGroup(DEFAULT_GROUP_NAME).addParameter(parameter); }
private void assertHeisenbergSource(SourceDeclaration source, String sourceName, Class<? extends Source> type) { assertThat(source.getName(), is(sourceName)); List<ParameterDeclaration> parameters = source.getAllParameters(); assertThat(parameters, hasSize(31)); assertParameter(parameters, SOURCE_PARAMETER, "", INT_TYPE, true, NOT_SUPPORTED, null); assertParameter(parameters, SOURCE_CALLBACK_PARAMETER, "", toMetadataType(Long.class), false, SUPPORTED, "#[payload]"); assertParameter(parameters, SOURCE_REPEATED_CALLBACK_PARAMETER, "", STRING_TYPE, false, SUPPORTED, null); assertParameter(parameters, "methylamine", "", toMetadataType(Methylamine.class), false, SUPPORTED, null); ImplementingTypeModelProperty typeModelProperty = source.getModelProperty(ImplementingTypeModelProperty.class).get(); assertThat(typeModelProperty.getType(), equalTo(type)); }
private void assertTestModuleMessageSource(ExtensionDeclaration extensionDeclaration) throws Exception { assertThat(extensionDeclaration.getMessageSources(), hasSize(1)); SourceDeclaration source = extensionDeclaration.getMessageSources().get(0); assertThat(source.getName(), is(DEA_SOURCE_NAME)); final MetadataType outputType = source.getOutput().getType(); assertThat(outputType, is(instanceOf(ArrayType.class))); MetadataType outputMetadataType = IntrospectionUtils.getReturnType(new TypeWrapper(Object.class, TYPE_LOADER)); assertMessageType(((ArrayType) outputType).getType(), STRING_TYPE, TYPE_LOADER.load(DEAOfficerAttributes.class)); assertThat(source.getOutputAttributes().getType(), equalTo(outputMetadataType)); ConfigurationDeclaration config = extensionDeclaration.getConfigurations().get(0); assertThat(config.getMessageSources(), hasSize(3)); assertHeisenbergSource(config.getMessageSources().get(0), ASYNC_SOURCE_NAME, AsyncHeisenbergSource.class); assertHeisenbergSource(config.getMessageSources().get(1), SOURCE_NAME, HeisenbergSource.class); }
private Optional<SourceDeclaration> findMatchingSource(WithSourcesDeclaration<?>[] containerDeclarations, Element element) { for (WithSourcesDeclaration<?> declaration : containerDeclarations) { Optional<SourceDeclaration> sourceDeclaration = declaration.getMessageSources().stream() .filter(source -> { String name = source.getName(); String elementName = element.getSimpleName().toString(); String defaultNaming = hyphenize(elementName); return name.equals(defaultNaming) || getAlias(element).map(name::equals).orElse(name.equals(elementName)); }) .findFirst(); if (sourceDeclaration.isPresent()) { return sourceDeclaration; } } return Optional.empty(); }
private void addBackPressureParameter(ExtensionDeclaration extensionDeclaration, SourceDeclaration sourceDeclaration, BackPressureStrategyModelProperty property) { ParameterDeclaration parameter = new ParameterDeclaration(BACK_PRESSURE_STRATEGY_PARAMETER_NAME); parameter.setDescription(BACK_PRESSURE_STRATEGY_PARAMETER_DESCRIPTION); parameter.setRequired(false); parameter.setDefaultValue(property.getDefaultMode()); parameter.setExpressionSupport(NOT_SUPPORTED); parameter.setLayoutModel(LayoutModel.builder().tabName(ADVANCED_TAB).build()); MetadataType type = BaseTypeBuilder.create(JAVA).stringType() .id(format("%s-%s-backPressureStrategy", extensionDeclaration.getName(), sourceDeclaration.getName())) .with(new EnumAnnotation<>(property.getSupportedModes().stream().map(BackPressureMode::name).toArray(String[]::new))) .build(); parameter.setType(type, false); sourceDeclaration.getParameterGroup(DEFAULT_GROUP_NAME).addParameter(parameter); }