├── .gitignore ├── .project ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md └── SparkBuilderGeneratorPlugin ├── .classpath ├── .project ├── META-INF └── MANIFEST.MF ├── SparkBuilderGeneratorFeature ├── .project ├── build.properties └── feature.xml ├── SparkBuilderGeneratorUpdateSite ├── .project └── site.xml ├── build.properties ├── builder.md ├── dependency ├── byte-buddy-1.14.19.jar ├── byte-buddy-agent-1.14.19.jar ├── jcommander-1.60.jar ├── mockito-core-5.12.0.jar └── testng-6.11.jar ├── icons ├── builder.gif └── builder_32.gif ├── plugin.xml ├── sparkbuildergenerator.target ├── src └── com │ └── helospark │ └── spark │ └── builder │ ├── Activator.java │ ├── DiContainer.java │ ├── NamedElementWithId.java │ ├── PluginLogger.java │ ├── dialogs │ ├── RegularBuilderUserPreferenceDialog.java │ ├── StagedBuilderStagePropertyInputDialog.java │ └── domain │ │ ├── RegularBuilderDialogData.java │ │ ├── RegularBuilderFieldIncludeFieldIncludeDomain.java │ │ └── StagedBuilderStagePropertiesDialogResult.java │ ├── handlers │ ├── BuilderType.java │ ├── CompilationUnitSourceSetter.java │ ├── CurrentShellProvider.java │ ├── DialogWrapper.java │ ├── ErrorHandlerHook.java │ ├── GenerateBuilderExecutor.java │ ├── GenerateBuilderExecutorImpl.java │ ├── GenerateBuilderHandlerErrorHandlerDecorator.java │ ├── GenerateDefaultBuilderHandler.java │ ├── GenerateRegularBuilderHandler.java │ ├── GenerateStagedBuilderHandler.java │ ├── HandlerUtilWrapper.java │ ├── ImportRepository.java │ ├── IsEventOnJavaFilePredicate.java │ ├── StateInitializerGenerateBuilderExecutorDecorator.java │ ├── StatefulBean.java │ ├── StatefulBeanHandler.java │ ├── WorkingCopyManagerWrapper.java │ ├── codegenerator │ │ ├── ApplicableBuilderFieldExtractor.java │ │ ├── BuilderCompilationUnitGenerator.java │ │ ├── BuilderOwnerClassFinder.java │ │ ├── BuilderRemover.java │ │ ├── CompilationUnitParser.java │ │ ├── RegularBuilderCompilationUnitGenerator.java │ │ ├── RegularBuilderCompilationUnitGeneratorBuilderFieldCollectingDecorator.java │ │ ├── RegularBuilderUserPreferenceDialogOpener.java │ │ ├── RegularBuilderUserPreferenceProvider.java │ │ ├── StagedBuilderCompilationUnitGenerator.java │ │ ├── StagedBuilderCompilationUnitGeneratorFieldCollectorDecorator.java │ │ ├── builderfieldcollector │ │ │ ├── ClassFieldCollector.java │ │ │ ├── FieldCollectorChainItem.java │ │ │ ├── RecordFieldCollector.java │ │ │ ├── SuperClassSetterFieldCollector.java │ │ │ └── SuperConstructorParameterCollector.java │ │ ├── builderprocessor │ │ │ ├── GlobalBuilderPostProcessor.java │ │ │ └── JsonDeserializeAdder.java │ │ ├── component │ │ │ ├── BuilderAstRemover.java │ │ │ ├── DefaultConstructorAppender.java │ │ │ ├── ImportPopulator.java │ │ │ ├── PrivateInitializingConstructorCreator.java │ │ │ ├── RegularBuilderBuilderMethodCreator.java │ │ │ ├── RegularBuilderClassCreator.java │ │ │ ├── RegularBuilderCopyInstanceBuilderMethodCreator.java │ │ │ ├── StagedBuilderClassCreator.java │ │ │ ├── StagedBuilderCreationBuilderMethodAdder.java │ │ │ ├── StagedBuilderCreationWithMethodAdder.java │ │ │ ├── StagedBuilderStaticBuilderCreatorMethodCreator.java │ │ │ ├── fragment │ │ │ │ ├── builderclass │ │ │ │ │ ├── EmptyBuilderClassGeneratorFragment.java │ │ │ │ │ ├── builderclass │ │ │ │ │ │ └── JsonPOJOBuilderAdderFragment.java │ │ │ │ │ ├── buildmethod │ │ │ │ │ │ ├── BuildMethodBodyCreatorFragment.java │ │ │ │ │ │ ├── BuildMethodCreatorFragment.java │ │ │ │ │ │ └── BuildMethodDeclarationCreatorFragment.java │ │ │ │ │ ├── constructor │ │ │ │ │ ├── field │ │ │ │ │ │ ├── BuilderFieldAdderFragment.java │ │ │ │ │ │ ├── FieldDeclarationPostProcessor.java │ │ │ │ │ │ ├── FullyQualifiedNameExtractor.java │ │ │ │ │ │ ├── StaticMethodInvocationFragment.java │ │ │ │ │ │ └── chain │ │ │ │ │ │ │ ├── BuiltInCollectionsInitializerChainitem.java │ │ │ │ │ │ │ ├── FieldDeclarationPostProcessorChainItem.java │ │ │ │ │ │ │ └── OptionalInitializerChainItem.java │ │ │ │ │ ├── stagedinterface │ │ │ │ │ │ ├── StagedBuilderInterfaceCreatorFragment.java │ │ │ │ │ │ └── StagedBuilderInterfaceTypeDefinitionCreatorFragment.java │ │ │ │ │ └── withmethod │ │ │ │ │ │ ├── RegularBuilderWithMethodAdderFragment.java │ │ │ │ │ │ ├── StagedBuilderWithMethodAdderFragment.java │ │ │ │ │ │ ├── StagedBuilderWithMethodDefiniationCreatorFragment.java │ │ │ │ │ │ └── WithMethodParameterCreatorFragment.java │ │ │ │ ├── buildermethod │ │ │ │ │ ├── StaticBuilderMethodSignatureGeneratorFragment.java │ │ │ │ │ ├── copy │ │ │ │ │ │ ├── BlockWithNewCopyInstanceConstructorCreationFragment.java │ │ │ │ │ │ └── CopyInstanceBuilderMethodDefinitionCreatorFragment.java │ │ │ │ │ └── empty │ │ │ │ │ │ ├── BlockWithNewBuilderCreationFragment.java │ │ │ │ │ │ ├── BuilderMethodDefinitionCreatorFragment.java │ │ │ │ │ │ └── NewBuilderAndWithMethodCallCreationFragment.java │ │ │ │ └── constructor │ │ │ ├── helper │ │ │ │ ├── ActiveJavaEditorOffsetProvider.java │ │ │ │ ├── ApplicableFieldVisibilityFilter.java │ │ │ │ ├── BuilderMethodNameBuilder.java │ │ │ │ ├── CamelCaseConverter.java │ │ │ │ ├── CurrentlySelectedApplicableClassesClassNameProvider.java │ │ │ │ ├── FieldExtractor.java │ │ │ │ ├── FieldNameToBuilderFieldNameConverter.java │ │ │ │ ├── FieldPrefixSuffixPreferenceProvider.java │ │ │ │ ├── GeneratedAnnotationPopulator.java │ │ │ │ ├── ITypeExtractor.java │ │ │ │ ├── InterfaceSetter.java │ │ │ │ ├── IsRecordTypePredicate.java │ │ │ │ ├── IsRegularBuilderInstanceCopyEnabledPredicate.java │ │ │ │ ├── IsTypeApplicableForBuilderGenerationPredicate.java │ │ │ │ ├── JavadocAdder.java │ │ │ │ ├── JavadocGenerator.java │ │ │ │ ├── JlsVersionProvider.java │ │ │ │ ├── MarkerAnnotationAttacher.java │ │ │ │ ├── MethodExtractor.java │ │ │ │ ├── ParentITypeExtractor.java │ │ │ │ ├── PreferenceStoreProvider.java │ │ │ │ ├── PreferenceStoreWrapper.java │ │ │ │ ├── RecordDeclarationWrapper.java │ │ │ │ ├── StagedBuilderInterfaceNameProvider.java │ │ │ │ ├── StagedBuilderProperties.java │ │ │ │ ├── StagedBuilderStagePropertiesProvider.java │ │ │ │ ├── StagedBuilderStagePropertyInputDialogOpener.java │ │ │ │ ├── TemplateResolver.java │ │ │ │ ├── TypeDeclarationFromSuperclassExtractor.java │ │ │ │ ├── TypeDeclarationToVariableNameConverter.java │ │ │ │ ├── TypeExtractor.java │ │ │ │ └── domain │ │ │ │ │ ├── BodyDeclarationFinderUtil.java │ │ │ │ │ ├── BodyDeclarationVisibleFromPredicate.java │ │ │ │ │ ├── JavaVisibilityScopeModifier.java │ │ │ │ │ └── PrefixSuffixHolder.java │ │ │ └── remover │ │ │ │ ├── BuilderClassRemover.java │ │ │ │ ├── BuilderRemoverChainItem.java │ │ │ │ ├── JsonDeserializeRemover.java │ │ │ │ ├── PrivateConstructorRemover.java │ │ │ │ ├── StagedBuilderInterfaceRemover.java │ │ │ │ ├── StaticBuilderMethodRemover.java │ │ │ │ └── helper │ │ │ │ ├── BodyDeclarationOfTypeExtractor.java │ │ │ │ ├── GeneratedAnnotationContainingBodyDeclarationFilter.java │ │ │ │ ├── GeneratedAnnotationPredicate.java │ │ │ │ ├── GenericModifierPredicate.java │ │ │ │ ├── IsPackageEqualsPredicate.java │ │ │ │ ├── IsPrivatePredicate.java │ │ │ │ ├── IsPublicPredicate.java │ │ │ │ └── IsStaticPredicate.java │ │ ├── converter │ │ │ ├── RegularBuilderDialogDataConverter.java │ │ │ └── RegularBuilderUserPreferenceConverter.java │ │ └── domain │ │ │ ├── BuilderField.java │ │ │ ├── ClassFieldSetterBuilderField.java │ │ │ ├── CompilationUnitModificationDomain.java │ │ │ ├── ConstructorParameterSetterBuilderField.java │ │ │ ├── NamedVariableDeclarationField.java │ │ │ ├── RegularBuilderUserPreference.java │ │ │ ├── SuperSetterBasedBuilderField.java │ │ │ ├── ThisConstructorParameterSetterBuilderField.java │ │ │ └── instancefieldaccess │ │ │ ├── DirectFieldAccessStrategy.java │ │ │ ├── GetterFieldAccessStrategy.java │ │ │ └── InstanceFieldAccessStrategy.java │ └── exception │ │ └── PluginException.java │ └── preferences │ ├── BuilderGeneratorPreferences.java │ ├── PluginPreference.java │ ├── PluginPreferenceGroup.java │ ├── PluginPreferenceInitializer.java │ ├── PluginPreferenceList.java │ ├── PreferenceHolder.java │ ├── PreferencesManager.java │ ├── StaticPreferences.java │ └── impl │ ├── AbstractPluginPreference.java │ ├── BooleanPluginPreference.java │ ├── NamedElementListPluginPreference.java │ └── StringPluginPreference.java ├── test └── com │ └── helospark │ └── spark │ └── builder │ └── handlers │ ├── codegenerator │ └── component │ │ └── helper │ │ ├── CamelCaseConverterTest.java │ │ ├── TemplateResolverTest.java │ │ └── VariableDeclarationToFieldNameConverterIT.java │ └── it │ ├── BaseBuilderGeneratorIT.java │ ├── BuilderInstanceCopyForStagedBuilderIT.java │ ├── BuilderInstanceCopyIT.java │ ├── BuilderWithCustomMethodsIT.java │ ├── BuilderWithSuperClassDefaultFieldsE2ETest.java │ ├── BuilderWithSuperClassFieldsE2ETest.java │ ├── BuilderWithSuperClassInstanceCopyFieldsE2ETest.java │ ├── BuilderWithSuperConstructorE2ETest.java │ ├── BuilderWithSuperSetterE2ETest.java │ ├── ClassSelectionE2ETest.java │ ├── CollectionInitializingE2ETest.java │ ├── DefaultConstructorIT.java │ ├── DefaultConstructorStagedBuilderIT.java │ ├── DefaultConstructorWithRegularBuilderAndChangedDialogIT.java │ ├── DefaultPreferencesE2ETest.java │ ├── ExceptionFlowE2ETest.java │ ├── FieldAssignmentToDefaultValueIT.java │ ├── HappyFlowE2ETest.java │ ├── JacksonAnnotationWithRegularBuilderAndChangedDialogIT.java │ ├── JacksonAnnotationWithRegularBuilderIT.java │ ├── JacksonAnnotationWithStagedBuilderIT.java │ ├── JakartaAnnotationIT.java │ ├── OptionalInitializingE2ETest.java │ ├── PublicConstructorForMandatoryFieldsIT.java │ ├── RecordBuilderIT.java │ ├── RegularBuilderWithUserSelectedFieldsIT.java │ ├── StagedBuilderTest.java │ ├── StagedBuilderWithChangedDialogSettingsE2ETest.java │ ├── WrongInputE2ETest.java │ └── dummyService │ ├── FieldDeclarationAnswerProvider.java │ ├── ModifiedStagedDialogSettingsAnswerProvider.java │ ├── NoDialogOperationPerformedStagedBuilderDialogAnswerProvider.java │ ├── RegularBuilderFilterDialogAnswerProvider.java │ └── TypeExtractorAnswerProvider.java └── test_resources ├── annotated_fields_input.tjava ├── annotated_fields_output.tjava ├── annotated_fields_staged_output.tjava ├── class_with_already_generated_builder.tjava ├── class_with_already_generated_builder_and_private_method_with_generated_annotation_input.tjava ├── class_with_already_generated_builder_and_private_method_with_generated_annotation_output.tjava ├── class_with_already_generated_builder_and_private_method_without_generated_annotation_input.tjava ├── class_with_already_generated_builder_and_private_method_without_generated_annotation_output.tjava ├── class_with_collections_input.tjava ├── class_with_collections_output.tjava ├── class_with_collections_staged_builder_output.tjava ├── class_with_collections_with_turned_off_setting_output.tjava ├── custom_method ├── class_with_custom_add_method_and_helper_disabled_output.tjava ├── class_with_custom_add_method_and_helper_input.tjava ├── class_with_custom_add_method_and_helper_output.tjava ├── custom_method_that_looks_like_builder_method_input.tjava ├── custom_method_that_looks_like_builder_method_output.tjava ├── removed_fields_input.tjava ├── removed_fields_output.tjava ├── stage_build_custom_method_input.tjava ├── stage_build_custom_method_output.tjava ├── ticket_example_input.tjava └── ticket_example_output.tjava ├── default_constructor ├── base_child_input.tjava ├── base_output.tjava ├── base_super_input.tjava ├── mail_input.tjava ├── mail_input_with_existing_default_constructor.tjava ├── mail_output_with_annotated_default_constructor.tjava ├── mail_output_with_default_constructor.tjava ├── mail_output_without_default_constructor.tjava └── mail_with_staged_builder_output.tjava ├── default_value ├── regular_builder_default_value_input.tjava ├── regular_builder_default_value_output.tjava ├── regular_builder_default_value_with_disabled_option_and_enabled_empty_output.tjava ├── regular_builder_default_value_with_disabled_option_output.tjava └── staged_builder_default_value_output.tjava ├── enum_class ├── class_with_enum_between_classes_first_output.tjava ├── class_with_enum_between_classes_input.tjava ├── class_with_enum_between_classes_second_output.tjava ├── class_with_enum_input.tjava ├── class_with_enum_output.tjava ├── class_with_enum_staged_output.tjava └── file_with_only_enum_input.tjava ├── field_with_underscore_input.tjava ├── field_with_underscore_output.tjava ├── field_with_underscore_staged_output.tjava ├── import_and_package_base_output.tjava ├── import_and_package_input.tjava ├── import_and_package_output_with_nonnull.tjava ├── jackson ├── mail_input.tjava ├── mail_with_changed_build_method_output.tjava ├── mail_with_changed_builder_output.tjava ├── mail_with_changed_with_method_output.tjava ├── mail_with_default_methodnames_output.tjava ├── mail_with_no_jackson_annotations.tjava └── mail_with_staged_builder_output.tjava ├── jakarta ├── input.tjava ├── output_with_jakarta_annotations.tjava ├── output_with_javax_annotations.tjava └── output_with_no_annotations.tjava ├── mail_input.tjava ├── mail_output_with_all_preferences_enabled.tjava ├── mail_with_copy_method_output.tjava ├── mail_with_copy_method_output_when_generated_annotation_and_javadoc_is_enabled.tjava ├── mail_without_copy_method_output.tjava ├── multi_class_output_with_nested_static_class_builder.tjava ├── multi_classes_input.tjava ├── multi_classes_output_with_main_class_generated_builder.tjava ├── multi_classes_output_with_secondary_class_builder.tjava ├── multi_classes_output_with_staged_builder.tjava ├── multi_field_input.tjava ├── multi_field_output.tjava ├── multi_field_output_for_regular_builder_with_default_preferences.tjava ├── multi_field_output_for_staged_builder_with_default_preferences.tjava ├── multi_field_output_for_staged_builder_with_skipped_builder_method.tjava ├── multi_field_output_full.tjava ├── multi_field_output_with_builder_javadoc.tjava ├── multi_field_output_with_class_javadoc.tjava ├── multi_field_output_with_custom_builder_names.tjava ├── multi_field_output_with_duplicate_builder.tjava ├── multi_field_output_with_generated.tjava ├── multi_field_output_with_method_javadoc.tjava ├── multi_field_output_with_method_nonnull.tjava ├── multi_field_output_with_no_fields_included.tjava ├── multi_field_output_with_only_first_two_field_included.tjava ├── multi_field_output_with_return_nonnull.tjava ├── multi_field_output_with_templated_builder_names.tjava ├── multi_field_staged_builder_output.tjava ├── multi_field_staged_builder_output_with_leftover_generated_annotation.tjava ├── multi_field_staged_builder_output_with_reversed_order_and_optional.tjava ├── multi_field_staged_output_with_all_optional_fields.tjava ├── multi_field_staged_output_with_only_first_two_fields_selected.tjava ├── nested_class_input.tjava ├── nested_class_output_with_root_type_builder_generated.tjava ├── nested_class_output_with_second_nested_generated.tjava ├── nested_class_output_with_staged_builder_on_second_nested_class.tjava ├── no_field_input.tjava ├── no_field_output.tjava ├── no_field_staged_output.tjava ├── optional_containing_input.tjava ├── optional_containing_output.tjava ├── optional_containing_output_with_disabled_optional_initialization.tjava ├── optional_containing_staging_builder_output.tjava ├── optional_without_import_input.tjava ├── optional_without_import_output.tjava ├── prefix_input.tjava ├── prefix_output.tjava ├── prefix_suffix_input.tjava ├── prefix_suffix_output.tjava ├── primitive_field_input.tjava ├── primitive_field_output.tjava ├── primitive_field_staged_output.tjava ├── public_constructor_with_mandatory_fields ├── gh_input.tjava ├── gh_output.tjava ├── gh_output_when_all_selected.tjava └── gh_output_when_none_selected.tjava ├── record ├── record_input.tjava ├── record_output.tjava ├── record_output_staged.tjava └── record_output_with_json_annotation.tjava ├── singlefield_input.tjava ├── singlefield_output.tjava ├── singlefield_staged_output.tjava ├── static_field_input.tjava ├── static_field_output.tjava ├── static_field_output_with_staged_builder.tjava ├── suffix_input.tjava ├── suffix_output.tjava ├── super_superclass_test_input.tjava ├── superclass_instance_copy ├── 1_base_child_input.tjava ├── 1_base_output.tjava ├── 1_base_super_input.tjava ├── 2_base_child_input.tjava ├── 2_base_output.tjava ├── 2_base_super_input.tjava ├── 3_base_child_input.tjava ├── 3_base_output.tjava ├── 3_base_super_input.tjava ├── 4_base_child_input.tjava ├── 4_base_output.tjava └── 4_base_super_input.tjava ├── superclass_output.tjava ├── superclass_output_in_same_default_package.tjava ├── superclass_output_with_different_package.tjava ├── superclass_test_extends_input.tjava ├── superclass_test_extends_input_in_default_package.tjava ├── superclass_test_output_with_staged_builder.tjava ├── superclass_test_superclass_in_default_package_input.tjava ├── superclass_test_superclass_in_different_package_input.tjava ├── superclass_test_superclass_input.tjava ├── superclass_test_with_disabled_preference.tjava ├── superclass_with_constructor ├── base_child_input.tjava ├── base_output.tjava ├── base_output_staged.tjava ├── base_output_with_copy_constructor.tjava ├── base_super_input.tjava ├── class_without_parent_input.tjava ├── class_without_parent_output.tjava ├── multi_constructor_child_input.tjava ├── multi_constructor_output_with_not_prefer_empty_constructor.tjava ├── multi_constructor_output_with_prefer_empty_constructor_setting.tjava ├── multi_constructor_super_input.tjava ├── no_visible_constructor_output.tjava ├── no_visible_constructor_super_input.tjava ├── private_constructor_output.tjava ├── private_constructor_super_input.tjava ├── repro_issue_child_input.tjava ├── repro_issue_output.tjava ├── repro_issue_output_staged.tjava └── repro_issue_super_input.tjava ├── superclass_with_default_value ├── childclass.tjava ├── result.tjava ├── superclass.tjava └── supersuperclass.tjava ├── superclass_with_setter ├── 10_base_output_with_overridden_setter_output.tjava ├── 10_super_class_with_overridden_setter.tjava ├── 10_super_super_class_with_overridden_setter.tjava ├── 1_base_child_input.tjava ├── 1_base_output.tjava ├── 1_base_super_input.tjava ├── 2_base_output_with_duplicated_field.tjava ├── 2_base_super_input_with_duplicated_field.tjava ├── 3_base_output_with_two_superclass.tjava ├── 3_super_class.tjava ├── 3_super_super_class.tjava ├── 4_base_output_staged.tjava ├── 5_base_child_input_without_superclass.tjava ├── 5_base_output_without_superclass.tjava ├── 6_base_output_with_wrong_setter.tjava ├── 6_base_super_input_with_wrong_setter.tjava ├── 7_base_output_with_constructor.tjava ├── 7_base_super_input_with_constructor.tjava ├── 8_base_output_with_deduplicated_field.tjava ├── 8_base_super_input_with_constructor_and_setter.tjava └── 9_turned_off_setting_output.tjava └── superclass_with_two_superclasses_output.tjava /.gitignore: -------------------------------------------------------------------------------- 1 | .settings/ 2 | .metadata 3 | */build 4 | bin/ 5 | SparkBuilderGeneratorPlugin/SparkBuilderGeneratorUpdateSite/**/*.jar 6 | */test-output 7 | */target 8 | */test-classes 9 | .project 10 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | SparkBuilderGenerator 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Helospark 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | com.helospark.SparkBuilderPlugin 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.pde.ManifestBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.pde.SchemaBuilder 20 | 21 | 22 | 23 | 24 | 25 | org.eclipse.pde.PluginNature 26 | org.eclipse.jdt.core.javanature 27 | 28 | 29 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Bundle-ManifestVersion: 2 3 | Bundle-Name: SparkBuilderGenerator 4 | Bundle-SymbolicName: com.helospark.SparkBuilderGenerator;singleton:=true 5 | Bundle-Version: 0.0.29.qualifier 6 | Bundle-ClassPath: . 7 | Bundle-Activator: com.helospark.spark.builder.Activator 8 | Require-Bundle: org.eclipse.ui, 9 | org.eclipse.core.runtime, 10 | org.eclipse.core.resources, 11 | org.eclipse.jdt.ui, 12 | org.eclipse.jdt.core, 13 | org.eclipse.jface.text 14 | Bundle-RequiredExecutionEnvironment: JavaSE-1.8 15 | Bundle-ActivationPolicy: lazy 16 | Import-Package: org.eclipse.ui.texteditor, 17 | org.osgi.framework 18 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/SparkBuilderGeneratorFeature/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | SparkBuilderGeneratorFeature 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.pde.FeatureBuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.pde.FeatureNature 16 | 17 | 18 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/SparkBuilderGeneratorFeature/build.properties: -------------------------------------------------------------------------------- 1 | bin.includes = feature.xml 2 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/SparkBuilderGeneratorUpdateSite/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | SparkBuilderGeneratorUpdateSite 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.pde.UpdateSiteBuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.pde.UpdateSiteNature 16 | 17 | 18 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/SparkBuilderGeneratorUpdateSite/site.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Plugin to generate builder 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/build.properties: -------------------------------------------------------------------------------- 1 | source.. = src/ 2 | output.. = bin/ 3 | bin.includes = plugin.xml,\ 4 | META-INF/,\ 5 | .,\ 6 | icons/ 7 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/builder.md: -------------------------------------------------------------------------------- 1 | Moved to README.md 2 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/dependency/byte-buddy-1.14.19.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helospark/SparkBuilderGenerator/9178989b982b7ebff08cd283fb2fae1cb31afe22/SparkBuilderGeneratorPlugin/dependency/byte-buddy-1.14.19.jar -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/dependency/byte-buddy-agent-1.14.19.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helospark/SparkBuilderGenerator/9178989b982b7ebff08cd283fb2fae1cb31afe22/SparkBuilderGeneratorPlugin/dependency/byte-buddy-agent-1.14.19.jar -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/dependency/jcommander-1.60.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helospark/SparkBuilderGenerator/9178989b982b7ebff08cd283fb2fae1cb31afe22/SparkBuilderGeneratorPlugin/dependency/jcommander-1.60.jar -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/dependency/mockito-core-5.12.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helospark/SparkBuilderGenerator/9178989b982b7ebff08cd283fb2fae1cb31afe22/SparkBuilderGeneratorPlugin/dependency/mockito-core-5.12.0.jar -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/dependency/testng-6.11.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helospark/SparkBuilderGenerator/9178989b982b7ebff08cd283fb2fae1cb31afe22/SparkBuilderGeneratorPlugin/dependency/testng-6.11.jar -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/icons/builder.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helospark/SparkBuilderGenerator/9178989b982b7ebff08cd283fb2fae1cb31afe22/SparkBuilderGeneratorPlugin/icons/builder.gif -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/icons/builder_32.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helospark/SparkBuilderGenerator/9178989b982b7ebff08cd283fb2fae1cb31afe22/SparkBuilderGeneratorPlugin/icons/builder_32.gif -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/sparkbuildergenerator.target: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/NamedElementWithId.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder; 2 | 3 | /** 4 | * Element with name and Id. 5 | * @author helospark 6 | */ 7 | public interface NamedElementWithId { 8 | 9 | public String getId(); 10 | 11 | public String getDisplayName(); 12 | } 13 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/dialogs/domain/RegularBuilderFieldIncludeFieldIncludeDomain.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.dialogs.domain; 2 | 3 | /** 4 | * Holds the fields and whether they are included in the regular builder. 5 | * @author helospark 6 | */ 7 | public class RegularBuilderFieldIncludeFieldIncludeDomain { 8 | private boolean includeField; 9 | private boolean mandatory; 10 | private String fieldName; 11 | 12 | public RegularBuilderFieldIncludeFieldIncludeDomain(boolean includeField, boolean mandatory, String fieldName) { 13 | this.includeField = includeField; 14 | this.mandatory = mandatory; 15 | this.fieldName = fieldName; 16 | } 17 | 18 | public boolean isIncludeField() { 19 | return includeField; 20 | } 21 | 22 | public void setIncludeField(boolean includeField) { 23 | this.includeField = includeField; 24 | } 25 | 26 | public String getFieldName() { 27 | return fieldName; 28 | } 29 | 30 | public void setFieldName(String fieldName) { 31 | this.fieldName = fieldName; 32 | } 33 | 34 | public boolean isMandatory() { 35 | return mandatory; 36 | } 37 | 38 | public void setMandatory(boolean mandatory) { 39 | this.mandatory = mandatory; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/dialogs/domain/StagedBuilderStagePropertiesDialogResult.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.dialogs.domain; 2 | 3 | /** 4 | * Result of the staged builder property change dialog. 5 | * @author helospark 6 | */ 7 | public class StagedBuilderStagePropertiesDialogResult { 8 | private boolean mandatory; 9 | private String fieldName; 10 | private int originalIndex; 11 | 12 | public StagedBuilderStagePropertiesDialogResult(boolean isMandatory, String fieldName, int originalIndex) { 13 | this.mandatory = isMandatory; 14 | this.fieldName = fieldName; 15 | this.originalIndex = originalIndex; 16 | } 17 | 18 | public boolean isMandatory() { 19 | return mandatory; 20 | } 21 | 22 | public void setMandatory(boolean selected) { 23 | this.mandatory = selected; 24 | } 25 | 26 | public String getFieldName() { 27 | return fieldName; 28 | } 29 | 30 | public void setFieldName(String fieldName) { 31 | this.fieldName = fieldName; 32 | } 33 | 34 | public int getOriginalIndex() { 35 | return originalIndex; 36 | } 37 | 38 | public void setOriginalIndex(int originalIndex) { 39 | this.originalIndex = originalIndex; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/BuilderType.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers; 2 | 3 | import java.util.Arrays; 4 | 5 | import com.helospark.spark.builder.NamedElementWithId; 6 | 7 | /** 8 | * Enum for all builder types this builder can generate. 9 | * @author helospark 10 | */ 11 | public enum BuilderType implements NamedElementWithId { 12 | REGULAR("regularBuilder", "Regular builder"), 13 | STAGED("stagedBuilder", "Staged builder"); 14 | 15 | private String id; 16 | private String displayName; 17 | 18 | BuilderType(String id, String displayName) { 19 | this.id = id; 20 | this.displayName = displayName; 21 | } 22 | 23 | @Override 24 | public String getId() { 25 | return id; 26 | } 27 | 28 | @Override 29 | public String getDisplayName() { 30 | return displayName; 31 | } 32 | 33 | public BuilderType getFromId(String id) { 34 | return Arrays.stream(values()) 35 | .filter(e -> e.getId().equals(id)) 36 | .findFirst() 37 | .orElseThrow(() -> new IllegalArgumentException("Cannot find enum with value " + id)); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/CompilationUnitSourceSetter.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers; 2 | 3 | import org.eclipse.jdt.core.ICompilationUnit; 4 | import org.eclipse.jdt.core.dom.rewrite.ASTRewrite; 5 | import org.eclipse.jface.text.Document; 6 | import org.eclipse.text.edits.TextEdit; 7 | 8 | /** 9 | * Sets the changed source to the compilation unit. 10 | * @author helospark 11 | */ 12 | public class CompilationUnitSourceSetter { 13 | 14 | public void commitCodeChange(ICompilationUnit iCompilationUnit, ASTRewrite rewriter) { 15 | try { 16 | Document document = new Document(iCompilationUnit.getSource()); 17 | TextEdit edits = rewriter.rewriteAST(document, null); 18 | edits.apply(document); 19 | iCompilationUnit.getBuffer().setContents(document.get()); 20 | } catch (Exception e) { 21 | throw new RuntimeException(e); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/CurrentShellProvider.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers; 2 | 3 | import org.eclipse.swt.widgets.Shell; 4 | import org.eclipse.ui.PlatformUI; 5 | 6 | public class CurrentShellProvider { 7 | 8 | public Shell provideCurrentShell() { 9 | return PlatformUI.getWorkbench().getDisplay().getActiveShell(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/GenerateBuilderExecutor.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers; 2 | 3 | import org.eclipse.core.commands.ExecutionEvent; 4 | import org.eclipse.core.commands.ExecutionException; 5 | 6 | /** 7 | * Generates a builder with the given type. 8 | * @author helospark 9 | */ 10 | public interface GenerateBuilderExecutor { 11 | 12 | void execute(ExecutionEvent event, BuilderType staged) throws ExecutionException; 13 | 14 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/GenerateBuilderHandlerErrorHandlerDecorator.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers; 2 | 3 | import org.eclipse.core.commands.ExecutionEvent; 4 | import org.eclipse.core.commands.ExecutionException; 5 | 6 | import com.helospark.spark.builder.handlers.exception.PluginException; 7 | 8 | /** 9 | * Adds error handling to the builder generator. 10 | * @author helospark 11 | */ 12 | public class GenerateBuilderHandlerErrorHandlerDecorator implements GenerateBuilderExecutor { 13 | private GenerateBuilderExecutor generateBuilderHandlerDelegate; 14 | private ErrorHandlerHook errorHandlerHook; 15 | 16 | public GenerateBuilderHandlerErrorHandlerDecorator(GenerateBuilderExecutor generateBuilderHandlerDelegate, 17 | ErrorHandlerHook errorHandlerHook) { 18 | this.generateBuilderHandlerDelegate = generateBuilderHandlerDelegate; 19 | this.errorHandlerHook = errorHandlerHook; 20 | } 21 | 22 | @Override 23 | public void execute(ExecutionEvent event, BuilderType builderType) throws ExecutionException { 24 | try { 25 | generateBuilderHandlerDelegate.execute(event, builderType); 26 | } catch (PluginException e) { 27 | errorHandlerHook.onPluginException(e); 28 | } catch (Throwable e) { 29 | errorHandlerHook.onUnexpectedException(e); 30 | throw new RuntimeException(e.getMessage(), e); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/GenerateRegularBuilderHandler.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers; 2 | 3 | import org.eclipse.core.commands.AbstractHandler; 4 | import org.eclipse.core.commands.ExecutionEvent; 5 | import org.eclipse.core.commands.ExecutionException; 6 | 7 | import com.helospark.spark.builder.DiContainer; 8 | 9 | /** 10 | * Eclipse handler to generate regular builder. 11 | * @author helospark 12 | */ 13 | public class GenerateRegularBuilderHandler extends AbstractHandler { 14 | private GenerateBuilderExecutor generateBuilderExecutor; 15 | 16 | public GenerateRegularBuilderHandler() { 17 | this(DiContainer.getDependency(StateInitializerGenerateBuilderExecutorDecorator.class)); 18 | } 19 | 20 | public GenerateRegularBuilderHandler(GenerateBuilderExecutor generateBuilderExecutor) { 21 | this.generateBuilderExecutor = generateBuilderExecutor; 22 | } 23 | 24 | @Override 25 | public Object execute(ExecutionEvent event) throws ExecutionException { 26 | generateBuilderExecutor.execute(event, BuilderType.REGULAR); 27 | return null; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/GenerateStagedBuilderHandler.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers; 2 | 3 | import org.eclipse.core.commands.AbstractHandler; 4 | import org.eclipse.core.commands.ExecutionEvent; 5 | import org.eclipse.core.commands.ExecutionException; 6 | 7 | import com.helospark.spark.builder.DiContainer; 8 | 9 | public class GenerateStagedBuilderHandler extends AbstractHandler { 10 | private GenerateBuilderExecutor generateBuilderExecutor; 11 | 12 | public GenerateStagedBuilderHandler() { 13 | this(DiContainer.getDependency(StateInitializerGenerateBuilderExecutorDecorator.class)); 14 | } 15 | 16 | public GenerateStagedBuilderHandler(GenerateBuilderExecutor generateBuilderExecutor) { 17 | this.generateBuilderExecutor = generateBuilderExecutor; 18 | } 19 | 20 | @Override 21 | public Object execute(ExecutionEvent event) throws ExecutionException { 22 | generateBuilderExecutor.execute(event, BuilderType.STAGED); 23 | return null; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/HandlerUtilWrapper.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers; 2 | 3 | import org.eclipse.core.commands.ExecutionEvent; 4 | import org.eclipse.ui.IEditorPart; 5 | import org.eclipse.ui.handlers.HandlerUtil; 6 | 7 | public class HandlerUtilWrapper { 8 | 9 | public IEditorPart getActiveEditor(ExecutionEvent event) { 10 | return HandlerUtil.getActiveEditor(event); 11 | } 12 | 13 | public String getActivePartId(ExecutionEvent event) { 14 | return HandlerUtil.getActivePartId(event); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/ImportRepository.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers; 2 | 3 | import java.util.Collection; 4 | import java.util.HashSet; 5 | import java.util.Set; 6 | import java.util.concurrent.ConcurrentSkipListSet; 7 | 8 | /** 9 | * Stateful bean to contain required import during the current builder's generation. 10 | * Note: Since it is stateful, use with care. 11 | * @author helospark 12 | */ 13 | public class ImportRepository implements StatefulBean { 14 | private Set imports = new ConcurrentSkipListSet<>(); 15 | 16 | @Override 17 | public void clearState() { 18 | imports.clear(); 19 | } 20 | 21 | public void addImport(String importToAdd) { 22 | imports.add(importToAdd); 23 | } 24 | 25 | public void addImports(Collection importsToAdd) { 26 | imports.addAll(importsToAdd); 27 | } 28 | 29 | public Set queryImports() { 30 | return new HashSet<>(imports); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/IsEventOnJavaFilePredicate.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers; 2 | 3 | import java.util.function.Predicate; 4 | 5 | import org.eclipse.core.commands.ExecutionEvent; 6 | 7 | /** 8 | * Predicate to check if the given event is occurred while in an active Java editor. 9 | * @author helospark 10 | */ 11 | public class IsEventOnJavaFilePredicate implements Predicate { 12 | private static final String JAVA_TYPE = "org.eclipse.jdt.ui.CompilationUnitEditor"; 13 | private HandlerUtilWrapper handlerUtilWrapper; 14 | 15 | public IsEventOnJavaFilePredicate(HandlerUtilWrapper handlerUtilWrapper) { 16 | this.handlerUtilWrapper = handlerUtilWrapper; 17 | } 18 | 19 | @Override 20 | public boolean test(ExecutionEvent event) { 21 | String activePartId = handlerUtilWrapper.getActivePartId(event); 22 | return JAVA_TYPE.equals(activePartId); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/StateInitializerGenerateBuilderExecutorDecorator.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers; 2 | 3 | import org.eclipse.core.commands.ExecutionEvent; 4 | import org.eclipse.core.commands.ExecutionException; 5 | 6 | /** 7 | * Decorator to initialize plugin state when an event occurres. 8 | * @deprecated builder generator should be stateless eventually, at that point this can be deleted 9 | * @author helospark 10 | */ 11 | @Deprecated 12 | public class StateInitializerGenerateBuilderExecutorDecorator implements GenerateBuilderExecutor { 13 | private GenerateBuilderExecutor delegate; 14 | private StatefulBeanHandler statefulBeanHandler; 15 | 16 | public StateInitializerGenerateBuilderExecutorDecorator(GenerateBuilderExecutor delegate, 17 | StatefulBeanHandler statefulBeanHandler) { 18 | this.delegate = delegate; 19 | this.statefulBeanHandler = statefulBeanHandler; 20 | } 21 | 22 | @Override 23 | public void execute(ExecutionEvent event, BuilderType builderType) throws ExecutionException { 24 | statefulBeanHandler.initializeState(event); 25 | try { 26 | delegate.execute(event, builderType); 27 | } finally { 28 | statefulBeanHandler.clearState(); 29 | } 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/StatefulBean.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers; 2 | 3 | /** 4 | * Marker interface for all stateful beans. 5 | * WARNING: Be careful with these in multithreaded environment. 6 | * @author helospark 7 | */ 8 | public interface StatefulBean { 9 | 10 | public void clearState(); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/StatefulBeanHandler.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers; 2 | 3 | import org.eclipse.core.commands.ExecutionEvent; 4 | import org.eclipse.jdt.core.ICompilationUnit; 5 | 6 | import com.helospark.spark.builder.handlers.codegenerator.component.helper.PreferenceStoreProvider; 7 | 8 | /** 9 | * Initializes stateful beans. 10 | * @deprecated There should not be stateful beans 11 | * @author helospark 12 | */ 13 | @Deprecated 14 | public class StatefulBeanHandler { 15 | private PreferenceStoreProvider preferenceStoreProvider; 16 | private WorkingCopyManagerWrapper workingCopyManagerWrapper; 17 | private ImportRepository importRepository; 18 | 19 | public StatefulBeanHandler(PreferenceStoreProvider preferenceStoreProvider, WorkingCopyManagerWrapper workingCopyManagerWrapper, 20 | ImportRepository importRepository) { 21 | this.preferenceStoreProvider = preferenceStoreProvider; 22 | this.workingCopyManagerWrapper = workingCopyManagerWrapper; 23 | this.importRepository = importRepository; 24 | } 25 | 26 | public void initializeState(ExecutionEvent executionEvent) { 27 | ICompilationUnit iCompilationUnit = workingCopyManagerWrapper.getCurrentCompilationUnit(executionEvent); 28 | preferenceStoreProvider.setJavaProject(iCompilationUnit.getJavaProject()); 29 | importRepository.clearState(); 30 | } 31 | 32 | public void clearState() { 33 | preferenceStoreProvider.clearState(); 34 | importRepository.clearState(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/WorkingCopyManagerWrapper.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers; 2 | 3 | import org.eclipse.core.commands.ExecutionEvent; 4 | import org.eclipse.jdt.core.ICompilationUnit; 5 | import org.eclipse.jdt.ui.IWorkingCopyManager; 6 | import org.eclipse.jdt.ui.JavaUI; 7 | import org.eclipse.ui.IEditorPart; 8 | 9 | public class WorkingCopyManagerWrapper { 10 | private HandlerUtilWrapper handlerUtilWrapper; 11 | 12 | public WorkingCopyManagerWrapper(HandlerUtilWrapper handlerUtilWrapper) { 13 | this.handlerUtilWrapper = handlerUtilWrapper; 14 | } 15 | 16 | public ICompilationUnit getCurrentCompilationUnit(ExecutionEvent event) { 17 | IEditorPart editor = handlerUtilWrapper.getActiveEditor(event); 18 | IWorkingCopyManager manager = JavaUI.getWorkingCopyManager(); 19 | return manager.getWorkingCopy(editor.getEditorInput()); 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/codegenerator/BuilderCompilationUnitGenerator.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers.codegenerator; 2 | 3 | import com.helospark.spark.builder.handlers.BuilderType; 4 | import com.helospark.spark.builder.handlers.codegenerator.domain.CompilationUnitModificationDomain; 5 | 6 | /** 7 | * Generates the builder to the given compilation unit. 8 | * @author helospark 9 | */ 10 | public interface BuilderCompilationUnitGenerator { 11 | 12 | void generateBuilder(CompilationUnitModificationDomain compilationUnitModificationDomain); 13 | 14 | boolean canHandle(BuilderType builderType); 15 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/codegenerator/CompilationUnitParser.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers.codegenerator; 2 | 3 | import org.eclipse.jdt.core.IClassFile; 4 | import org.eclipse.jdt.core.ICompilationUnit; 5 | import org.eclipse.jdt.core.dom.ASTParser; 6 | import org.eclipse.jdt.core.dom.CompilationUnit; 7 | 8 | import com.helospark.spark.builder.handlers.codegenerator.component.helper.JlsVersionProvider; 9 | 10 | /** 11 | * Parses ICompilation unit to CompilationUnit. 12 | * 13 | * @author helospark 14 | */ 15 | public class CompilationUnitParser { 16 | 17 | public CompilationUnit parse(ICompilationUnit unit) { 18 | ASTParser parser = ASTParser.newParser(JlsVersionProvider.getLatestJlsVersion()); 19 | parser.setKind(ASTParser.K_COMPILATION_UNIT); 20 | parser.setSource(unit); 21 | parser.setResolveBindings(true); 22 | parser.setProject(unit.getJavaProject()); 23 | parser.setUnitName(unit.getPath().toString()); 24 | return (CompilationUnit) parser.createAST(null); 25 | } 26 | 27 | public CompilationUnit parse(IClassFile classFile) { 28 | ASTParser parser = ASTParser.newParser(JlsVersionProvider.getLatestJlsVersion()); 29 | parser.setSource(classFile); 30 | parser.setKind(ASTParser.K_COMPILATION_UNIT); 31 | parser.setResolveBindings(true); 32 | return (CompilationUnit) parser.createAST(null); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/codegenerator/RegularBuilderUserPreferenceDialogOpener.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers.codegenerator; 2 | 3 | import java.util.Optional; 4 | 5 | import org.eclipse.swt.widgets.Shell; 6 | 7 | import com.helospark.spark.builder.dialogs.RegularBuilderUserPreferenceDialog; 8 | import com.helospark.spark.builder.dialogs.domain.RegularBuilderDialogData; 9 | import com.helospark.spark.builder.handlers.CurrentShellProvider; 10 | 11 | /** 12 | * Opens the dialog that filter the fields to include in the builder. 13 | * @author helospark 14 | */ 15 | public class RegularBuilderUserPreferenceDialogOpener { 16 | private CurrentShellProvider currentShellProvider; 17 | 18 | public RegularBuilderUserPreferenceDialogOpener(CurrentShellProvider currentShellProvider) { 19 | this.currentShellProvider = currentShellProvider; 20 | } 21 | 22 | public Optional open(RegularBuilderDialogData regularBuilderDialogData) { 23 | Shell shell = currentShellProvider.provideCurrentShell(); 24 | RegularBuilderUserPreferenceDialog dialog = new RegularBuilderUserPreferenceDialog(shell, regularBuilderDialogData); 25 | RegularBuilderDialogData result = (RegularBuilderDialogData) dialog.open(); 26 | return Optional.ofNullable(result); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/codegenerator/builderfieldcollector/FieldCollectorChainItem.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers.codegenerator.builderfieldcollector; 2 | 3 | import java.util.List; 4 | 5 | import org.eclipse.jdt.core.dom.AbstractTypeDeclaration; 6 | 7 | import com.helospark.spark.builder.handlers.codegenerator.domain.BuilderField; 8 | 9 | /** 10 | * Common interface to collect fields for the builder. 11 | * @author helospark 12 | */ 13 | public interface FieldCollectorChainItem { 14 | 15 | /** 16 | * Collect field for type. 17 | * @param AbstractTypeDeclaration to collect fields from 18 | * @return collected fields 19 | */ 20 | public List collect(AbstractTypeDeclaration typeDeclaration); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/codegenerator/builderprocessor/GlobalBuilderPostProcessor.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers.codegenerator.builderprocessor; 2 | 3 | import static com.helospark.spark.builder.preferences.PluginPreferenceList.ADD_JACKSON_DESERIALIZE_ANNOTATION; 4 | 5 | import org.eclipse.jdt.core.dom.TypeDeclaration; 6 | 7 | import com.helospark.spark.builder.handlers.codegenerator.domain.CompilationUnitModificationDomain; 8 | import com.helospark.spark.builder.preferences.PreferencesManager; 9 | 10 | /** 11 | * Post process compilation unit, after the builder class is already added. 12 | * @author helospark 13 | */ 14 | public class GlobalBuilderPostProcessor { 15 | private PreferencesManager preferencesManager; 16 | private JsonDeserializeAdder jsonDeserializeAdder; 17 | 18 | public GlobalBuilderPostProcessor(PreferencesManager preferencesManager, JsonDeserializeAdder jsonDeserializeAdder) { 19 | this.preferencesManager = preferencesManager; 20 | this.jsonDeserializeAdder = jsonDeserializeAdder; 21 | } 22 | 23 | public void postProcessBuilder(CompilationUnitModificationDomain compilationUnitModificationDomain, TypeDeclaration builderType) { 24 | if (preferencesManager.getPreferenceValue(ADD_JACKSON_DESERIALIZE_ANNOTATION)) { 25 | jsonDeserializeAdder.addJsonDeserializeAnnotation(compilationUnitModificationDomain, builderType); 26 | } 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/codegenerator/component/BuilderAstRemover.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers.codegenerator.component; 2 | 3 | import java.util.List; 4 | 5 | import org.eclipse.jdt.core.dom.AbstractTypeDeclaration; 6 | import org.eclipse.jdt.core.dom.CompilationUnit; 7 | import org.eclipse.jdt.core.dom.rewrite.ASTRewrite; 8 | 9 | import com.helospark.spark.builder.handlers.codegenerator.component.remover.BuilderRemoverChainItem; 10 | import com.helospark.spark.builder.handlers.codegenerator.domain.CompilationUnitModificationDomain; 11 | 12 | /** 13 | * Tries to remove the (earlier generated) builder from the given compilation unit. 14 | * @author helospark 15 | */ 16 | public class BuilderAstRemover { 17 | private List builderRemovers; 18 | 19 | public BuilderAstRemover(List builderRemovers) { 20 | this.builderRemovers = builderRemovers; 21 | } 22 | 23 | public void removeBuilder(ASTRewrite rewriter, CompilationUnit compilationUnit, CompilationUnitModificationDomain modificationDomain) { 24 | AbstractTypeDeclaration type = modificationDomain.getOriginalType(); 25 | builderRemovers.stream().forEach(remover -> remover.remove(rewriter, type, modificationDomain)); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/codegenerator/component/fragment/builderclass/constructor/PrivateConstructorAdderFragment.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers.codegenerator.component.fragment.builderclass.constructor; 2 | 3 | import org.eclipse.jdt.core.dom.AST; 4 | import org.eclipse.jdt.core.dom.MethodDeclaration; 5 | import org.eclipse.jdt.core.dom.Modifier.ModifierKeyword; 6 | import org.eclipse.jdt.core.dom.TypeDeclaration; 7 | 8 | /** 9 | * Fragment to add empty private constructor to the builder. 10 | * Generated code is something like: 11 | *
12 |  * private Clazz() {
13 |  * }
14 |  * 
15 | * @author helospark 16 | */ 17 | public class PrivateConstructorAdderFragment { 18 | 19 | public void addEmptyPrivateConstructor(AST ast, TypeDeclaration builderType) { 20 | MethodDeclaration privateConstructorMethod = ast.newMethodDeclaration(); 21 | privateConstructorMethod.setBody(ast.newBlock()); 22 | privateConstructorMethod.setConstructor(true); 23 | privateConstructorMethod.setName(ast.newSimpleName(builderType.getName().toString())); 24 | privateConstructorMethod.modifiers().add(ast.newModifier(ModifierKeyword.PRIVATE_KEYWORD)); 25 | builderType.bodyDeclarations().add(privateConstructorMethod); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/codegenerator/component/fragment/builderclass/field/StaticMethodInvocationFragment.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers.codegenerator.component.fragment.builderclass.field; 2 | 3 | import org.eclipse.jdt.core.dom.AST; 4 | import org.eclipse.jdt.core.dom.MethodInvocation; 5 | import org.eclipse.jdt.core.dom.SimpleName; 6 | 7 | /** 8 | * Creates a static method invocation. 9 | * Note that import is not added by this fragment. 10 | * @author helospark 11 | */ 12 | public class StaticMethodInvocationFragment { 13 | 14 | public MethodInvocation createStaticMethodInvocation(AST ast, String className, String methodName) { 15 | SimpleName typeName = ast.newSimpleName(className); 16 | 17 | MethodInvocation methodInvocation = ast.newMethodInvocation(); 18 | methodInvocation.setName(ast.newSimpleName(methodName)); 19 | methodInvocation.setExpression(typeName); 20 | 21 | return methodInvocation; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/codegenerator/component/fragment/builderclass/field/chain/FieldDeclarationPostProcessorChainItem.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers.codegenerator.component.fragment.builderclass.field.chain; 2 | 3 | import java.util.List; 4 | 5 | import org.eclipse.jdt.core.dom.AST; 6 | import org.eclipse.jdt.core.dom.Expression; 7 | 8 | public interface FieldDeclarationPostProcessorChainItem { 9 | 10 | public boolean doesSupport(String fullyQualifiedName); 11 | 12 | public Expression createExpression(AST ast, String fullyQualifiedName); 13 | 14 | public List getImport(String fullyQualifiedName); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/codegenerator/component/fragment/builderclass/stagedinterface/StagedBuilderInterfaceTypeDefinitionCreatorFragment.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers.codegenerator.component.fragment.builderclass.stagedinterface; 2 | 3 | import org.eclipse.jdt.core.dom.AST; 4 | import org.eclipse.jdt.core.dom.Modifier.ModifierKeyword; 5 | import org.eclipse.jdt.core.dom.TypeDeclaration; 6 | 7 | import com.helospark.spark.builder.handlers.codegenerator.component.helper.JavadocAdder; 8 | 9 | /** 10 | * Creates the interface definition for the staged builder's stage. 11 | * Generated code is something like: 12 | *
13 |  * public interface IFirstStage;
14 |  * 
15 | * @author helospark 16 | */ 17 | public class StagedBuilderInterfaceTypeDefinitionCreatorFragment { 18 | private JavadocAdder javadocAdder; 19 | 20 | public StagedBuilderInterfaceTypeDefinitionCreatorFragment(JavadocAdder javadocAdder) { 21 | this.javadocAdder = javadocAdder; 22 | } 23 | 24 | public TypeDeclaration createStageBuilderInterface(AST ast, String interfaceName) { 25 | TypeDeclaration addedInterface = ast.newTypeDeclaration(); 26 | addedInterface.setInterface(true); 27 | addedInterface.setName(ast.newSimpleName(interfaceName)); 28 | addedInterface.modifiers().add(ast.newModifier(ModifierKeyword.PUBLIC_KEYWORD)); 29 | javadocAdder.addJavadocForStagedInterface(ast, interfaceName, addedInterface); 30 | return addedInterface; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/codegenerator/component/fragment/buildermethod/empty/BlockWithNewBuilderCreationFragment.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers.codegenerator.component.fragment.buildermethod.empty; 2 | 3 | import org.eclipse.jdt.core.dom.AST; 4 | import org.eclipse.jdt.core.dom.Block; 5 | import org.eclipse.jdt.core.dom.ClassInstanceCreation; 6 | import org.eclipse.jdt.core.dom.ReturnStatement; 7 | import org.eclipse.jdt.core.dom.TypeDeclaration; 8 | 9 | /** 10 | * Creates a block which creates a builder, generated code is something like: 11 | *
12 |  * return new Builder();
13 |  * 
14 | * @author helospark 15 | */ 16 | public class BlockWithNewBuilderCreationFragment { 17 | 18 | public Block createReturnBlock(AST ast, TypeDeclaration builderType) { 19 | Block builderMethodBlock = ast.newBlock(); 20 | ReturnStatement returnStatement = ast.newReturnStatement(); 21 | ClassInstanceCreation newClassInstanceCreation = ast.newClassInstanceCreation(); 22 | newClassInstanceCreation.setType(ast.newSimpleType(ast.newName(builderType.getName().toString()))); 23 | returnStatement.setExpression(newClassInstanceCreation); 24 | builderMethodBlock.statements().add(returnStatement); 25 | return builderMethodBlock; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/codegenerator/component/fragment/constructor/BuilderFieldAccessCreatorFragment.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers.codegenerator.component.fragment.constructor; 2 | 3 | import org.eclipse.jdt.core.dom.AST; 4 | import org.eclipse.jdt.core.dom.FieldAccess; 5 | 6 | import com.helospark.spark.builder.handlers.codegenerator.domain.BuilderField; 7 | 8 | /** 9 | * Creates an access of the field in the builder. 10 | *
11 |  * builderName.fieldName;
12 |  * 
13 | * 14 | * @author helospark 15 | */ 16 | public class BuilderFieldAccessCreatorFragment { 17 | 18 | public FieldAccess createBuilderFieldAccess(AST ast, String builderName, BuilderField field) { 19 | FieldAccess builderFieldAccess = ast.newFieldAccess(); 20 | builderFieldAccess.setExpression(ast.newSimpleName(builderName)); 21 | builderFieldAccess.setName(ast.newSimpleName(field.getOriginalFieldName())); 22 | return builderFieldAccess; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/codegenerator/component/fragment/constructor/ConstructorInsertionFragment.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers.codegenerator.component.fragment.constructor; 2 | 3 | import org.eclipse.jdt.core.dom.AbstractTypeDeclaration; 4 | import org.eclipse.jdt.core.dom.FieldDeclaration; 5 | import org.eclipse.jdt.core.dom.MethodDeclaration; 6 | import org.eclipse.jdt.core.dom.rewrite.ListRewrite; 7 | 8 | import com.helospark.spark.builder.handlers.codegenerator.component.helper.FieldExtractor; 9 | 10 | /** 11 | * Insert constructor after fields, but before methods. 12 | * @author helospark 13 | */ 14 | public class ConstructorInsertionFragment { 15 | public void insertMethodToFirstPlace(AbstractTypeDeclaration originalType, ListRewrite listRewrite, MethodDeclaration constructor) { 16 | FieldDeclaration[] fields = FieldExtractor.getFields(originalType); 17 | if (fields == null || fields.length == 0) { 18 | listRewrite.insertFirst(constructor, null); 19 | } else { 20 | listRewrite.insertAfter(constructor, fields[fields.length - 1], null); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/codegenerator/component/helper/ActiveJavaEditorOffsetProvider.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers.codegenerator.component.helper; 2 | 3 | import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor; 4 | import org.eclipse.jface.text.ITextSelection; 5 | import org.eclipse.jface.viewers.ISelection; 6 | import org.eclipse.ui.IEditorPart; 7 | import org.eclipse.ui.IWorkbenchPage; 8 | import org.eclipse.ui.PlatformUI; 9 | 10 | /** 11 | * Provides the offset of the cursor from the beginning of the document in the currently active Java editor. 12 | * @author helospark 13 | */ 14 | public class ActiveJavaEditorOffsetProvider { 15 | 16 | public int provideOffsetOfCurrentCursorPosition() { 17 | IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); 18 | IEditorPart activeEditor = page.getActiveEditor(); 19 | if (activeEditor instanceof JavaEditor) { 20 | JavaEditor javaEditor = (JavaEditor) activeEditor; 21 | ISelection selection = javaEditor.getSelectionProvider().getSelection(); 22 | if (selection instanceof ITextSelection) { 23 | ITextSelection iTextSelection = (ITextSelection) selection; 24 | return iTextSelection.getOffset(); 25 | } 26 | } 27 | return 0; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/codegenerator/component/helper/BuilderMethodNameBuilder.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers.codegenerator.component.helper; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import com.helospark.spark.builder.preferences.PluginPreferenceList; 7 | import com.helospark.spark.builder.preferences.PreferencesManager; 8 | 9 | /** 10 | * Creates the builder classes's method names. 11 | * 12 | * @author helospark 13 | */ 14 | public class BuilderMethodNameBuilder { 15 | private CamelCaseConverter camelCaseConverter; 16 | private PreferencesManager preferencesManager; 17 | private TemplateResolver templateResolver; 18 | 19 | public BuilderMethodNameBuilder(CamelCaseConverter camelCaseConverter, PreferencesManager preferencesManager, 20 | TemplateResolver templateResolver) { 21 | this.camelCaseConverter = camelCaseConverter; 22 | this.preferencesManager = preferencesManager; 23 | this.templateResolver = templateResolver; 24 | } 25 | 26 | public String build(String fieldName) { 27 | Map replacements = new HashMap<>(); 28 | replacements.put("fieldName", fieldName); 29 | replacements.put("FieldName", camelCaseConverter.toUpperCamelCase(fieldName)); 30 | String name = preferencesManager.getPreferenceValue(PluginPreferenceList.BUILDERS_METHOD_NAME_PATTERN); 31 | return templateResolver.resolveTemplate(name, replacements); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/codegenerator/component/helper/CamelCaseConverter.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers.codegenerator.component.helper; 2 | 3 | public class CamelCaseConverter { 4 | 5 | public String toUpperCamelCase(String variableName) { 6 | if (variableName == null || variableName.length() <= 1) { 7 | return variableName; 8 | } 9 | return String.valueOf(Character.toUpperCase(variableName.charAt(0))) + variableName.substring(1); 10 | } 11 | 12 | public String toLowerCamelCase(String variableName) { 13 | if (variableName == null || variableName.length() <= 1) { 14 | return variableName; 15 | } 16 | return String.valueOf(Character.toLowerCase(variableName.charAt(0))) + variableName.substring(1); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/codegenerator/component/helper/FieldExtractor.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers.codegenerator.component.helper; 2 | 3 | import org.eclipse.jdt.core.dom.AbstractTypeDeclaration; 4 | import org.eclipse.jdt.core.dom.FieldDeclaration; 5 | import org.eclipse.jdt.core.dom.TypeDeclaration; 6 | 7 | /** 8 | * Get fields declared by this AbstractTypeDeclaration. 9 | * @author helospark 10 | */ 11 | public class FieldExtractor { 12 | 13 | public static FieldDeclaration[] getFields(AbstractTypeDeclaration mainType) { 14 | if (mainType.getClass() == TypeDeclaration.class) { 15 | return ((TypeDeclaration) mainType).getFields(); 16 | } else if (IsRecordTypePredicate.isRecordDeclaration(mainType)) { 17 | return RecordDeclarationWrapper.of(mainType).getFields(); 18 | } else { 19 | return new FieldDeclaration[0]; 20 | } 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/codegenerator/component/helper/ITypeExtractor.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers.codegenerator.component.helper; 2 | 3 | import java.util.Optional; 4 | 5 | import org.eclipse.jdt.core.IType; 6 | import org.eclipse.jdt.core.dom.AbstractTypeDeclaration; 7 | 8 | /** 9 | * Extracts IType from the given AbstractTypeDeclaration. 10 | * @author helospark 11 | */ 12 | public class ITypeExtractor { 13 | 14 | public Optional extract(AbstractTypeDeclaration typeDeclaration) { 15 | return Optional.ofNullable(typeDeclaration.resolveBinding()) 16 | .map(binding -> binding.getSuperclass()) 17 | .map(superclass -> superclass.getJavaElement()) 18 | .filter(javaElement -> javaElement instanceof IType) 19 | .map(javaElement -> (IType) javaElement); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/codegenerator/component/helper/InterfaceSetter.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers.codegenerator.component.helper; 2 | 3 | import org.eclipse.jdt.core.dom.AST; 4 | import org.eclipse.jdt.core.dom.AbstractTypeDeclaration; 5 | import org.eclipse.jdt.core.dom.SimpleType; 6 | import org.eclipse.jdt.core.dom.TypeDeclaration; 7 | 8 | /** 9 | * Sets the given interface to the given type as a superinterface. 10 | * @author helospark 11 | */ 12 | public class InterfaceSetter { 13 | 14 | public void setInterface(AST ast, AbstractTypeDeclaration type, TypeDeclaration interfaceToAdd) { 15 | SimpleType interfaceType = ast.newSimpleType(ast.newSimpleName(interfaceToAdd.getName().getFullyQualifiedName())); 16 | 17 | if (type.getClass() == TypeDeclaration.class) { 18 | ((TypeDeclaration) type).superInterfaceTypes().add(interfaceType); 19 | } else if (IsRecordTypePredicate.isRecordDeclaration(type)) { 20 | RecordDeclarationWrapper.of(type).superInterfaceTypes().add(interfaceType); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/codegenerator/component/helper/IsRecordTypePredicate.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers.codegenerator.component.helper; 2 | 3 | import org.eclipse.jdt.core.dom.AbstractTypeDeclaration; 4 | 5 | /** 6 | * Checks if the given AbstractTypeDeclaration is a RecordDeclaration. 7 | * @author helospark 8 | */ 9 | public class IsRecordTypePredicate { 10 | private static final String RECORD_DECLARATION_FQN = "org.eclipse.jdt.core.dom.RecordDeclaration"; 11 | 12 | public static boolean isRecordDeclaration(AbstractTypeDeclaration abstractTypeDeclaration) { 13 | return abstractTypeDeclaration.getClass().getCanonicalName().equals(RECORD_DECLARATION_FQN); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/codegenerator/component/helper/IsRegularBuilderInstanceCopyEnabledPredicate.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers.codegenerator.component.helper; 2 | 3 | import static com.helospark.spark.builder.preferences.PluginPreferenceList.CREATE_METHOD_TO_INSTANTIATE_BUILDER_BASED_ON_INSTANCE; 4 | 5 | import java.util.function.Predicate; 6 | 7 | import com.helospark.spark.builder.handlers.codegenerator.domain.RegularBuilderUserPreference; 8 | import com.helospark.spark.builder.preferences.PreferencesManager; 9 | 10 | /** 11 | * Returns whether instance copying is enabled and possible. 12 | * @author helospark 13 | */ 14 | public class IsRegularBuilderInstanceCopyEnabledPredicate implements Predicate { 15 | private PreferencesManager preferencesManager; 16 | 17 | public IsRegularBuilderInstanceCopyEnabledPredicate(PreferencesManager preferencesManager) { 18 | this.preferencesManager = preferencesManager; 19 | } 20 | 21 | @Override 22 | public boolean test(RegularBuilderUserPreference preference) { 23 | return preferencesManager.getPreferenceValue(CREATE_METHOD_TO_INSTANTIATE_BUILDER_BASED_ON_INSTANCE); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/codegenerator/component/helper/IsTypeApplicableForBuilderGenerationPredicate.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers.codegenerator.component.helper; 2 | 3 | import static org.eclipse.jdt.core.Flags.isStatic; 4 | 5 | import org.eclipse.jdt.core.IType; 6 | import org.eclipse.jdt.core.JavaModelException; 7 | 8 | /** 9 | * Determines if the given IType is applicable for builder generation. 10 | * In the current implementation 11 | * - Nonstatic nested classes (inner classes) are not applicable for builder generation, since they cannot contain static methods 12 | * @author helospark 13 | */ 14 | public class IsTypeApplicableForBuilderGenerationPredicate { 15 | private ParentITypeExtractor parentITypeExtractor; 16 | 17 | public IsTypeApplicableForBuilderGenerationPredicate(ParentITypeExtractor parentITypeExtractor) { 18 | this.parentITypeExtractor = parentITypeExtractor; 19 | } 20 | 21 | public boolean test(IType type) throws JavaModelException { 22 | return !isNestedType(type) || isStatic(type.getFlags()); 23 | } 24 | 25 | private boolean isNestedType(IType iType) { 26 | return parentITypeExtractor.getParentType(iType).isPresent(); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/codegenerator/component/helper/JavadocGenerator.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers.codegenerator.component.helper; 2 | 3 | import java.util.Map; 4 | 5 | import org.eclipse.jdt.core.dom.AST; 6 | import org.eclipse.jdt.core.dom.Javadoc; 7 | import org.eclipse.jdt.core.dom.TagElement; 8 | import org.eclipse.jdt.core.dom.TextElement; 9 | 10 | /** 11 | * Generates Javadoc from template. 12 | * 13 | * @author helospark 14 | */ 15 | public class JavadocGenerator { 16 | 17 | @SuppressWarnings("unchecked") 18 | public Javadoc generateJavadoc(AST ast, String mainTemplate, Map tags) { 19 | Javadoc javadoc = ast.newJavadoc(); 20 | for (String line : mainTemplate.split("\n")) { 21 | TextElement textElement = ast.newTextElement(); 22 | textElement.setText(line); 23 | TagElement tagElement = ast.newTagElement(); 24 | tagElement.fragments().add(textElement); 25 | javadoc.tags().add(tagElement); 26 | } 27 | 28 | for (Map.Entry entity : tags.entrySet()) { 29 | TextElement tagTextElement = ast.newTextElement(); 30 | tagTextElement.setText(entity.getValue()); 31 | 32 | TagElement tagElement = ast.newTagElement(); 33 | tagElement.setTagName(entity.getKey()); 34 | tagElement.fragments().add(tagTextElement); 35 | javadoc.tags().add(tagElement); 36 | } 37 | return javadoc; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/codegenerator/component/helper/JlsVersionProvider.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers.codegenerator.component.helper; 2 | 3 | import org.eclipse.jdt.core.dom.AST; 4 | 5 | /** 6 | * Provides the latest JLS (java version) this Eclipse implementation supports. 7 | * 8 | * Implementation note: 9 | * Unfortunately old version of Eclipse doesn't support getJLSLatest method on AST, therefore, we have to find out the latest 10 | * version via reflection in that case by checking if JLS20, JLS19... fields exists. 11 | * @author helospark 12 | */ 13 | public class JlsVersionProvider { 14 | 15 | public static int getLatestJlsVersion() { 16 | try { 17 | try { 18 | return (Integer) AST.class.getMethod("getJLSLatest").invoke(null); 19 | } catch (Throwable e) { 20 | } 21 | for (int jlsVersion = 20; jlsVersion >= 8; --jlsVersion) { 22 | try { 23 | int value = AST.class.getField("JLS" + jlsVersion).getInt(null); 24 | return value; 25 | } catch (Throwable e) { 26 | } 27 | } 28 | } catch (Exception e) { 29 | } 30 | 31 | return AST.JLS8; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/codegenerator/component/helper/MethodExtractor.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers.codegenerator.component.helper; 2 | 3 | import org.eclipse.jdt.core.dom.AbstractTypeDeclaration; 4 | import org.eclipse.jdt.core.dom.MethodDeclaration; 5 | import org.eclipse.jdt.core.dom.TypeDeclaration; 6 | 7 | /** 8 | * Get methods declared by this AbstractTypeDeclaration. 9 | * @author helospark 10 | */ 11 | public class MethodExtractor { 12 | 13 | public static MethodDeclaration[] getMethods(AbstractTypeDeclaration mainType) { 14 | if (mainType.getClass() == TypeDeclaration.class) { 15 | return ((TypeDeclaration) mainType).getMethods(); 16 | } else if (IsRecordTypePredicate.isRecordDeclaration(mainType)) { 17 | return RecordDeclarationWrapper.of(mainType).getMethods(); 18 | } else { 19 | return new MethodDeclaration[0]; 20 | } 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/codegenerator/component/helper/ParentITypeExtractor.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers.codegenerator.component.helper; 2 | 3 | import static java.util.Optional.ofNullable; 4 | 5 | import java.util.Optional; 6 | 7 | import org.eclipse.jdt.core.IJavaElement; 8 | import org.eclipse.jdt.core.IType; 9 | 10 | /** 11 | * Extracts the parent {@link IType} from the given IJavaElement. 12 | * @author helospark 13 | */ 14 | public class ParentITypeExtractor { 15 | 16 | public Optional getParentType(IJavaElement currentElement) { 17 | // getAncestor may return itself if it's already an IType 18 | // therefore we must get call getParent before 19 | return ofNullable(currentElement) 20 | .map(element -> element.getParent()) 21 | .map(element -> element.getAncestor(IJavaElement.TYPE)) 22 | .map(element -> (IType) element); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/codegenerator/component/helper/PreferenceStoreWrapper.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers.codegenerator.component.helper; 2 | 3 | import java.util.Optional; 4 | 5 | import org.eclipse.jface.preference.IPreferenceStore; 6 | 7 | /** 8 | * Wrapper around Eclipse's IPreferenceStore. 9 | * 10 | * @author helospark 11 | */ 12 | public class PreferenceStoreWrapper { 13 | private IPreferenceStore preferenceStore; 14 | 15 | public PreferenceStoreWrapper(IPreferenceStore preferenceStore) { 16 | this.preferenceStore = preferenceStore; 17 | } 18 | 19 | public Optional getString(String key) { 20 | return Optional.ofNullable(preferenceStore.getString(key)); 21 | } 22 | 23 | public Boolean getBoolean(String key) { 24 | return Optional.ofNullable(preferenceStore.getBoolean(key)) 25 | .orElse(false); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/codegenerator/component/helper/StagedBuilderStagePropertyInputDialogOpener.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers.codegenerator.component.helper; 2 | 3 | import static java.util.Optional.ofNullable; 4 | 5 | import java.util.List; 6 | import java.util.Optional; 7 | 8 | import org.eclipse.swt.widgets.Shell; 9 | 10 | import com.helospark.spark.builder.dialogs.StagedBuilderStagePropertyInputDialog; 11 | import com.helospark.spark.builder.dialogs.domain.StagedBuilderStagePropertiesDialogResult; 12 | import com.helospark.spark.builder.handlers.CurrentShellProvider; 13 | 14 | /** 15 | * Opens a dialog to get stage properties. 16 | * @author helospark 17 | */ 18 | public class StagedBuilderStagePropertyInputDialogOpener { 19 | private CurrentShellProvider currentShellProvider; 20 | 21 | public StagedBuilderStagePropertyInputDialogOpener(CurrentShellProvider currentShellProvider) { 22 | this.currentShellProvider = currentShellProvider; 23 | } 24 | 25 | public Optional> open(List request) { 26 | Shell shell = currentShellProvider.provideCurrentShell(); 27 | StagedBuilderStagePropertyInputDialog stagedBuilderStagePropertyInputDialog = new StagedBuilderStagePropertyInputDialog(shell, request); 28 | List result = (List) stagedBuilderStagePropertyInputDialog.open(); 29 | return ofNullable(result); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/codegenerator/component/helper/TemplateResolver.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers.codegenerator.component.helper; 2 | 3 | import java.util.Map; 4 | import java.util.regex.Matcher; 5 | import java.util.regex.Pattern; 6 | 7 | import com.helospark.spark.builder.handlers.exception.PluginException; 8 | 9 | /** 10 | * Resolves template to actual value. 11 | * 12 | * @author helospark 13 | * @author stackoverflow 14 | */ 15 | public class TemplateResolver { 16 | 17 | public String resolveTemplate(String fullTemplateString, Map replacements) { 18 | Pattern pattern = Pattern.compile("\\[(.+?)\\]"); 19 | Matcher matcher = pattern.matcher(fullTemplateString); 20 | StringBuilder builder = new StringBuilder(); 21 | int i = 0; 22 | while (matcher.find()) { 23 | String templateToReplace = matcher.group(1); 24 | String replacement = replacements.get(templateToReplace); 25 | builder.append(fullTemplateString.substring(i, matcher.start())); 26 | if (replacement == null) { 27 | throw new PluginException("Illegal template '" + templateToReplace + "' in context of " + fullTemplateString + ". Valid templates: " + replacements.toString()); 28 | } else { 29 | builder.append(replacement); 30 | } 31 | i = matcher.end(); 32 | } 33 | builder.append(fullTemplateString.substring(i, fullTemplateString.length())); 34 | return builder.toString(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/codegenerator/component/helper/TypeDeclarationToVariableNameConverter.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers.codegenerator.component.helper; 2 | 3 | import org.eclipse.jdt.core.dom.AbstractTypeDeclaration; 4 | 5 | /** 6 | * Converts the given AbstractTypeDeclaration to a variable name using common Java camelCase convention. 7 | * @author helospark 8 | */ 9 | public class TypeDeclarationToVariableNameConverter { 10 | private CamelCaseConverter camelCaseConverter; 11 | 12 | public TypeDeclarationToVariableNameConverter(CamelCaseConverter camelCaseConverter) { 13 | this.camelCaseConverter = camelCaseConverter; 14 | } 15 | 16 | public String convert(AbstractTypeDeclaration builderType) { 17 | return camelCaseConverter.toLowerCamelCase(builderType.getName().toString()); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/codegenerator/component/helper/TypeExtractor.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers.codegenerator.component.helper; 2 | 3 | import org.eclipse.jdt.core.dom.AbstractTypeDeclaration; 4 | import org.eclipse.jdt.core.dom.TypeDeclaration; 5 | 6 | public class TypeExtractor { 7 | 8 | public static TypeDeclaration[] getTypes(AbstractTypeDeclaration mainType) { 9 | if (mainType.getClass() == TypeDeclaration.class) { 10 | return ((TypeDeclaration) mainType).getTypes(); 11 | } else { 12 | return new TypeDeclaration[0]; 13 | } 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/codegenerator/component/helper/domain/PrefixSuffixHolder.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers.codegenerator.component.helper.domain; 2 | 3 | import java.util.List; 4 | 5 | import javax.annotation.Generated; 6 | 7 | public class PrefixSuffixHolder { 8 | private List prefixes; 9 | private List suffixes; 10 | 11 | @Generated("SparkTools") 12 | private PrefixSuffixHolder(Builder builder) { 13 | this.prefixes = builder.prefixes; 14 | this.suffixes = builder.suffixes; 15 | } 16 | 17 | public List getPrefixes() { 18 | return prefixes; 19 | } 20 | 21 | public List getSuffixes() { 22 | return suffixes; 23 | } 24 | 25 | @Generated("SparkTools") 26 | public static Builder builder() { 27 | return new Builder(); 28 | } 29 | 30 | @Generated("SparkTools") 31 | public static final class Builder { 32 | private List prefixes; 33 | private List suffixes; 34 | 35 | private Builder() { 36 | } 37 | 38 | public Builder withPrefixes(List prefixes) { 39 | this.prefixes = prefixes; 40 | return this; 41 | } 42 | 43 | public Builder withSuffixes(List suffixes) { 44 | this.suffixes = suffixes; 45 | return this; 46 | } 47 | 48 | public PrefixSuffixHolder build() { 49 | return new PrefixSuffixHolder(this); 50 | } 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/codegenerator/component/remover/BuilderRemoverChainItem.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers.codegenerator.component.remover; 2 | 3 | import org.eclipse.jdt.core.dom.AbstractTypeDeclaration; 4 | import org.eclipse.jdt.core.dom.rewrite.ASTRewrite; 5 | 6 | import com.helospark.spark.builder.handlers.codegenerator.domain.CompilationUnitModificationDomain; 7 | 8 | /** 9 | * Chain item to remove parts of the previously generated builder. 10 | * @author helospark 11 | */ 12 | public interface BuilderRemoverChainItem { 13 | 14 | void remove(ASTRewrite rewriter, AbstractTypeDeclaration mainType, CompilationUnitModificationDomain modificationDomain); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/codegenerator/component/remover/helper/BodyDeclarationOfTypeExtractor.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers.codegenerator.component.remover.helper; 2 | 3 | import java.util.List; 4 | import java.util.stream.Collectors; 5 | 6 | import org.eclipse.jdt.core.dom.AbstractTypeDeclaration; 7 | import org.eclipse.jdt.core.dom.BodyDeclaration; 8 | 9 | /** 10 | * Extracts body declarations that has the same type as the given class. 11 | * @author helospark 12 | */ 13 | public class BodyDeclarationOfTypeExtractor { 14 | 15 | public List extractBodyDeclaration(AbstractTypeDeclaration typeDeclaration, Class expectedReturnType) { 16 | return ((List) typeDeclaration.bodyDeclarations()) 17 | .stream() 18 | .filter(value -> value.getClass().equals(expectedReturnType)) 19 | .map(value -> (T) value) 20 | .collect(Collectors.toList()); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/codegenerator/component/remover/helper/GeneratedAnnotationContainingBodyDeclarationFilter.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers.codegenerator.component.remover.helper; 2 | 3 | import java.util.List; 4 | import java.util.stream.Collectors; 5 | 6 | import org.eclipse.jdt.core.dom.BodyDeclaration; 7 | 8 | /** 9 | * Filters the given list and return only those body declarations that contain Generated annotation. 10 | * @author helospark 11 | */ 12 | public class GeneratedAnnotationContainingBodyDeclarationFilter { 13 | private GeneratedAnnotationPredicate generatedAnnotationPredicate; 14 | 15 | public GeneratedAnnotationContainingBodyDeclarationFilter(GeneratedAnnotationPredicate generatedAnnotationPredicate) { 16 | this.generatedAnnotationPredicate = generatedAnnotationPredicate; 17 | } 18 | 19 | public List filterAnnotatedClasses(List bodyDeclarations) { 20 | return bodyDeclarations 21 | .stream() 22 | .filter(generatedAnnotationPredicate) 23 | .collect(Collectors.toList()); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/codegenerator/component/remover/helper/GenericModifierPredicate.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers.codegenerator.component.remover.helper; 2 | 3 | import java.util.List; 4 | import java.util.function.Predicate; 5 | 6 | import org.eclipse.jdt.core.dom.BodyDeclaration; 7 | import org.eclipse.jdt.core.dom.IExtendedModifier; 8 | import org.eclipse.jdt.core.dom.Modifier; 9 | 10 | /** 11 | * Predicate that return whether the given predicate is true for at least one modifier. 12 | * @author helospark 13 | */ 14 | public class GenericModifierPredicate { 15 | 16 | public boolean test(BodyDeclaration method, Predicate modifiedPredicate) { 17 | return ((List) method.modifiers()) 18 | .stream() 19 | .filter(modifier -> modifier instanceof Modifier) 20 | .filter(modifiedPredicate) 21 | .findFirst() 22 | .isPresent(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/codegenerator/component/remover/helper/IsPackageEqualsPredicate.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers.codegenerator.component.remover.helper; 2 | 3 | import java.util.Objects; 4 | import java.util.Optional; 5 | import java.util.function.BiPredicate; 6 | 7 | import org.eclipse.jdt.core.dom.ASTNode; 8 | import org.eclipse.jdt.core.dom.CompilationUnit; 9 | 10 | /** 11 | * Determines if the package of the two given ASTNode is equals. 12 | * @author helospark 13 | */ 14 | public class IsPackageEqualsPredicate implements BiPredicate { 15 | 16 | @Override 17 | public boolean test(ASTNode first, ASTNode second) { 18 | Optional firstPackageName = getPackageName(first); 19 | Optional secondPackageName = getPackageName(second); 20 | 21 | return Objects.equals(firstPackageName, secondPackageName); 22 | } 23 | 24 | private Optional getPackageName(ASTNode first) { 25 | return Optional.ofNullable(first.getRoot()) 26 | .filter(root -> root instanceof CompilationUnit) 27 | .map(root -> (CompilationUnit) root) 28 | .map(compilationUnit -> compilationUnit.getPackage()) 29 | .map(packageDeclaration -> packageDeclaration.getName()) 30 | .map(packageName -> packageName.toString()); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/codegenerator/component/remover/helper/IsPrivatePredicate.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers.codegenerator.component.remover.helper; 2 | 3 | import java.util.function.Predicate; 4 | 5 | import org.eclipse.jdt.core.dom.BodyDeclaration; 6 | import org.eclipse.jdt.core.dom.Modifier; 7 | import org.eclipse.jdt.core.dom.Modifier.ModifierKeyword; 8 | 9 | /** 10 | * Return whether the given body declaration is private. 11 | * @author helospark 12 | */ 13 | public class IsPrivatePredicate implements Predicate { 14 | private GenericModifierPredicate genericModifierPredicate; 15 | 16 | public IsPrivatePredicate(GenericModifierPredicate genericModifierPredicate) { 17 | this.genericModifierPredicate = genericModifierPredicate; 18 | } 19 | 20 | @Override 21 | public boolean test(BodyDeclaration bodyDeclaration) { 22 | return genericModifierPredicate.test(bodyDeclaration, element -> ((Modifier) element).getKeyword() == ModifierKeyword.PRIVATE_KEYWORD); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/codegenerator/component/remover/helper/IsPublicPredicate.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers.codegenerator.component.remover.helper; 2 | 3 | import java.util.function.Predicate; 4 | 5 | import org.eclipse.jdt.core.dom.BodyDeclaration; 6 | import org.eclipse.jdt.core.dom.Modifier; 7 | import org.eclipse.jdt.core.dom.Modifier.ModifierKeyword; 8 | 9 | /** 10 | * Return whether the given body declaration is public. 11 | * @author helospark 12 | */ 13 | public class IsPublicPredicate implements Predicate { 14 | private GenericModifierPredicate genericModifierPredicate; 15 | 16 | public IsPublicPredicate(GenericModifierPredicate genericModifierPredicate) { 17 | this.genericModifierPredicate = genericModifierPredicate; 18 | } 19 | 20 | @Override 21 | public boolean test(BodyDeclaration bodyDeclaration) { 22 | return genericModifierPredicate.test(bodyDeclaration, element -> ((Modifier) element).getKeyword() == ModifierKeyword.PUBLIC_KEYWORD); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/codegenerator/component/remover/helper/IsStaticPredicate.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers.codegenerator.component.remover.helper; 2 | 3 | import java.util.function.Predicate; 4 | 5 | import org.eclipse.jdt.core.dom.BodyDeclaration; 6 | import org.eclipse.jdt.core.dom.Modifier; 7 | import org.eclipse.jdt.core.dom.Modifier.ModifierKeyword; 8 | 9 | /** 10 | * Return whether the given body declaration is static. 11 | * @author helospark 12 | */ 13 | public class IsStaticPredicate implements Predicate { 14 | private GenericModifierPredicate genericModifierPredicate; 15 | 16 | public IsStaticPredicate(GenericModifierPredicate genericModifierPredicate) { 17 | this.genericModifierPredicate = genericModifierPredicate; 18 | } 19 | 20 | @Override 21 | public boolean test(BodyDeclaration bodyDeclaration) { 22 | return genericModifierPredicate.test(bodyDeclaration, element -> ((Modifier) element).getKeyword() == ModifierKeyword.STATIC_KEYWORD); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/codegenerator/domain/instancefieldaccess/DirectFieldAccessStrategy.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers.codegenerator.domain.instancefieldaccess; 2 | 3 | import org.eclipse.jdt.core.dom.AST; 4 | import org.eclipse.jdt.core.dom.Expression; 5 | import org.eclipse.jdt.core.dom.FieldAccess; 6 | 7 | /** 8 | * Accesses the original field via field access. 9 | *
10 |  * rhsName.field
11 |  * 
12 | * 13 | * @author helospark 14 | */ 15 | public class DirectFieldAccessStrategy implements InstanceFieldAccessStrategy { 16 | private String originalFieldName; 17 | 18 | public DirectFieldAccessStrategy(String originalFieldName) { 19 | this.originalFieldName = originalFieldName; 20 | } 21 | 22 | @Override 23 | public Expression createFieldAccessExpression(AST ast, String rhsName) { 24 | FieldAccess builderFieldAccess = ast.newFieldAccess(); 25 | builderFieldAccess.setExpression(ast.newSimpleName(rhsName)); 26 | builderFieldAccess.setName(ast.newSimpleName(originalFieldName)); 27 | return builderFieldAccess; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/codegenerator/domain/instancefieldaccess/GetterFieldAccessStrategy.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers.codegenerator.domain.instancefieldaccess; 2 | 3 | import org.eclipse.jdt.core.dom.AST; 4 | import org.eclipse.jdt.core.dom.Expression; 5 | import org.eclipse.jdt.core.dom.MethodInvocation; 6 | 7 | /** 8 | * Accesses the original field via getter. 9 | *
10 |  * rhsName.getField()
11 |  * 
12 | * 13 | * @author helospark 14 | */ 15 | public class GetterFieldAccessStrategy implements InstanceFieldAccessStrategy { 16 | private String getterName; 17 | 18 | public GetterFieldAccessStrategy(String getterName) { 19 | this.getterName = getterName; 20 | } 21 | 22 | @Override 23 | public Expression createFieldAccessExpression(AST ast, String rhsName) { 24 | MethodInvocation getterMethodInvocation = ast.newMethodInvocation(); 25 | getterMethodInvocation.setExpression(ast.newSimpleName(rhsName)); 26 | getterMethodInvocation.setName(ast.newSimpleName(getterName)); 27 | return getterMethodInvocation; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/codegenerator/domain/instancefieldaccess/InstanceFieldAccessStrategy.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers.codegenerator.domain.instancefieldaccess; 2 | 3 | import org.eclipse.jdt.core.dom.AST; 4 | import org.eclipse.jdt.core.dom.Expression; 5 | 6 | public interface InstanceFieldAccessStrategy { 7 | 8 | public Expression createFieldAccessExpression(AST ast, String rhsName); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/handlers/exception/PluginException.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers.exception; 2 | 3 | public class PluginException extends RuntimeException { 4 | 5 | public PluginException(String cause) { 6 | super(cause); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/preferences/PluginPreferenceGroup.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.preferences; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Represent a preference grouping. 7 | * @author helospark 8 | */ 9 | public class PluginPreferenceGroup { 10 | private String name; 11 | private List> preferences; 12 | 13 | public PluginPreferenceGroup(String name, List> preferences) { 14 | this.name = name; 15 | this.preferences = preferences; 16 | } 17 | 18 | public String getName() { 19 | return name; 20 | } 21 | 22 | public List> getPreferences() { 23 | return preferences; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/preferences/PluginPreferenceInitializer.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.preferences; 2 | 3 | import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; 4 | import org.eclipse.core.runtime.preferences.DefaultScope; 5 | import org.eclipse.core.runtime.preferences.IEclipsePreferences; 6 | 7 | import com.helospark.spark.builder.Activator; 8 | 9 | public class PluginPreferenceInitializer extends AbstractPreferenceInitializer { 10 | 11 | @Override 12 | public void initializeDefaultPreferences() { 13 | initializeDefaultValues(DefaultScope.INSTANCE.getNode(Activator.PLUGIN_ID)); 14 | } 15 | 16 | private void initializeDefaultValues(IEclipsePreferences iEclipsePreferences) { 17 | PluginPreferenceList.getAllPreferences() 18 | .stream() 19 | .flatMap(preferenceGroup -> preferenceGroup.getPreferences().stream()) 20 | .forEach(pluginPreference -> pluginPreference.putDefaultValue(iEclipsePreferences)); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/preferences/PreferenceHolder.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.preferences; 2 | 3 | public interface PreferenceHolder { 4 | 5 | void setNewValue(Object newValue); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/preferences/StaticPreferences.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.preferences; 2 | 3 | public class StaticPreferences { 4 | public static final String RETURN_JAVADOC_TAG_NAME = "@return"; 5 | public static final String PARAM_JAVADOC_TAG_NAME = "@param"; 6 | public static final String PLUGIN_GENERATED_ANNOTATION_NAME = "SparkTools"; 7 | public static final String OPTIONAL_CLASS_NAME = "Optional"; 8 | public static final String OPTIONAL_FULLY_QUALIFIED_NAME = "java.util." + OPTIONAL_CLASS_NAME; 9 | public static final String EMPTY_OPTIONAL_CREATOR_STATIC_METHOD = "empty"; 10 | public static final String COLLECTIONS_CLASS_NAME = "Collections"; 11 | public static final String COLLECTIONS_CLASS_FULLY_QUALIFIED_NAME = "java.util." + COLLECTIONS_CLASS_NAME; 12 | 13 | public static final String JACKSON_DATABIND_PACKAGE = "com.fasterxml.jackson.databind.annotation"; 14 | public static final String JSON_POJO_BUILDER_CLASS_NAME = "JsonPOJOBuilder"; 15 | public static final String JSON_POJO_BUILDER_FULLY_QUALIFIED_NAME = JACKSON_DATABIND_PACKAGE + "." + JSON_POJO_BUILDER_CLASS_NAME; 16 | 17 | public static final String JSON_DESERIALIZE_CLASS_NAME = "JsonDeserialize"; 18 | public static final String JSON_DESERIALIZE_FULLY_QUALIFIED_NAME = JACKSON_DATABIND_PACKAGE + "." + JSON_DESERIALIZE_CLASS_NAME; 19 | } 20 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/src/com/helospark/spark/builder/preferences/impl/AbstractPluginPreference.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.preferences.impl; 2 | 3 | import com.helospark.spark.builder.preferences.PluginPreference; 4 | 5 | /** 6 | * Abstract implementation of the {@link PluginPreference} 7 | * 8 | * @author maudrain 9 | * @param 10 | * the type of preference value 11 | */ 12 | public abstract class AbstractPluginPreference implements PluginPreference { 13 | 14 | private final String key; 15 | private final String description; 16 | private final T defaultValue; 17 | 18 | /** 19 | * Constructor 20 | * 21 | * @param key 22 | * the key for this preference 23 | * @param description 24 | * the description for this preference 25 | * @param defaultValue 26 | * the default value of this preference 27 | */ 28 | public AbstractPluginPreference(String key, String description, T defaultValue) { 29 | this.key = key; 30 | this.description = description; 31 | this.defaultValue = defaultValue; 32 | } 33 | 34 | @Override 35 | public final String getKey() { 36 | return key; 37 | } 38 | 39 | @Override 40 | public final String getDescription() { 41 | return description; 42 | } 43 | 44 | @Override 45 | public final T getDefaultValue() { 46 | return defaultValue; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test/com/helospark/spark/builder/handlers/it/dummyService/ModifiedStagedDialogSettingsAnswerProvider.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers.it.dummyService; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.Optional; 6 | 7 | import org.mockito.invocation.InvocationOnMock; 8 | 9 | import com.helospark.spark.builder.dialogs.domain.StagedBuilderStagePropertiesDialogResult; 10 | 11 | public class ModifiedStagedDialogSettingsAnswerProvider { 12 | private List newOrderIndices; 13 | private List mandatoryFieldIndices; 14 | 15 | public ModifiedStagedDialogSettingsAnswerProvider(List newOrder, List mandatoryFieldIndices) { 16 | this.newOrderIndices = newOrder; 17 | this.mandatoryFieldIndices = mandatoryFieldIndices; 18 | } 19 | 20 | public Object provideAnswer(InvocationOnMock inv) { 21 | List request = (List) inv.getArguments()[0]; 22 | List result = new ArrayList<>(); 23 | for (int i = 0; i < newOrderIndices.size(); ++i) { 24 | StagedBuilderStagePropertiesDialogResult otherRequest = request.get(newOrderIndices.get(i)); 25 | otherRequest.setMandatory(false); 26 | result.add(otherRequest); 27 | 28 | } 29 | for (int i = 0; i < mandatoryFieldIndices.size(); ++i) { 30 | result.get(i).setMandatory(true); 31 | } 32 | return Optional.of(result); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test/com/helospark/spark/builder/handlers/it/dummyService/NoDialogOperationPerformedStagedBuilderDialogAnswerProvider.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers.it.dummyService; 2 | 3 | import java.util.Optional; 4 | 5 | import org.mockito.invocation.InvocationOnMock; 6 | 7 | public class NoDialogOperationPerformedStagedBuilderDialogAnswerProvider { 8 | 9 | public Object provideAnswer(InvocationOnMock inv) { 10 | return Optional.of(inv.getArguments()[0]); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test/com/helospark/spark/builder/handlers/it/dummyService/TypeExtractorAnswerProvider.java: -------------------------------------------------------------------------------- 1 | package com.helospark.spark.builder.handlers.it.dummyService; 2 | 3 | import static java.util.Optional.ofNullable; 4 | 5 | import java.util.Map; 6 | 7 | import org.eclipse.jdt.core.IType; 8 | import org.eclipse.jdt.core.dom.TypeDeclaration; 9 | import org.mockito.invocation.InvocationOnMock; 10 | 11 | /** 12 | * Provide IType based on TypeDeclaration. 13 | * @author helospark 14 | */ 15 | public class TypeExtractorAnswerProvider { 16 | private Map typeNameToITypeMapping; 17 | 18 | public TypeExtractorAnswerProvider(Map types) { 19 | this.typeNameToITypeMapping = types; 20 | } 21 | 22 | public Object provideAnswer(InvocationOnMock inv) { 23 | TypeDeclaration result = (TypeDeclaration) inv.getArguments()[0]; 24 | String typeName = result.getName().toString(); 25 | return ofNullable(typeNameToITypeMapping.get(typeName)); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/annotated_fields_input.tjava: -------------------------------------------------------------------------------- 1 | public class TestClass { 2 | @Nonnul 3 | private String testField; 4 | @Valid 5 | private Integer data; 6 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/annotated_fields_output.tjava: -------------------------------------------------------------------------------- 1 | public class TestClass { 2 | @Nonnul 3 | private String testField; 4 | @Valid 5 | private Integer data; 6 | 7 | private TestClass(Builder builder) { 8 | this.testField = builder.testField; 9 | this.data = builder.data; 10 | } 11 | 12 | public static Builder builder() { 13 | return new Builder(); 14 | } 15 | 16 | public static final class Builder { 17 | private String testField; 18 | private Integer data; 19 | 20 | private Builder() { 21 | } 22 | 23 | public Builder withTestField(String testField) { 24 | this.testField = testField; 25 | return this; 26 | } 27 | 28 | public Builder withData(Integer data) { 29 | this.data = data; 30 | return this; 31 | } 32 | 33 | public TestClass build() { 34 | return new TestClass(this); 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/annotated_fields_staged_output.tjava: -------------------------------------------------------------------------------- 1 | public class TestClass { 2 | @Nonnul 3 | private String testField; 4 | @Valid 5 | private Integer data; 6 | 7 | private TestClass(Builder builder) { 8 | this.testField = builder.testField; 9 | this.data = builder.data; 10 | } 11 | 12 | public static ITestFieldStage builder() { 13 | return new Builder(); 14 | } 15 | 16 | public interface ITestFieldStage { 17 | public IDataStage withTestField(String testField); 18 | } 19 | 20 | public interface IDataStage { 21 | public IBuildStage withData(Integer data); 22 | } 23 | 24 | public interface IBuildStage { 25 | public TestClass build(); 26 | } 27 | 28 | public static final class Builder implements ITestFieldStage, IDataStage, IBuildStage { 29 | private String testField; 30 | private Integer data; 31 | 32 | private Builder() { 33 | } 34 | 35 | @Override 36 | public IDataStage withTestField(String testField) { 37 | this.testField = testField; 38 | return this; 39 | } 40 | 41 | @Override 42 | public IBuildStage withData(Integer data) { 43 | this.data = data; 44 | return this; 45 | } 46 | 47 | @Override 48 | public TestClass build() { 49 | return new TestClass(this); 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/class_with_collections_input.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.test; 2 | 3 | import java.util.Collection; 4 | import java.util.List; 5 | import java.util.Map; 6 | import java.util.Set; 7 | import java.util.SortedMap; 8 | import java.util.SortedSet; 9 | 10 | public class ClassWithCollections { 11 | private Set set; 12 | private List list; 13 | private Map map; 14 | private SortedSet sortedSet; 15 | private SortedMap sortedMap; 16 | private Collection collection; 17 | private Iterable iterable; 18 | private String string; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/custom_method/class_with_custom_add_method_and_helper_disabled_output.tjava: -------------------------------------------------------------------------------- 1 | public class Example 2 | { 3 | List ids; 4 | 5 | private Example(ExampleBuilder exampleBuilder) { 6 | this.ids = exampleBuilder.ids; 7 | } 8 | 9 | public static ExampleBuilder builder() { 10 | return new ExampleBuilder(); 11 | } 12 | 13 | public static final class ExampleBuilder { 14 | private List ids; 15 | 16 | private ExampleBuilder() { 17 | } 18 | 19 | public ExampleBuilder withIds(List ids) { 20 | this.ids = ids; 21 | return this; 22 | } 23 | 24 | public Example build() { 25 | return new Example(this); 26 | } 27 | } 28 | 29 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/custom_method/class_with_custom_add_method_and_helper_input.tjava: -------------------------------------------------------------------------------- 1 | public class Example 2 | { 3 | List ids; 4 | 5 | private Example(ExampleBuilder exampleBuilder) { 6 | this.ids = exampleBuilder.ids; 7 | } 8 | 9 | public static ExampleBuilder builder() { 10 | return new ExampleBuilder(); 11 | } 12 | 13 | public static final class ExampleBuilder { 14 | private List ids; 15 | 16 | private ExampleBuilder() { 17 | } 18 | 19 | public ExampleBuilder addId(String id) { 20 | this.ids.add(id); 21 | return this; 22 | } 23 | 24 | public ExampleBuilder withIds(List ids) { 25 | this.ids = ids; 26 | return this; 27 | } 28 | 29 | public static void helperMethod() { 30 | id = new ArrayList<>(); 31 | } 32 | 33 | public Example build() { 34 | return new Example(this); 35 | } 36 | } 37 | 38 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/custom_method/class_with_custom_add_method_and_helper_output.tjava: -------------------------------------------------------------------------------- 1 | public class Example 2 | { 3 | List ids; 4 | 5 | private Example(ExampleBuilder exampleBuilder) { 6 | this.ids = exampleBuilder.ids; 7 | } 8 | 9 | public static ExampleBuilder builder() { 10 | return new ExampleBuilder(); 11 | } 12 | 13 | public static final class ExampleBuilder { 14 | private List ids; 15 | 16 | private ExampleBuilder() { 17 | } 18 | 19 | public ExampleBuilder withIds(List ids) { 20 | this.ids = ids; 21 | return this; 22 | } 23 | 24 | public ExampleBuilder addId(String id) { 25 | this.ids.add(id); 26 | return this; 27 | } 28 | 29 | public static void helperMethod() { 30 | id = new ArrayList<>(); 31 | } 32 | 33 | public Example build() { 34 | return new Example(this); 35 | } 36 | } 37 | 38 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/custom_method/custom_method_that_looks_like_builder_method_input.tjava: -------------------------------------------------------------------------------- 1 | public class Example 2 | { 3 | List ids; 4 | 5 | private Example(ExampleBuilder exampleBuilder) { 6 | this.ids = exampleBuilder.ids; 7 | } 8 | 9 | public static ExampleBuilder builder() { 10 | return new ExampleBuilder(); 11 | } 12 | 13 | public static final class ExampleBuilder { 14 | private List ids; 15 | 16 | private ExampleBuilder() { 17 | } 18 | 19 | public ExampleBuilder withIds(List ids) { 20 | this.ids = ids; 21 | return this; 22 | } 23 | 24 | public ExampleBuilder withData(String data) { 25 | this.data = data; 26 | return this; 27 | } 28 | 29 | public Example build() { 30 | return new Example(this); 31 | } 32 | } 33 | 34 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/custom_method/custom_method_that_looks_like_builder_method_output.tjava: -------------------------------------------------------------------------------- 1 | public class Example 2 | { 3 | List ids; 4 | 5 | private Example(ExampleBuilder exampleBuilder) { 6 | this.ids = exampleBuilder.ids; 7 | } 8 | 9 | public static ExampleBuilder builder() { 10 | return new ExampleBuilder(); 11 | } 12 | 13 | public static final class ExampleBuilder { 14 | private List ids; 15 | 16 | private ExampleBuilder() { 17 | } 18 | 19 | public ExampleBuilder withIds(List ids) { 20 | this.ids = ids; 21 | return this; 22 | } 23 | 24 | public Example build() { 25 | return new Example(this); 26 | } 27 | } 28 | 29 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/custom_method/removed_fields_input.tjava: -------------------------------------------------------------------------------- 1 | public class Example { 2 | String firstField; 3 | 4 | private Example(ExampleBuilder exampleBuilder) { 5 | this.firstField = exampleBuilder.firstField; 6 | this.secondField = exampleBuilder.secondField; 7 | } 8 | 9 | public static ExampleBuilder builder() { 10 | return new ExampleBuilder(); 11 | } 12 | 13 | public static final class ExampleBuilder { 14 | private String firstField; 15 | private String secondField; 16 | 17 | private ExampleBuilder() { 18 | } 19 | 20 | public ExampleBuilder withFirstField(String firstField) { 21 | this.firstField = firstField; 22 | return this; 23 | } 24 | 25 | public ExampleBuilder withSecondField(String secondField) { 26 | this.secondField = secondField; 27 | return this; 28 | } 29 | 30 | public Example build() { 31 | return new Example(this); 32 | } 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/custom_method/removed_fields_output.tjava: -------------------------------------------------------------------------------- 1 | public class Example { 2 | String firstField; 3 | 4 | private Example(ExampleBuilder exampleBuilder) { 5 | this.firstField = exampleBuilder.firstField; 6 | } 7 | 8 | public static ExampleBuilder builder() { 9 | return new ExampleBuilder(); 10 | } 11 | 12 | public static final class ExampleBuilder { 13 | private String firstField; 14 | 15 | private ExampleBuilder() { 16 | } 17 | 18 | public ExampleBuilder withFirstField(String firstField) { 19 | this.firstField = firstField; 20 | return this; 21 | } 22 | 23 | public Example build() { 24 | return new Example(this); 25 | } 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/custom_method/stage_build_custom_method_input.tjava: -------------------------------------------------------------------------------- 1 | public class Example 2 | { 3 | List ids; 4 | 5 | private Example(ExampleBuilder exampleBuilder) { 6 | this.ids = exampleBuilder.ids; 7 | } 8 | 9 | public static IIdsStage builder() { 10 | return new ExampleBuilder(); 11 | } 12 | 13 | public interface IIdsStage { 14 | public IBuildStage withIds(List ids); 15 | } 16 | 17 | public interface IBuildStage { 18 | public Example build(); 19 | } 20 | 21 | public static final class ExampleBuilder implements IIdsStage, IBuildStage { 22 | private List ids; 23 | 24 | private ExampleBuilder() { 25 | } 26 | 27 | public IBuildStage addIds(String id) { 28 | this.ids.add(id); 29 | return this; 30 | } 31 | 32 | @Override 33 | public IBuildStage withIds(List ids) { 34 | this.ids = ids; 35 | return this; 36 | } 37 | 38 | @Override 39 | public Example build() { 40 | return new Example(this); 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/custom_method/stage_build_custom_method_output.tjava: -------------------------------------------------------------------------------- 1 | public class Example 2 | { 3 | List ids; 4 | 5 | private Example(ExampleBuilder exampleBuilder) { 6 | this.ids = exampleBuilder.ids; 7 | } 8 | 9 | public static IIdsStage builder() { 10 | return new ExampleBuilder(); 11 | } 12 | 13 | public interface IIdsStage { 14 | public IBuildStage withIds(List ids); 15 | } 16 | 17 | public interface IBuildStage { 18 | public Example build(); 19 | } 20 | 21 | public static final class ExampleBuilder implements IIdsStage, IBuildStage { 22 | private List ids; 23 | 24 | private ExampleBuilder() { 25 | } 26 | 27 | @Override 28 | public IBuildStage withIds(List ids) { 29 | this.ids = ids; 30 | return this; 31 | } 32 | 33 | public IBuildStage addIds(String id) { 34 | this.ids.add(id); 35 | return this; 36 | } 37 | 38 | @Override 39 | public Example build() { 40 | return new Example(this); 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/custom_method/ticket_example_input.tjava: -------------------------------------------------------------------------------- 1 | import java.util.UUID; 2 | import javax.annotation.processing.Generated; 3 | 4 | public class Example 5 | { 6 | UUID id; 7 | 8 | private Example(ExampleBuilder exampleBuilder) 9 | { 10 | this.id = exampleBuilder.id; 11 | } 12 | 13 | public static ExampleBuilder builder() 14 | { 15 | return new ExampleBuilder(); 16 | } 17 | 18 | public static final class ExampleBuilder 19 | { 20 | private UUID id; 21 | 22 | private ExampleBuilder() 23 | { 24 | } 25 | 26 | public ExampleBuilder withId(UUID id) 27 | { 28 | this.id = id; 29 | return this; 30 | } 31 | 32 | public ExampleBuilder withRandomId() 33 | { 34 | this.id = UUID.randomUUID(); 35 | return this; 36 | } 37 | 38 | public Example build() 39 | { 40 | return new Example(this); 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/custom_method/ticket_example_output.tjava: -------------------------------------------------------------------------------- 1 | import java.util.UUID; 2 | import javax.annotation.processing.Generated; 3 | 4 | public class Example 5 | { 6 | UUID id; 7 | 8 | private Example(ExampleBuilder exampleBuilder) 9 | { 10 | this.id = exampleBuilder.id; 11 | } 12 | 13 | public static ExampleBuilder builder() 14 | { 15 | return new ExampleBuilder(); 16 | } 17 | 18 | public static final class ExampleBuilder 19 | { 20 | private UUID id; 21 | 22 | private ExampleBuilder() 23 | { 24 | } 25 | 26 | public ExampleBuilder withId(UUID id) 27 | { 28 | this.id = id; 29 | return this; 30 | } 31 | 32 | public ExampleBuilder withRandomId() 33 | { 34 | this.id = UUID.randomUUID(); 35 | return this; 36 | } 37 | 38 | public Example build() 39 | { 40 | return new Example(this); 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/default_constructor/base_child_input.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.testpackage; 2 | 3 | public class TestClass extends TestSuperClass { 4 | private String childField; 5 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/default_constructor/base_super_input.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.testpackage; 2 | 3 | public class TestSuperClass { 4 | public String publicSuperClassField; 5 | String defaultSuperClassField; 6 | protected String protectedSuperClassField; 7 | private String privateSuperClassField; 8 | 9 | public TestSuperClass(String publicSuperClassField, String defaultSuperClassField, String protectedSuperClassField, 10 | String privateSuperClassField) { 11 | this.publicSuperClassField = publicSuperClassField; 12 | this.defaultSuperClassField = defaultSuperClassField; 13 | this.protectedSuperClassField = protectedSuperClassField; 14 | this.privateSuperClassField = privateSuperClassField; 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/default_constructor/mail_input.tjava: -------------------------------------------------------------------------------- 1 | ast.newModifier(ModifierKeyword.PRIVATE_KEYWORD)public class EmailMessage { 2 | private String from; 3 | private String to; 4 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/default_constructor/mail_input_with_existing_default_constructor.tjava: -------------------------------------------------------------------------------- 1 | public class EmailMessage { 2 | private String from; 3 | private String to; 4 | 5 | public EmailMessage() { 6 | } 7 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/default_constructor/mail_output_with_annotated_default_constructor.tjava: -------------------------------------------------------------------------------- 1 | import javax.annotation.Generated; 2 | 3 | public class EmailMessage { 4 | private String from; 5 | private String to; 6 | 7 | @Generated("SparkTools") 8 | private EmailMessage(Builder builder) { 9 | this.from = builder.from; 10 | this.to = builder.to; 11 | } 12 | 13 | @Generated("SparkTools") 14 | public EmailMessage() { 15 | } 16 | 17 | @Generated("SparkTools") 18 | public static Builder builder() { 19 | return new Builder(); 20 | } 21 | 22 | @Generated("SparkTools") 23 | public static final class Builder { 24 | private String from; 25 | private String to; 26 | 27 | private Builder() { 28 | } 29 | 30 | public Builder withFrom(String from) { 31 | this.from = from; 32 | return this; 33 | } 34 | 35 | public Builder withTo(String to) { 36 | this.to = to; 37 | return this; 38 | } 39 | 40 | public EmailMessage build() { 41 | return new EmailMessage(this); 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/default_constructor/mail_output_with_default_constructor.tjava: -------------------------------------------------------------------------------- 1 | public class EmailMessage { 2 | private String from; 3 | private String to; 4 | 5 | private EmailMessage(Builder builder) { 6 | this.from = builder.from; 7 | this.to = builder.to; 8 | } 9 | 10 | public EmailMessage() { 11 | } 12 | 13 | public static Builder builder() { 14 | return new Builder(); 15 | } 16 | 17 | public static final class Builder { 18 | private String from; 19 | private String to; 20 | 21 | private Builder() { 22 | } 23 | 24 | public Builder withFrom(String from) { 25 | this.from = from; 26 | return this; 27 | } 28 | 29 | public Builder withTo(String to) { 30 | this.to = to; 31 | return this; 32 | } 33 | 34 | public EmailMessage build() { 35 | return new EmailMessage(this); 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/default_constructor/mail_output_without_default_constructor.tjava: -------------------------------------------------------------------------------- 1 | public class EmailMessage { 2 | private String from; 3 | private String to; 4 | 5 | private EmailMessage(Builder builder) { 6 | this.from = builder.from; 7 | this.to = builder.to; 8 | } 9 | 10 | public static Builder builder() { 11 | return new Builder(); 12 | } 13 | 14 | public static final class Builder { 15 | private String from; 16 | private String to; 17 | 18 | private Builder() { 19 | } 20 | 21 | public Builder withFrom(String from) { 22 | this.from = from; 23 | return this; 24 | } 25 | 26 | public Builder withTo(String to) { 27 | this.to = to; 28 | return this; 29 | } 30 | 31 | public EmailMessage build() { 32 | return new EmailMessage(this); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/default_constructor/mail_with_staged_builder_output.tjava: -------------------------------------------------------------------------------- 1 | public class EmailMessage { 2 | private String from; 3 | private String to; 4 | 5 | private EmailMessage(Builder builder) { 6 | this.from = builder.from; 7 | this.to = builder.to; 8 | } 9 | 10 | public EmailMessage() { 11 | } 12 | 13 | public static IFromStage builder() { 14 | return new Builder(); 15 | } 16 | 17 | public interface IFromStage { 18 | public IToStage withFrom(String from); 19 | } 20 | 21 | public interface IToStage { 22 | public IBuildStage withTo(String to); 23 | } 24 | 25 | public interface IBuildStage { 26 | public EmailMessage build(); 27 | } 28 | 29 | public static final class Builder implements IFromStage, IToStage, IBuildStage { 30 | private String from; 31 | private String to; 32 | 33 | private Builder() { 34 | } 35 | 36 | @Override 37 | public IToStage withFrom(String from) { 38 | this.from = from; 39 | return this; 40 | } 41 | 42 | @Override 43 | public IBuildStage withTo(String to) { 44 | this.to = to; 45 | return this; 46 | } 47 | 48 | @Override 49 | public EmailMessage build() { 50 | return new EmailMessage(this); 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/default_value/regular_builder_default_value_input.tjava: -------------------------------------------------------------------------------- 1 | import java.util.Collection; 2 | import java.util.Collections; 3 | import java.util.List; 4 | 5 | public class Example{ 6 | 7 | private int intData = 5; 8 | private Collection texts = List.of("default"); 9 | private String noData; 10 | 11 | public int getIntData(){ 12 | return this.intData; 13 | } 14 | 15 | public Collection getTexts(){ 16 | return this.texts; 17 | } 18 | 19 | public String getNoData(){ 20 | return this.noData; 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/default_value/regular_builder_default_value_output.tjava: -------------------------------------------------------------------------------- 1 | import java.util.Collection; 2 | import java.util.Collections; 3 | import java.util.List; 4 | 5 | import javax.annotation.Generated; 6 | 7 | public class Example{ 8 | 9 | private int intData = 5; 10 | private Collection texts = List.of("default"); 11 | private String noData; 12 | 13 | @Generated("SparkTools") 14 | private Example(Builder builder){ 15 | this.intData = builder.intData; 16 | this.texts = builder.texts; 17 | this.noData = builder.noData; 18 | } 19 | 20 | public int getIntData(){ 21 | return this.intData; 22 | } 23 | 24 | public Collection getTexts(){ 25 | return this.texts; 26 | } 27 | 28 | public String getNoData(){ 29 | return this.noData; 30 | } 31 | 32 | @Generated("SparkTools") 33 | public static Builder builder(){ 34 | return new Builder(); 35 | } 36 | 37 | @Generated("SparkTools") 38 | public static final class Builder{ 39 | private int intData = 5; 40 | private Collection texts = List.of("default"); 41 | private String noData; 42 | 43 | private Builder(){ 44 | } 45 | 46 | public Builder withIntData(int intData){ 47 | this.intData = intData; 48 | return this; 49 | } 50 | 51 | public Builder withTexts(Collection texts){ 52 | this.texts = texts; 53 | return this; 54 | } 55 | 56 | public Builder withNoData(String noData){ 57 | this.noData = noData; 58 | return this; 59 | } 60 | 61 | public Example build(){ 62 | return new Example(this); 63 | } 64 | } 65 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/default_value/regular_builder_default_value_with_disabled_option_and_enabled_empty_output.tjava: -------------------------------------------------------------------------------- 1 | import java.util.Collection; 2 | import java.util.Collections; 3 | import java.util.List; 4 | 5 | import javax.annotation.Generated; 6 | 7 | public class Example{ 8 | 9 | private int intData = 5; 10 | private Collection texts = List.of("default"); 11 | private String noData; 12 | 13 | @Generated("SparkTools") 14 | private Example(Builder builder){ 15 | this.intData = builder.intData; 16 | this.texts = builder.texts; 17 | this.noData = builder.noData; 18 | } 19 | 20 | public int getIntData(){ 21 | return this.intData; 22 | } 23 | 24 | public Collection getTexts(){ 25 | return this.texts; 26 | } 27 | 28 | public String getNoData(){ 29 | return this.noData; 30 | } 31 | 32 | @Generated("SparkTools") 33 | public static Builder builder(){ 34 | return new Builder(); 35 | } 36 | 37 | @Generated("SparkTools") 38 | public static final class Builder{ 39 | private int intData; 40 | private Collection texts = Collections.emptyList(); 41 | private String noData; 42 | 43 | private Builder(){ 44 | } 45 | 46 | public Builder withIntData(int intData){ 47 | this.intData = intData; 48 | return this; 49 | } 50 | 51 | public Builder withTexts(Collection texts){ 52 | this.texts = texts; 53 | return this; 54 | } 55 | 56 | public Builder withNoData(String noData){ 57 | this.noData = noData; 58 | return this; 59 | } 60 | 61 | public Example build(){ 62 | return new Example(this); 63 | } 64 | } 65 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/default_value/regular_builder_default_value_with_disabled_option_output.tjava: -------------------------------------------------------------------------------- 1 | import java.util.Collection; 2 | import java.util.Collections; 3 | import java.util.List; 4 | 5 | import javax.annotation.Generated; 6 | 7 | public class Example{ 8 | 9 | private int intData = 5; 10 | private Collection texts = List.of("default"); 11 | private String noData; 12 | 13 | @Generated("SparkTools") 14 | private Example(Builder builder){ 15 | this.intData = builder.intData; 16 | this.texts = builder.texts; 17 | this.noData = builder.noData; 18 | } 19 | 20 | public int getIntData(){ 21 | return this.intData; 22 | } 23 | 24 | public Collection getTexts(){ 25 | return this.texts; 26 | } 27 | 28 | public String getNoData(){ 29 | return this.noData; 30 | } 31 | 32 | @Generated("SparkTools") 33 | public static Builder builder(){ 34 | return new Builder(); 35 | } 36 | 37 | @Generated("SparkTools") 38 | public static final class Builder{ 39 | private int intData; 40 | private Collection texts; 41 | private String noData; 42 | 43 | private Builder(){ 44 | } 45 | 46 | public Builder withIntData(int intData){ 47 | this.intData = intData; 48 | return this; 49 | } 50 | 51 | public Builder withTexts(Collection texts){ 52 | this.texts = texts; 53 | return this; 54 | } 55 | 56 | public Builder withNoData(String noData){ 57 | this.noData = noData; 58 | return this; 59 | } 60 | 61 | public Example build(){ 62 | return new Example(this); 63 | } 64 | } 65 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/enum_class/class_with_enum_between_classes_first_output.tjava: -------------------------------------------------------------------------------- 1 | public class FirstClass { 2 | private String firstField; 3 | private String secondField; 4 | 5 | private FirstClass(Builder builder) { 6 | this.firstField = builder.firstField; 7 | this.secondField = builder.secondField; 8 | } 9 | 10 | public static Builder builder() { 11 | return new Builder(); 12 | } 13 | 14 | public static final class Builder { 15 | private String firstField; 16 | private String secondField; 17 | 18 | private Builder() { 19 | } 20 | 21 | public Builder withFirstField(String firstField) { 22 | this.firstField = firstField; 23 | return this; 24 | } 25 | 26 | public Builder withSecondField(String secondField) { 27 | this.secondField = secondField; 28 | return this; 29 | } 30 | 31 | public FirstClass build() { 32 | return new FirstClass(this); 33 | } 34 | } 35 | } 36 | 37 | enum SomeEnum { 38 | } 39 | 40 | class SecondClass { 41 | private String sec; 42 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/enum_class/class_with_enum_between_classes_input.tjava: -------------------------------------------------------------------------------- 1 | 2 | public class FirstClass { 3 | private String firstField; 4 | private String secondField; 5 | } 6 | 7 | enum SomeEnum { 8 | 9 | } 10 | 11 | class SecondClass { 12 | private String sec; 13 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/enum_class/class_with_enum_between_classes_second_output.tjava: -------------------------------------------------------------------------------- 1 | public class FirstClass { 2 | private String firstField; 3 | private String secondField; 4 | } 5 | 6 | enum SomeEnum { 7 | } 8 | 9 | class SecondClass { 10 | private String sec; 11 | 12 | private SecondClass(Builder builder) { 13 | this.sec = builder.sec; 14 | } 15 | 16 | public static Builder builder() { 17 | return new Builder(); 18 | } 19 | 20 | public static final class Builder { 21 | private String sec; 22 | 23 | private Builder() { 24 | } 25 | 26 | public Builder withSec(String sec) { 27 | this.sec = sec; 28 | return this; 29 | } 30 | 31 | public SecondClass build() { 32 | return new SecondClass(this); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/enum_class/class_with_enum_input.tjava: -------------------------------------------------------------------------------- 1 | 2 | enum FirstEnum { 3 | 4 | } 5 | 6 | public class ClassWithEnum { 7 | private String firstField; 8 | private String secondField; 9 | } 10 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/enum_class/class_with_enum_output.tjava: -------------------------------------------------------------------------------- 1 | enum FirstEnum { 2 | } 3 | 4 | public class ClassWithEnum { 5 | private String firstField; 6 | private String secondField; 7 | 8 | private ClassWithEnum(Builder builder) { 9 | this.firstField = builder.firstField; 10 | this.secondField = builder.secondField; 11 | } 12 | 13 | public static Builder builder() { 14 | return new Builder(); 15 | } 16 | 17 | public static final class Builder { 18 | private String firstField; 19 | private String secondField; 20 | 21 | private Builder() { 22 | } 23 | 24 | public Builder withFirstField(String firstField) { 25 | this.firstField = firstField; 26 | return this; 27 | } 28 | 29 | public Builder withSecondField(String secondField) { 30 | this.secondField = secondField; 31 | return this; 32 | } 33 | 34 | public ClassWithEnum build() { 35 | return new ClassWithEnum(this); 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/enum_class/class_with_enum_staged_output.tjava: -------------------------------------------------------------------------------- 1 | enum FirstEnum { 2 | } 3 | 4 | public class ClassWithEnum { 5 | private String firstField; 6 | private String secondField; 7 | 8 | private ClassWithEnum(Builder builder) { 9 | this.firstField = builder.firstField; 10 | this.secondField = builder.secondField; 11 | } 12 | 13 | public static IFirstFieldStage builder() { 14 | return new Builder(); 15 | } 16 | 17 | public interface IFirstFieldStage { 18 | public ISecondFieldStage withFirstField(String firstField); 19 | } 20 | 21 | public interface ISecondFieldStage { 22 | public IBuildStage withSecondField(String secondField); 23 | } 24 | 25 | public interface IBuildStage { 26 | public ClassWithEnum build(); 27 | } 28 | 29 | public static final class Builder implements IFirstFieldStage, ISecondFieldStage, IBuildStage { 30 | private String firstField; 31 | private String secondField; 32 | 33 | private Builder() { 34 | } 35 | 36 | @Override 37 | public ISecondFieldStage withFirstField(String firstField) { 38 | this.firstField = firstField; 39 | return this; 40 | } 41 | 42 | @Override 43 | public IBuildStage withSecondField(String secondField) { 44 | this.secondField = secondField; 45 | return this; 46 | } 47 | 48 | @Override 49 | public ClassWithEnum build() { 50 | return new ClassWithEnum(this); 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/enum_class/file_with_only_enum_input.tjava: -------------------------------------------------------------------------------- 1 | 2 | enum FirstEnum { 3 | 4 | } 5 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/field_with_underscore_input.tjava: -------------------------------------------------------------------------------- 1 | public class TestClass { 2 | private int _testField; 3 | } 4 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/field_with_underscore_output.tjava: -------------------------------------------------------------------------------- 1 | public class TestClass { 2 | private int _testField; 3 | 4 | private TestClass(Builder builder) { 5 | this._testField = builder._testField; 6 | } 7 | 8 | public static Builder builder() { 9 | return new Builder(); 10 | } 11 | 12 | public static final class Builder { 13 | private int _testField; 14 | 15 | private Builder() { 16 | } 17 | 18 | public Builder withTestField(int testField) { 19 | this._testField = testField; 20 | return this; 21 | } 22 | 23 | public TestClass build() { 24 | return new TestClass(this); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/field_with_underscore_staged_output.tjava: -------------------------------------------------------------------------------- 1 | public class TestClass { 2 | private int _testField; 3 | 4 | private TestClass(Builder builder) { 5 | this._testField = builder._testField; 6 | } 7 | 8 | public static ITestFieldStage builder() { 9 | return new Builder(); 10 | } 11 | 12 | public interface ITestFieldStage { 13 | public IBuildStage withTestField(int testField); 14 | } 15 | 16 | public interface IBuildStage { 17 | public TestClass build(); 18 | } 19 | 20 | public static final class Builder implements ITestFieldStage, IBuildStage { 21 | private int _testField; 22 | 23 | private Builder() { 24 | } 25 | 26 | @Override 27 | public IBuildStage withTestField(int testField) { 28 | this._testField = testField; 29 | return this; 30 | } 31 | 32 | @Override 33 | public TestClass build() { 34 | return new TestClass(this); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/import_and_package_base_output.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.test; 2 | 3 | import java.util.List; 4 | 5 | public class TestClass { 6 | private List list; 7 | private String other; 8 | 9 | private TestClass(Builder builder) { 10 | this.list = builder.list; 11 | this.other = builder.other; 12 | } 13 | 14 | public static Builder builder() { 15 | return new Builder(); 16 | } 17 | 18 | public static final class Builder { 19 | private List list; 20 | private String other; 21 | 22 | private Builder() { 23 | } 24 | 25 | public Builder withList(List list) { 26 | this.list = list; 27 | return this; 28 | } 29 | 30 | public Builder withOther(String other) { 31 | this.other = other; 32 | return this; 33 | } 34 | 35 | public TestClass build() { 36 | return new TestClass(this); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/import_and_package_input.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.test; 2 | 3 | import java.util.List; 4 | 5 | public class TestClass { 6 | private List list; 7 | private String other; 8 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/import_and_package_output_with_nonnull.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.test; 2 | 3 | import java.util.List; 4 | import javax.annotation.Nonnull; 5 | 6 | public class TestClass { 7 | private List list; 8 | private String other; 9 | 10 | private TestClass(Builder builder) { 11 | this.list = builder.list; 12 | this.other = builder.other; 13 | } 14 | 15 | public static Builder builder() { 16 | return new Builder(); 17 | } 18 | 19 | public static final class Builder { 20 | private List list; 21 | private String other; 22 | 23 | private Builder() { 24 | } 25 | 26 | public Builder withList(@Nonnull List list) { 27 | this.list = list; 28 | return this; 29 | } 30 | 31 | public Builder withOther(@Nonnull String other) { 32 | this.other = other; 33 | return this; 34 | } 35 | 36 | public TestClass build() { 37 | return new TestClass(this); 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/jackson/mail_input.tjava: -------------------------------------------------------------------------------- 1 | public class EmailMessage { 2 | private String from; 3 | private String to; 4 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/jackson/mail_with_changed_build_method_output.tjava: -------------------------------------------------------------------------------- 1 | import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; 2 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 3 | 4 | @JsonDeserialize(builder = EmailMessage.Builder.class) 5 | public class EmailMessage { 6 | private String from; 7 | private String to; 8 | 9 | private EmailMessage(Builder builder) { 10 | this.from = builder.from; 11 | this.to = builder.to; 12 | } 13 | 14 | public static Builder builder() { 15 | return new Builder(); 16 | } 17 | 18 | @JsonPOJOBuilder(buildMethodName="customBuild",withPrefix="asd") 19 | public static final class Builder { 20 | private String from; 21 | private String to; 22 | 23 | private Builder() { 24 | } 25 | 26 | public Builder asdFrom(String from) { 27 | this.from = from; 28 | return this; 29 | } 30 | 31 | public Builder asdTo(String to) { 32 | this.to = to; 33 | return this; 34 | } 35 | 36 | public EmailMessage customBuild() { 37 | return new EmailMessage(this); 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/jackson/mail_with_changed_builder_output.tjava: -------------------------------------------------------------------------------- 1 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 2 | 3 | @JsonDeserialize(builder = EmailMessage.EmailMessageBuilder.class) 4 | public class EmailMessage { 5 | private String from; 6 | private String to; 7 | 8 | private EmailMessage(EmailMessageBuilder emailMessageBuilder) { 9 | this.from = emailMessageBuilder.from; 10 | this.to = emailMessageBuilder.to; 11 | } 12 | 13 | public static EmailMessageBuilder builder() { 14 | return new EmailMessageBuilder(); 15 | } 16 | 17 | public static final class EmailMessageBuilder { 18 | private String from; 19 | private String to; 20 | 21 | private EmailMessageBuilder() { 22 | } 23 | 24 | public EmailMessageBuilder withFrom(String from) { 25 | this.from = from; 26 | return this; 27 | } 28 | 29 | public EmailMessageBuilder withTo(String to) { 30 | this.to = to; 31 | return this; 32 | } 33 | 34 | public EmailMessage build() { 35 | return new EmailMessage(this); 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/jackson/mail_with_changed_with_method_output.tjava: -------------------------------------------------------------------------------- 1 | import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; 2 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 3 | 4 | @JsonDeserialize(builder = EmailMessage.Builder.class) 5 | public class EmailMessage { 6 | private String from; 7 | private String to; 8 | 9 | private EmailMessage(Builder builder) { 10 | this.from = builder.from; 11 | this.to = builder.to; 12 | } 13 | 14 | public static Builder builder() { 15 | return new Builder(); 16 | } 17 | 18 | @JsonPOJOBuilder(buildMethodName="build", withPrefix="") 19 | public static final class Builder { 20 | private String from; 21 | private String to; 22 | 23 | private Builder() { 24 | } 25 | 26 | public Builder from(String from) { 27 | this.from = from; 28 | return this; 29 | } 30 | 31 | public Builder to(String to) { 32 | this.to = to; 33 | return this; 34 | } 35 | 36 | public EmailMessage build() { 37 | return new EmailMessage(this); 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/jackson/mail_with_default_methodnames_output.tjava: -------------------------------------------------------------------------------- 1 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 2 | 3 | @JsonDeserialize(builder = EmailMessage.Builder.class) 4 | public class EmailMessage { 5 | private String from; 6 | private String to; 7 | 8 | private EmailMessage(Builder builder) { 9 | this.from = builder.from; 10 | this.to = builder.to; 11 | } 12 | 13 | public static Builder builder() { 14 | return new Builder(); 15 | } 16 | 17 | public static final class Builder { 18 | private String from; 19 | private String to; 20 | 21 | private Builder() { 22 | } 23 | 24 | public Builder withFrom(String from) { 25 | this.from = from; 26 | return this; 27 | } 28 | 29 | public Builder withTo(String to) { 30 | this.to = to; 31 | return this; 32 | } 33 | 34 | public EmailMessage build() { 35 | return new EmailMessage(this); 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/jackson/mail_with_no_jackson_annotations.tjava: -------------------------------------------------------------------------------- 1 | public class EmailMessage { 2 | private String from; 3 | private String to; 4 | 5 | private EmailMessage(Builder builder) { 6 | this.from = builder.from; 7 | this.to = builder.to; 8 | } 9 | 10 | public static Builder builder() { 11 | return new Builder(); 12 | } 13 | 14 | public static final class Builder { 15 | private String from; 16 | private String to; 17 | 18 | private Builder() { 19 | } 20 | 21 | public Builder withFrom(String from) { 22 | this.from = from; 23 | return this; 24 | } 25 | 26 | public Builder withTo(String to) { 27 | this.to = to; 28 | return this; 29 | } 30 | 31 | public EmailMessage build() { 32 | return new EmailMessage(this); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/jackson/mail_with_staged_builder_output.tjava: -------------------------------------------------------------------------------- 1 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 2 | 3 | @JsonDeserialize(builder = EmailMessage.Builder.class) 4 | public class EmailMessage { 5 | private String from; 6 | private String to; 7 | 8 | private EmailMessage(Builder builder) { 9 | this.from = builder.from; 10 | this.to = builder.to; 11 | } 12 | 13 | public static IFromStage builder() { 14 | return new Builder(); 15 | } 16 | 17 | public interface IFromStage { 18 | public IToStage withFrom(String from); 19 | } 20 | 21 | public interface IToStage { 22 | public IBuildStage withTo(String to); 23 | } 24 | 25 | public interface IBuildStage { 26 | public EmailMessage build(); 27 | } 28 | 29 | public static final class Builder implements IFromStage, IToStage, IBuildStage { 30 | private String from; 31 | private String to; 32 | 33 | private Builder() { 34 | } 35 | 36 | @Override 37 | public IToStage withFrom(String from) { 38 | this.from = from; 39 | return this; 40 | } 41 | 42 | @Override 43 | public IBuildStage withTo(String to) { 44 | this.to = to; 45 | return this; 46 | } 47 | 48 | @Override 49 | public EmailMessage build() { 50 | return new EmailMessage(this); 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/jakarta/input.tjava: -------------------------------------------------------------------------------- 1 | public class TestClass { 2 | private String testField; 3 | private Integer data; 4 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/jakarta/output_with_jakarta_annotations.tjava: -------------------------------------------------------------------------------- 1 | import jakarta.annotation.Nonnull; 2 | import jakarta.annotation.Generated; 3 | 4 | public class TestClass { 5 | private String testField; 6 | private Integer data; 7 | 8 | @Generated("SparkTools") 9 | private TestClass(Builder builder) { 10 | this.testField = builder.testField; 11 | this.data = builder.data; 12 | } 13 | 14 | @Generated("SparkTools") 15 | public static Builder builder() { 16 | return new Builder(); 17 | } 18 | 19 | @Generated("SparkTools") 20 | public static final class Builder { 21 | private String testField; 22 | private Integer data; 23 | 24 | private Builder() { 25 | } 26 | 27 | @Nonnull 28 | public Builder withTestField(String testField) { 29 | this.testField = testField; 30 | return this; 31 | } 32 | 33 | @Nonnull 34 | public Builder withData(Integer data) { 35 | this.data = data; 36 | return this; 37 | } 38 | 39 | @Nonnull 40 | public TestClass build() { 41 | return new TestClass(this); 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/jakarta/output_with_javax_annotations.tjava: -------------------------------------------------------------------------------- 1 | import javax.annotation.Nonnull; 2 | import javax.annotation.Generated; 3 | 4 | public class TestClass { 5 | private String testField; 6 | private Integer data; 7 | 8 | @Generated("SparkTools") 9 | private TestClass(Builder builder) { 10 | this.testField = builder.testField; 11 | this.data = builder.data; 12 | } 13 | 14 | @Generated("SparkTools") 15 | public static Builder builder() { 16 | return new Builder(); 17 | } 18 | 19 | @Generated("SparkTools") 20 | public static final class Builder { 21 | private String testField; 22 | private Integer data; 23 | 24 | private Builder() { 25 | } 26 | 27 | @Nonnull 28 | public Builder withTestField(String testField) { 29 | this.testField = testField; 30 | return this; 31 | } 32 | 33 | @Nonnull 34 | public Builder withData(Integer data) { 35 | this.data = data; 36 | return this; 37 | } 38 | 39 | @Nonnull 40 | public TestClass build() { 41 | return new TestClass(this); 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/jakarta/output_with_no_annotations.tjava: -------------------------------------------------------------------------------- 1 | 2 | public class TestClass { 3 | private String testField; 4 | private Integer data; 5 | 6 | private TestClass(Builder builder) { 7 | this.testField = builder.testField; 8 | this.data = builder.data; 9 | } 10 | 11 | public static Builder builder() { 12 | return new Builder(); 13 | } 14 | 15 | public static final class Builder { 16 | private String testField; 17 | private Integer data; 18 | 19 | private Builder() { 20 | } 21 | 22 | public Builder withTestField(String testField) { 23 | this.testField = testField; 24 | return this; 25 | } 26 | 27 | public Builder withData(Integer data) { 28 | this.data = data; 29 | return this; 30 | } 31 | 32 | public TestClass build() { 33 | return new TestClass(this); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/mail_input.tjava: -------------------------------------------------------------------------------- 1 | public class EmailMessage { 2 | private String from; 3 | private String to; 4 | private String subject; 5 | private String content; 6 | private String mimeType; 7 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/multi_class_output_with_nested_static_class_builder.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark; 2 | 3 | public class TestClass { 4 | private String mainClassField; 5 | 6 | static class NestedStaticClass { 7 | private String nestedStringField; 8 | 9 | private NestedStaticClass(Builder builder) { 10 | this.nestedStringField = builder.nestedStringField; 11 | } 12 | 13 | public static Builder builder() { 14 | return new Builder(); 15 | } 16 | 17 | public static final class Builder { 18 | private String nestedStringField; 19 | 20 | private Builder() { 21 | } 22 | 23 | public Builder withNestedStringField(String nestedStringField) { 24 | this.nestedStringField = nestedStringField; 25 | return this; 26 | } 27 | 28 | public NestedStaticClass build() { 29 | return new NestedStaticClass(this); 30 | } 31 | } 32 | } 33 | 34 | class NestedNonStaticClass { 35 | private String NestedNonStaticClassField; 36 | } 37 | } 38 | 39 | class SecondaryClass { 40 | private String secondaryClassField; 41 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/multi_classes_input.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark; 2 | 3 | public class TestClass { 4 | private String mainClassField; 5 | 6 | static class NestedStaticClass { 7 | private String nestedStringField; 8 | } 9 | 10 | class NestedNonStaticClass { 11 | private String NestedNonStaticClassField; 12 | } 13 | } 14 | 15 | class SecondaryClass { 16 | private String secondaryClassField; 17 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/multi_classes_output_with_main_class_generated_builder.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark; 2 | 3 | public class TestClass { 4 | private String mainClassField; 5 | 6 | private TestClass(Builder builder) { 7 | this.mainClassField = builder.mainClassField; 8 | } 9 | 10 | static class NestedStaticClass { 11 | private String nestedStringField; 12 | } 13 | 14 | class NestedNonStaticClass { 15 | private String NestedNonStaticClassField; 16 | } 17 | 18 | public static Builder builder() { 19 | return new Builder(); 20 | } 21 | 22 | public static final class Builder { 23 | private String mainClassField; 24 | 25 | private Builder() { 26 | } 27 | 28 | public Builder withMainClassField(String mainClassField) { 29 | this.mainClassField = mainClassField; 30 | return this; 31 | } 32 | 33 | public TestClass build() { 34 | return new TestClass(this); 35 | } 36 | } 37 | } 38 | 39 | class SecondaryClass { 40 | private String secondaryClassField; 41 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/multi_classes_output_with_secondary_class_builder.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark; 2 | 3 | public class TestClass { 4 | private String mainClassField; 5 | 6 | static class NestedStaticClass { 7 | private String nestedStringField; 8 | } 9 | 10 | class NestedNonStaticClass { 11 | private String NestedNonStaticClassField; 12 | } 13 | } 14 | 15 | class SecondaryClass { 16 | private String secondaryClassField; 17 | 18 | private SecondaryClass(Builder builder) { 19 | this.secondaryClassField = builder.secondaryClassField; 20 | } 21 | 22 | public static Builder builder() { 23 | return new Builder(); 24 | } 25 | 26 | public static final class Builder { 27 | private String secondaryClassField; 28 | 29 | private Builder() { 30 | } 31 | 32 | public Builder withSecondaryClassField(String secondaryClassField) { 33 | this.secondaryClassField = secondaryClassField; 34 | return this; 35 | } 36 | 37 | public SecondaryClass build() { 38 | return new SecondaryClass(this); 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/multi_field_input.tjava: -------------------------------------------------------------------------------- 1 | public class TestClass { 2 | private String testField; 3 | private Integer data; 4 | private long something; 5 | private List list; 6 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/multi_field_output.tjava: -------------------------------------------------------------------------------- 1 | public class TestClass { 2 | private String testField; 3 | private Integer data; 4 | private long something; 5 | private List list; 6 | 7 | private TestClass(Builder builder) { 8 | this.testField = builder.testField; 9 | this.data = builder.data; 10 | this.something = builder.something; 11 | this.list = builder.list; 12 | } 13 | 14 | public static Builder builder() { 15 | return new Builder(); 16 | } 17 | 18 | public static final class Builder { 19 | private String testField; 20 | private Integer data; 21 | private long something; 22 | private List list; 23 | 24 | private Builder() { 25 | } 26 | 27 | public Builder withTestField(String testField) { 28 | this.testField = testField; 29 | return this; 30 | } 31 | 32 | public Builder withData(Integer data) { 33 | this.data = data; 34 | return this; 35 | } 36 | 37 | public Builder withSomething(long something) { 38 | this.something = something; 39 | return this; 40 | } 41 | 42 | public Builder withList(List list) { 43 | this.list = list; 44 | return this; 45 | } 46 | 47 | public TestClass build() { 48 | return new TestClass(this); 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/multi_field_output_with_class_javadoc.tjava: -------------------------------------------------------------------------------- 1 | public class TestClass { 2 | private String testField; 3 | private Integer data; 4 | private long something; 5 | private List list; 6 | 7 | private TestClass(Builder builder) { 8 | this.testField = builder.testField; 9 | this.data = builder.data; 10 | this.something = builder.something; 11 | this.list = builder.list; 12 | } 13 | 14 | public static Builder builder() { 15 | return new Builder(); 16 | } 17 | 18 | /** 19 | * Builder to build {@link TestClass}. 20 | */ 21 | public static final class Builder { 22 | private String testField; 23 | private Integer data; 24 | private long something; 25 | private List list; 26 | 27 | private Builder() { 28 | } 29 | 30 | public Builder withTestField(String testField) { 31 | this.testField = testField; 32 | return this; 33 | } 34 | 35 | public Builder withData(Integer data) { 36 | this.data = data; 37 | return this; 38 | } 39 | 40 | public Builder withSomething(long something) { 41 | this.something = something; 42 | return this; 43 | } 44 | 45 | public Builder withList(List list) { 46 | this.list = list; 47 | return this; 48 | } 49 | 50 | public TestClass build() { 51 | return new TestClass(this); 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/multi_field_output_with_method_nonnull.tjava: -------------------------------------------------------------------------------- 1 | import javax.annotation.Nonnull; 2 | 3 | public class TestClass { 4 | private String testField; 5 | private Integer data; 6 | private long something; 7 | private List list; 8 | 9 | private TestClass(Builder builder) { 10 | this.testField = builder.testField; 11 | this.data = builder.data; 12 | this.something = builder.something; 13 | this.list = builder.list; 14 | } 15 | 16 | public static Builder builder() { 17 | return new Builder(); 18 | } 19 | 20 | public static final class Builder { 21 | private String testField; 22 | private Integer data; 23 | private long something; 24 | private List list; 25 | 26 | private Builder() { 27 | } 28 | 29 | public Builder withTestField(@Nonnull String testField) { 30 | this.testField = testField; 31 | return this; 32 | } 33 | 34 | public Builder withData(@Nonnull Integer data) { 35 | this.data = data; 36 | return this; 37 | } 38 | 39 | public Builder withSomething(@Nonnull long something) { 40 | this.something = something; 41 | return this; 42 | } 43 | 44 | public Builder withList(@Nonnull List list) { 45 | this.list = list; 46 | return this; 47 | } 48 | 49 | public TestClass build() { 50 | return new TestClass(this); 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/multi_field_output_with_no_fields_included.tjava: -------------------------------------------------------------------------------- 1 | public class TestClass { 2 | private String testField; 3 | private Integer data; 4 | private long something; 5 | private List list; 6 | 7 | private TestClass(Builder builder) { 8 | } 9 | 10 | public static Builder builder() { 11 | return new Builder(); 12 | } 13 | 14 | public static final class Builder { 15 | private Builder() { 16 | } 17 | 18 | public TestClass build() { 19 | return new TestClass(this); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/multi_field_output_with_only_first_two_field_included.tjava: -------------------------------------------------------------------------------- 1 | public class TestClass { 2 | private String testField; 3 | private Integer data; 4 | private long something; 5 | private List list; 6 | 7 | private TestClass(Builder builder) { 8 | this.testField = builder.testField; 9 | this.data = builder.data; 10 | } 11 | 12 | public static Builder builder() { 13 | return new Builder(); 14 | } 15 | 16 | public static final class Builder { 17 | private String testField; 18 | private Integer data; 19 | 20 | private Builder() { 21 | } 22 | 23 | public Builder withTestField(String testField) { 24 | this.testField = testField; 25 | return this; 26 | } 27 | 28 | public Builder withData(Integer data) { 29 | this.data = data; 30 | return this; 31 | } 32 | 33 | public TestClass build() { 34 | return new TestClass(this); 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/multi_field_staged_output_with_only_first_two_fields_selected.tjava: -------------------------------------------------------------------------------- 1 | public class TestClass { 2 | private String testField; 3 | private Integer data; 4 | private long something; 5 | private List list; 6 | 7 | private TestClass(Builder builder) { 8 | this.testField = builder.testField; 9 | this.data = builder.data; 10 | } 11 | 12 | public static ITestFieldStage builder() { 13 | return new Builder(); 14 | } 15 | 16 | public interface ITestFieldStage { 17 | public IDataStage withTestField(String testField); 18 | } 19 | 20 | public interface IDataStage { 21 | public IBuildStage withData(Integer data); 22 | } 23 | 24 | public interface IBuildStage { 25 | public TestClass build(); 26 | } 27 | 28 | public static final class Builder implements ITestFieldStage, IDataStage, IBuildStage { 29 | private String testField; 30 | private Integer data; 31 | 32 | private Builder() { 33 | } 34 | 35 | @Override 36 | public IDataStage withTestField(String testField) { 37 | this.testField = testField; 38 | return this; 39 | } 40 | 41 | @Override 42 | public IBuildStage withData(Integer data) { 43 | this.data = data; 44 | return this; 45 | } 46 | 47 | @Override 48 | public TestClass build() { 49 | return new TestClass(this); 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/nested_class_input.tjava: -------------------------------------------------------------------------------- 1 | 2 | public class TestClass { 3 | private String field; 4 | 5 | static class FirstNestedClass { 6 | String firstNestedClassField; 7 | 8 | static class SecondNestedClass { 9 | String secondNestedClassField; 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/nested_class_output_with_root_type_builder_generated.tjava: -------------------------------------------------------------------------------- 1 | public class TestClass { 2 | private String field; 3 | 4 | private TestClass(Builder builder) { 5 | this.field = builder.field; 6 | } 7 | 8 | static class FirstNestedClass { 9 | String firstNestedClassField; 10 | 11 | static class SecondNestedClass { 12 | String secondNestedClassField; 13 | } 14 | } 15 | 16 | public static Builder builder() { 17 | return new Builder(); 18 | } 19 | 20 | public static final class Builder { 21 | private String field; 22 | 23 | private Builder() { 24 | } 25 | 26 | public Builder withField(String field) { 27 | this.field = field; 28 | return this; 29 | } 30 | 31 | public TestClass build() { 32 | return new TestClass(this); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/nested_class_output_with_second_nested_generated.tjava: -------------------------------------------------------------------------------- 1 | public class TestClass { 2 | private String field; 3 | 4 | static class FirstNestedClass { 5 | String firstNestedClassField; 6 | 7 | static class SecondNestedClass { 8 | String secondNestedClassField; 9 | 10 | private SecondNestedClass(Builder builder) { 11 | this.secondNestedClassField = builder.secondNestedClassField; 12 | } 13 | 14 | public static Builder builder() { 15 | return new Builder(); 16 | } 17 | 18 | public static final class Builder { 19 | private String secondNestedClassField; 20 | 21 | private Builder() { 22 | } 23 | 24 | public Builder withSecondNestedClassField(String secondNestedClassField) { 25 | this.secondNestedClassField = secondNestedClassField; 26 | return this; 27 | } 28 | 29 | public SecondNestedClass build() { 30 | return new SecondNestedClass(this); 31 | } 32 | } 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/no_field_input.tjava: -------------------------------------------------------------------------------- 1 | public class TestClass { 2 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/no_field_output.tjava: -------------------------------------------------------------------------------- 1 | public class TestClass { 2 | private TestClass(Builder builder) { 3 | } 4 | 5 | public static Builder builder() { 6 | return new Builder(); 7 | } 8 | 9 | public static final class Builder { 10 | private Builder() { 11 | } 12 | 13 | public TestClass build() { 14 | return new TestClass(this); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/no_field_staged_output.tjava: -------------------------------------------------------------------------------- 1 | public class TestClass { 2 | private TestClass(Builder builder) { 3 | } 4 | 5 | public static IBuildStage builder() { 6 | return new Builder(); 7 | } 8 | 9 | public interface IBuildStage { 10 | public TestClass build(); 11 | } 12 | 13 | public static final class Builder implements IBuildStage { 14 | private Builder() { 15 | } 16 | 17 | @Override 18 | public TestClass build() { 19 | return new TestClass(this); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/optional_containing_input.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.test; 2 | 3 | import java.util.Optional; 4 | 5 | public class Mail { 6 | private String from; 7 | private Optional optional; 8 | private java.util.Optional secondOptional; 9 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/optional_containing_output.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.test; 2 | 3 | import java.util.Optional; 4 | 5 | public class Mail { 6 | private String from; 7 | private Optional optional; 8 | private java.util.Optional secondOptional; 9 | 10 | private Mail(Builder builder) { 11 | this.from = builder.from; 12 | this.optional = builder.optional; 13 | this.secondOptional = builder.secondOptional; 14 | } 15 | 16 | public static Builder builder() { 17 | return new Builder(); 18 | } 19 | 20 | public static final class Builder { 21 | private String from; 22 | private Optional optional = Optional.empty(); 23 | private java.util.Optional secondOptional = Optional.empty(); 24 | 25 | private Builder() { 26 | } 27 | 28 | public Builder withFrom(String from) { 29 | this.from = from; 30 | return this; 31 | } 32 | 33 | public Builder withOptional(Optional optional) { 34 | this.optional = optional; 35 | return this; 36 | } 37 | 38 | public Builder withSecondOptional(java.util.Optional secondOptional) { 39 | this.secondOptional = secondOptional; 40 | return this; 41 | } 42 | 43 | public Mail build() { 44 | return new Mail(this); 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/optional_containing_output_with_disabled_optional_initialization.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.test; 2 | 3 | import java.util.Optional; 4 | 5 | public class Mail { 6 | private String from; 7 | private Optional optional; 8 | private java.util.Optional secondOptional; 9 | 10 | private Mail(Builder builder) { 11 | this.from = builder.from; 12 | this.optional = builder.optional; 13 | this.secondOptional = builder.secondOptional; 14 | } 15 | 16 | public static Builder builder() { 17 | return new Builder(); 18 | } 19 | 20 | public static final class Builder { 21 | private String from; 22 | private Optional optional; 23 | private java.util.Optional secondOptional; 24 | 25 | private Builder() { 26 | } 27 | 28 | public Builder withFrom(String from) { 29 | this.from = from; 30 | return this; 31 | } 32 | 33 | public Builder withOptional(Optional optional) { 34 | this.optional = optional; 35 | return this; 36 | } 37 | 38 | public Builder withSecondOptional(java.util.Optional secondOptional) { 39 | this.secondOptional = secondOptional; 40 | return this; 41 | } 42 | 43 | public Mail build() { 44 | return new Mail(this); 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/optional_without_import_input.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.test; 2 | 3 | public class Mail { 4 | private String from; 5 | private java.util.Optional optional; 6 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/optional_without_import_output.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.test; 2 | 3 | import java.util.Optional; 4 | 5 | public class Mail { 6 | private String from; 7 | private java.util.Optional optional; 8 | 9 | private Mail(Builder builder) { 10 | this.from = builder.from; 11 | this.optional = builder.optional; 12 | } 13 | 14 | public static Builder builder() { 15 | return new Builder(); 16 | } 17 | 18 | public static final class Builder { 19 | private String from; 20 | private java.util.Optional optional = Optional.empty(); 21 | 22 | private Builder() { 23 | } 24 | 25 | public Builder withFrom(String from) { 26 | this.from = from; 27 | return this; 28 | } 29 | 30 | public Builder withOptional(java.util.Optional optional) { 31 | this.optional = optional; 32 | return this; 33 | } 34 | 35 | public Mail build() { 36 | return new Mail(this); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/prefix_input.tjava: -------------------------------------------------------------------------------- 1 | public class TestClass { 2 | private String prefixTestField; 3 | private Integer noPrefixData; 4 | private int data; 5 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/prefix_output.tjava: -------------------------------------------------------------------------------- 1 | public class TestClass { 2 | private String prefixTestField; 3 | private Integer noPrefixData; 4 | private int data; 5 | 6 | private TestClass(Builder builder) { 7 | this.prefixTestField = builder.prefixTestField; 8 | this.noPrefixData = builder.noPrefixData; 9 | this.data = builder.data; 10 | } 11 | 12 | public static Builder builder() { 13 | return new Builder(); 14 | } 15 | 16 | public static final class Builder { 17 | private String prefixTestField; 18 | private Integer noPrefixData; 19 | private int data; 20 | 21 | private Builder() { 22 | } 23 | 24 | public Builder withTestField(String testField) { 25 | this.prefixTestField = testField; 26 | return this; 27 | } 28 | 29 | public Builder withNoPrefixData(Integer noPrefixData) { 30 | this.noPrefixData = noPrefixData; 31 | return this; 32 | } 33 | 34 | public Builder withData(int data) { 35 | this.data = data; 36 | return this; 37 | } 38 | 39 | public TestClass build() { 40 | return new TestClass(this); 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/prefix_suffix_input.tjava: -------------------------------------------------------------------------------- 1 | public class TestClass { 2 | private String prefixTestField; 3 | private Integer prefixDataSuffix; 4 | private int otherB; 5 | private long prefixSomething; 6 | private String noPrefixNorsuffix; 7 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/primitive_field_input.tjava: -------------------------------------------------------------------------------- 1 | public class TestClass { 2 | private int testField; 3 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/primitive_field_output.tjava: -------------------------------------------------------------------------------- 1 | public class TestClass { 2 | private int testField; 3 | 4 | private TestClass(Builder builder) { 5 | this.testField = builder.testField; 6 | } 7 | 8 | public static Builder builder() { 9 | return new Builder(); 10 | } 11 | 12 | public static final class Builder { 13 | private int testField; 14 | 15 | private Builder() { 16 | } 17 | 18 | public Builder withTestField(int testField) { 19 | this.testField = testField; 20 | return this; 21 | } 22 | 23 | public TestClass build() { 24 | return new TestClass(this); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/primitive_field_staged_output.tjava: -------------------------------------------------------------------------------- 1 | public class TestClass { 2 | private int testField; 3 | 4 | private TestClass(Builder builder) { 5 | this.testField = builder.testField; 6 | } 7 | 8 | public static ITestFieldStage builder() { 9 | return new Builder(); 10 | } 11 | 12 | public interface ITestFieldStage { 13 | public IBuildStage withTestField(int testField); 14 | } 15 | 16 | public interface IBuildStage { 17 | public TestClass build(); 18 | } 19 | 20 | public static final class Builder implements ITestFieldStage, IBuildStage { 21 | private int testField; 22 | 23 | private Builder() { 24 | } 25 | 26 | @Override 27 | public IBuildStage withTestField(int testField) { 28 | this.testField = testField; 29 | return this; 30 | } 31 | 32 | @Override 33 | public TestClass build() { 34 | return new TestClass(this); 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/public_constructor_with_mandatory_fields/gh_input.tjava: -------------------------------------------------------------------------------- 1 | public class BuilderTest { 2 | private String value1; 3 | private String value2; 4 | private String value3; 5 | 6 | public String getValue1() { 7 | return value1; 8 | } 9 | public void setValue1(String value1) { 10 | this.value1 = value1; 11 | } 12 | public String getValue2() { 13 | return value2; 14 | } 15 | public void setValue2(String value2) { 16 | this.value2 = value2; 17 | } 18 | public String getValue3() { 19 | return value3; 20 | } 21 | public void setValue3(String value3) { 22 | this.value3 = value3; 23 | } 24 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/public_constructor_with_mandatory_fields/gh_output.tjava: -------------------------------------------------------------------------------- 1 | public class BuilderTest { 2 | private String value1; 3 | private String value2; 4 | private String value3; 5 | 6 | private BuilderTest(Builder builder) { 7 | this.value1 = builder.value1; 8 | this.value2 = builder.value2; 9 | this.value3 = builder.value3; 10 | } 11 | 12 | public String getValue1() { 13 | return value1; 14 | } 15 | 16 | public void setValue1(String value1) { 17 | this.value1 = value1; 18 | } 19 | 20 | public String getValue2() { 21 | return value2; 22 | } 23 | 24 | public void setValue2(String value2) { 25 | this.value2 = value2; 26 | } 27 | 28 | public String getValue3() { 29 | return value3; 30 | } 31 | 32 | public void setValue3(String value3) { 33 | this.value3 = value3; 34 | } 35 | 36 | public static final class Builder { 37 | private String value1; 38 | private String value2; 39 | private String value3; 40 | 41 | public Builder(String value1) { 42 | this.value1 = value1; 43 | } 44 | 45 | 46 | public Builder withValue2(String value2) { 47 | this.value2 = value2; 48 | return this; 49 | } 50 | 51 | public Builder withValue3(String value3) { 52 | this.value3 = value3; 53 | return this; 54 | } 55 | 56 | public BuilderTest build() { 57 | return new BuilderTest(this); 58 | } 59 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/public_constructor_with_mandatory_fields/gh_output_when_all_selected.tjava: -------------------------------------------------------------------------------- 1 | public class BuilderTest { 2 | private String value1; 3 | private String value2; 4 | private String value3; 5 | 6 | private BuilderTest(Builder builder) { 7 | this.value1 = builder.value1; 8 | this.value2 = builder.value2; 9 | this.value3 = builder.value3; 10 | } 11 | 12 | public String getValue1() { 13 | return value1; 14 | } 15 | 16 | public void setValue1(String value1) { 17 | this.value1 = value1; 18 | } 19 | 20 | public String getValue2() { 21 | return value2; 22 | } 23 | 24 | public void setValue2(String value2) { 25 | this.value2 = value2; 26 | } 27 | 28 | public String getValue3() { 29 | return value3; 30 | } 31 | 32 | public void setValue3(String value3) { 33 | this.value3 = value3; 34 | } 35 | 36 | public static final class Builder { 37 | private String value1; 38 | private String value2; 39 | private String value3; 40 | 41 | public Builder(String value1, String value2, String value3) { 42 | this.value1 = value1; 43 | this.value2 = value2; 44 | this.value3 = value3; 45 | } 46 | 47 | public BuilderTest build() { 48 | return new BuilderTest(this); 49 | } 50 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/public_constructor_with_mandatory_fields/gh_output_when_none_selected.tjava: -------------------------------------------------------------------------------- 1 | public class BuilderTest { 2 | private String value1; 3 | private String value2; 4 | private String value3; 5 | 6 | private BuilderTest(Builder builder) { 7 | this.value1 = builder.value1; 8 | this.value2 = builder.value2; 9 | this.value3 = builder.value3; 10 | } 11 | 12 | public String getValue1() { 13 | return value1; 14 | } 15 | 16 | public void setValue1(String value1) { 17 | this.value1 = value1; 18 | } 19 | 20 | public String getValue2() { 21 | return value2; 22 | } 23 | 24 | public void setValue2(String value2) { 25 | this.value2 = value2; 26 | } 27 | 28 | public String getValue3() { 29 | return value3; 30 | } 31 | 32 | public void setValue3(String value3) { 33 | this.value3 = value3; 34 | } 35 | 36 | public static final class Builder { 37 | private String value1; 38 | private String value2; 39 | private String value3; 40 | 41 | public Builder() { 42 | } 43 | 44 | public Builder withValue1(String value1) { 45 | this.value1 = value1; 46 | return this; 47 | } 48 | 49 | public Builder withValue2(String value2) { 50 | this.value2 = value2; 51 | return this; 52 | } 53 | 54 | public Builder withValue3(String value3) { 55 | this.value3 = value3; 56 | return this; 57 | } 58 | 59 | public BuilderTest build() { 60 | return new BuilderTest(this); 61 | } 62 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/record/record_input.tjava: -------------------------------------------------------------------------------- 1 | 2 | record Person(String name, String address) { 3 | 4 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/record/record_output.tjava: -------------------------------------------------------------------------------- 1 | 2 | record Person(String name, String address) { 3 | 4 | public static Builder builder() { 5 | return new Builder(); 6 | } 7 | 8 | public static final class Builder { 9 | private String name; 10 | private String address; 11 | 12 | private Builder() { 13 | } 14 | 15 | public Builder withName(String name) { 16 | this.name = name; 17 | return this; 18 | } 19 | 20 | public Builder withAddress(String address) { 21 | this.address = address; 22 | return this; 23 | } 24 | 25 | public Person build() { 26 | return new Person(name, address); 27 | } 28 | } 29 | 30 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/record/record_output_staged.tjava: -------------------------------------------------------------------------------- 1 | record Person(String name, String address) { 2 | 3 | public static INameStage builder() { 4 | return new Builder(); 5 | } 6 | 7 | public interface INameStage { 8 | public IAddressStage withName(String name); 9 | } 10 | 11 | public interface IAddressStage { 12 | public IBuildStage withAddress(String address); 13 | } 14 | 15 | public interface IBuildStage { 16 | public Person build(); 17 | } 18 | 19 | public static final class Builder implements INameStage, IAddressStage, IBuildStage { 20 | private String name; 21 | private String address; 22 | 23 | private Builder() { 24 | } 25 | 26 | @Override 27 | public IAddressStage withName(String name) { 28 | this.name = name; 29 | return this; 30 | } 31 | 32 | @Override 33 | public IBuildStage withAddress(String address) { 34 | this.address = address; 35 | return this; 36 | } 37 | 38 | @Override 39 | public Person build() { 40 | return new Person(name, address); 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/record/record_output_with_json_annotation.tjava: -------------------------------------------------------------------------------- 1 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 2 | 3 | @JsonDeserialize(builder = Person.Builder.class) 4 | record Person(String name, String address) { 5 | 6 | public static Builder builder() { 7 | return new Builder(); 8 | } 9 | 10 | public static final class Builder { 11 | private String name; 12 | private String address; 13 | 14 | private Builder() { 15 | } 16 | 17 | public Builder withName(String name) { 18 | this.name = name; 19 | return this; 20 | } 21 | 22 | public Builder withAddress(String address) { 23 | this.address = address; 24 | return this; 25 | } 26 | 27 | public Person build() { 28 | return new Person(name, address); 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/singlefield_input.tjava: -------------------------------------------------------------------------------- 1 | public class TestClass { 2 | private String testField; 3 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/singlefield_output.tjava: -------------------------------------------------------------------------------- 1 | public class TestClass { 2 | private String testField; 3 | 4 | private TestClass(Builder builder) { 5 | this.testField = builder.testField; 6 | } 7 | 8 | public static Builder builder() { 9 | return new Builder(); 10 | } 11 | 12 | public static final class Builder { 13 | private String testField; 14 | 15 | private Builder() { 16 | } 17 | 18 | public Builder withTestField(String testField) { 19 | this.testField = testField; 20 | return this; 21 | } 22 | 23 | public TestClass build() { 24 | return new TestClass(this); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/singlefield_staged_output.tjava: -------------------------------------------------------------------------------- 1 | public class TestClass { 2 | private String testField; 3 | 4 | private TestClass(Builder builder) { 5 | this.testField = builder.testField; 6 | } 7 | 8 | public static ITestFieldStage builder() { 9 | return new Builder(); 10 | } 11 | 12 | public interface ITestFieldStage { 13 | public IBuildStage withTestField(String testField); 14 | } 15 | 16 | public interface IBuildStage { 17 | public TestClass build(); 18 | } 19 | 20 | public static final class Builder implements ITestFieldStage, IBuildStage { 21 | private String testField; 22 | 23 | private Builder() { 24 | } 25 | 26 | @Override 27 | public IBuildStage withTestField(String testField) { 28 | this.testField = testField; 29 | return this; 30 | } 31 | 32 | @Override 33 | public TestClass build() { 34 | return new TestClass(this); 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/static_field_input.tjava: -------------------------------------------------------------------------------- 1 | public class TestClass { 2 | private static final String shouldNotInclude; 3 | private String testField; 4 | private long something; 5 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/static_field_output.tjava: -------------------------------------------------------------------------------- 1 | public class TestClass { 2 | private static final String shouldNotInclude; 3 | private String testField; 4 | private long something; 5 | 6 | private TestClass(Builder builder) { 7 | this.testField = builder.testField; 8 | this.something = builder.something; 9 | } 10 | 11 | public static Builder builder() { 12 | return new Builder(); 13 | } 14 | 15 | public static final class Builder { 16 | private String testField; 17 | private long something; 18 | 19 | private Builder() { 20 | } 21 | 22 | public Builder withTestField(String testField) { 23 | this.testField = testField; 24 | return this; 25 | } 26 | 27 | public Builder withSomething(long something) { 28 | this.something = something; 29 | return this; 30 | } 31 | 32 | public TestClass build() { 33 | return new TestClass(this); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/static_field_output_with_staged_builder.tjava: -------------------------------------------------------------------------------- 1 | public class TestClass { 2 | private static final String shouldNotInclude; 3 | private String testField; 4 | private long something; 5 | 6 | private TestClass(Builder builder) { 7 | this.testField = builder.testField; 8 | this.something = builder.something; 9 | } 10 | 11 | public static ITestFieldStage builder() { 12 | return new Builder(); 13 | } 14 | 15 | public interface ITestFieldStage { 16 | public ISomethingStage withTestField(String testField); 17 | } 18 | 19 | public interface ISomethingStage { 20 | public IBuildStage withSomething(long something); 21 | } 22 | 23 | public interface IBuildStage { 24 | public TestClass build(); 25 | } 26 | 27 | public static final class Builder implements ITestFieldStage, ISomethingStage, IBuildStage { 28 | private String testField; 29 | private long something; 30 | 31 | private Builder() { 32 | } 33 | 34 | @Override 35 | public ISomethingStage withTestField(String testField) { 36 | this.testField = testField; 37 | return this; 38 | } 39 | 40 | @Override 41 | public IBuildStage withSomething(long something) { 42 | this.something = something; 43 | return this; 44 | } 45 | 46 | @Override 47 | public TestClass build() { 48 | return new TestClass(this); 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/suffix_input.tjava: -------------------------------------------------------------------------------- 1 | public class TestClass { 2 | private String testFieldSuffix; 3 | private Integer dataB; 4 | private int other; 5 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/suffix_output.tjava: -------------------------------------------------------------------------------- 1 | public class TestClass { 2 | private String testFieldSuffix; 3 | private Integer dataB; 4 | private int other; 5 | 6 | private TestClass(Builder builder) { 7 | this.testFieldSuffix = builder.testFieldSuffix; 8 | this.dataB = builder.dataB; 9 | this.other = builder.other; 10 | } 11 | 12 | public static Builder builder() { 13 | return new Builder(); 14 | } 15 | 16 | public static final class Builder { 17 | private String testFieldSuffix; 18 | private Integer dataB; 19 | private int other; 20 | 21 | private Builder() { 22 | } 23 | 24 | public Builder withTestField(String testField) { 25 | this.testFieldSuffix = testField; 26 | return this; 27 | } 28 | 29 | public Builder withData(Integer data) { 30 | this.dataB = data; 31 | return this; 32 | } 33 | 34 | public Builder withOther(int other) { 35 | this.other = other; 36 | return this; 37 | } 38 | 39 | public TestClass build() { 40 | return new TestClass(this); 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/super_superclass_test_input.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.differentpackage; 2 | 3 | public class TestSuperSuperClass { 4 | public String publicSuperSuperClassField; 5 | String defaultSuperSuperClassField; 6 | protected String protectedSuperSuperClassField; 7 | private String privateSuperSuperClassField; 8 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_instance_copy/1_base_child_input.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.testpackage; 2 | 3 | public class TestClass extends TestSuperClass { 4 | private String childField; 5 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_instance_copy/1_base_output.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.testpackage; 2 | 3 | public class TestClass extends TestSuperClass { 4 | private String childField; 5 | 6 | private TestClass(Builder builder) { 7 | this.childField = builder.childField; 8 | super.setData(builder.data); 9 | } 10 | 11 | public static Builder builder() { 12 | return new Builder(); 13 | } 14 | 15 | public static Builder builderFrom(TestClass testClass) { 16 | return new Builder(testClass); 17 | } 18 | 19 | public static final class Builder { 20 | private String childField; 21 | private String data; 22 | 23 | private Builder() { 24 | } 25 | 26 | private Builder(TestClass testClass) { 27 | this.childField = testClass.childField; 28 | this.data = testClass.getData(); 29 | } 30 | 31 | public Builder withChildField(String childField) { 32 | this.childField = childField; 33 | return this; 34 | } 35 | 36 | public Builder withData(String data) { 37 | this.data = data; 38 | return this; 39 | } 40 | 41 | public TestClass build() { 42 | return new TestClass(this); 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_instance_copy/1_base_super_input.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.testpackage; 2 | 3 | public class TestSuperClass { 4 | private String data; 5 | 6 | public String getData() { 7 | return data; 8 | } 9 | 10 | public String setData(String data) { 11 | this.data = data; 12 | } 13 | 14 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_instance_copy/2_base_child_input.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.testpackage; 2 | 3 | public class TestClass extends TestSuperClass { 4 | private String childField; 5 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_instance_copy/2_base_output.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.testpackage; 2 | 3 | public class TestClass extends TestSuperClass { 4 | private String childField; 5 | 6 | private TestClass(Builder builder) { 7 | this.childField = builder.childField; 8 | super.setData(builder.data); 9 | } 10 | 11 | public static Builder builder() { 12 | return new Builder(); 13 | } 14 | 15 | public static Builder builderFrom(TestClass testClass) { 16 | return new Builder(testClass); 17 | } 18 | 19 | public static final class Builder { 20 | private String childField; 21 | private String data; 22 | 23 | private Builder() { 24 | } 25 | 26 | private Builder(TestClass testClass) { 27 | this.childField = testClass.childField; 28 | this.data = CANNOT_ACCESS_FIELD; 29 | } 30 | 31 | public Builder withChildField(String childField) { 32 | this.childField = childField; 33 | return this; 34 | } 35 | 36 | public Builder withData(String data) { 37 | this.data = data; 38 | return this; 39 | } 40 | 41 | public TestClass build() { 42 | return new TestClass(this); 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_instance_copy/2_base_super_input.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.testpackage; 2 | 3 | public class TestSuperClass { 4 | private String data; 5 | 6 | public String setData(String data) { 7 | this.data = data; 8 | } 9 | 10 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_instance_copy/3_base_child_input.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.testpackage; 2 | 3 | public class TestClass extends TestSuperClass { 4 | private String childField; 5 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_instance_copy/3_base_output.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.testpackage; 2 | 3 | public class TestClass extends TestSuperClass { 4 | private String childField; 5 | 6 | private TestClass(Builder builder) { 7 | this.data = builder.data; 8 | this.childField = builder.childField; 9 | } 10 | 11 | public static Builder builder() { 12 | return new Builder(); 13 | } 14 | 15 | public static Builder builderFrom(TestClass testClass) { 16 | return new Builder(testClass); 17 | } 18 | 19 | public static final class Builder { 20 | private String data; 21 | private String childField; 22 | 23 | private Builder() { 24 | } 25 | 26 | private Builder(TestClass testClass) { 27 | this.data = testClass.data; 28 | this.childField = testClass.childField; 29 | } 30 | 31 | public Builder withData(String data) { 32 | this.data = data; 33 | return this; 34 | } 35 | 36 | public Builder withChildField(String childField) { 37 | this.childField = childField; 38 | return this; 39 | } 40 | 41 | public TestClass build() { 42 | return new TestClass(this); 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_instance_copy/3_base_super_input.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.testpackage; 2 | 3 | public class TestSuperClass { 4 | public String data; 5 | 6 | public String setData(String data) { 7 | this.data = data; 8 | } 9 | 10 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_instance_copy/4_base_child_input.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.testpackage; 2 | 3 | public class TestClass extends TestSuperClass { 4 | private String childField; 5 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_instance_copy/4_base_output.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.testpackage; 2 | 3 | public class TestClass extends TestSuperClass { 4 | private String childField; 5 | 6 | private TestClass(Builder builder) { 7 | super(builder.data); 8 | this.childField = builder.childField; 9 | } 10 | 11 | public static Builder builder() { 12 | return new Builder(); 13 | } 14 | 15 | public static Builder builderFrom(TestClass testClass) { 16 | return new Builder(testClass); 17 | } 18 | 19 | public static final class Builder { 20 | private String data; 21 | private String childField; 22 | 23 | private Builder() { 24 | } 25 | 26 | private Builder(TestClass testClass) { 27 | this.data = testClass.getData(); 28 | this.childField = testClass.childField; 29 | } 30 | 31 | public Builder withData(String data) { 32 | this.data = data; 33 | return this; 34 | } 35 | 36 | public Builder withChildField(String childField) { 37 | this.childField = childField; 38 | return this; 39 | } 40 | 41 | public TestClass build() { 42 | return new TestClass(this); 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_instance_copy/4_base_super_input.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.testpackage; 2 | 3 | public class TestSuperClass { 4 | private String data; 5 | 6 | public TestSuperClass(String data) { 7 | this.data = data; 8 | } 9 | 10 | public String getData() { 11 | return data; 12 | } 13 | 14 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_output_with_different_package.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.testpackage; 2 | 3 | public class TestClass extends TestSuperClass { 4 | private String childField; 5 | 6 | private TestClass(Builder builder) { 7 | this.publicSuperClassField = builder.publicSuperClassField; 8 | this.protectedSuperClassField = builder.protectedSuperClassField; 9 | this.childField = builder.childField; 10 | } 11 | 12 | public static Builder builder() { 13 | return new Builder(); 14 | } 15 | 16 | public static final class Builder { 17 | private String publicSuperClassField; 18 | private String protectedSuperClassField; 19 | private String childField; 20 | 21 | private Builder() { 22 | } 23 | 24 | public Builder withPublicSuperClassField(String publicSuperClassField) { 25 | this.publicSuperClassField = publicSuperClassField; 26 | return this; 27 | } 28 | 29 | public Builder withProtectedSuperClassField(String protectedSuperClassField) { 30 | this.protectedSuperClassField = protectedSuperClassField; 31 | return this; 32 | } 33 | 34 | public Builder withChildField(String childField) { 35 | this.childField = childField; 36 | return this; 37 | } 38 | 39 | public TestClass build() { 40 | return new TestClass(this); 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_test_extends_input.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.testpackage; 2 | 3 | public class TestClass extends TestSuperClass { 4 | private String childField; 5 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_test_extends_input_in_default_package.tjava: -------------------------------------------------------------------------------- 1 | 2 | public class TestClass extends TestSuperClass { 3 | private String childField; 4 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_test_superclass_in_default_package_input.tjava: -------------------------------------------------------------------------------- 1 | 2 | public class TestSuperClass { 3 | public String publicSuperClassField; 4 | String defaultSuperClassField; 5 | protected String protectedSuperClassField; 6 | private String privateSuperClassField; 7 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_test_superclass_in_different_package_input.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.differentpackage; 2 | 3 | public class TestSuperClass { 4 | public String publicSuperClassField; 5 | String defaultSuperClassField; 6 | protected String protectedSuperClassField; 7 | private String privateSuperClassField; 8 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_test_superclass_input.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.testpackage; 2 | 3 | public class TestSuperClass { 4 | public String publicSuperClassField; 5 | String defaultSuperClassField; 6 | protected String protectedSuperClassField; 7 | private String privateSuperClassField; 8 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_test_with_disabled_preference.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.testpackage; 2 | 3 | public class TestClass extends TestSuperClass { 4 | private String childField; 5 | 6 | private TestClass(Builder builder) { 7 | this.childField = builder.childField; 8 | } 9 | 10 | public static Builder builder() { 11 | return new Builder(); 12 | } 13 | 14 | public static final class Builder { 15 | private String childField; 16 | 17 | private Builder() { 18 | } 19 | 20 | public Builder withChildField(String childField) { 21 | this.childField = childField; 22 | return this; 23 | } 24 | 25 | public TestClass build() { 26 | return new TestClass(this); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_with_constructor/base_child_input.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.testpackage; 2 | 3 | public class TestClass extends TestSuperClass { 4 | private String childField; 5 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_with_constructor/base_super_input.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.testpackage; 2 | 3 | public class TestSuperClass { 4 | public String publicSuperClassField; 5 | String defaultSuperClassField; 6 | protected String protectedSuperClassField; 7 | private String privateSuperClassField; 8 | 9 | public TestSuperClass(String publicSuperClassField, String defaultSuperClassField, String protectedSuperClassField, 10 | String privateSuperClassField) { 11 | this.publicSuperClassField = publicSuperClassField; 12 | this.defaultSuperClassField = defaultSuperClassField; 13 | this.protectedSuperClassField = protectedSuperClassField; 14 | this.privateSuperClassField = privateSuperClassField; 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_with_constructor/class_without_parent_input.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.testpackage; 2 | 3 | public class TestClass { 4 | private String childField; 5 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_with_constructor/class_without_parent_output.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.testpackage; 2 | 3 | public class TestClass { 4 | private String childField; 5 | 6 | private TestClass(Builder builder) { 7 | this.childField = builder.childField; 8 | } 9 | 10 | public static Builder builder() { 11 | return new Builder(); 12 | } 13 | 14 | public static final class Builder { 15 | private String childField; 16 | 17 | private Builder() { 18 | } 19 | 20 | public Builder withChildField(String childField) { 21 | this.childField = childField; 22 | return this; 23 | } 24 | 25 | public TestClass build() { 26 | return new TestClass(this); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_with_constructor/multi_constructor_child_input.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.testpackage; 2 | 3 | public class TestClass extends TestSuperClass { 4 | private String childField; 5 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_with_constructor/multi_constructor_super_input.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.testpackage; 2 | 3 | public class TestSuperClass { 4 | public String publicSuperClassField; 5 | String defaultSuperClassField; 6 | protected String protectedSuperClassField; 7 | private String privateSuperClassField; 8 | 9 | public TestSuperClass() { 10 | } 11 | 12 | public TestSuperClass(String publicSuperClassField) { 13 | this.publicSuperClassField = publicSuperClassField; 14 | } 15 | 16 | public TestSuperClass(String publicSuperClassField, String defaultSuperClassField, String protectedSuperClassField, 17 | String privateSuperClassField) { 18 | this.publicSuperClassField = publicSuperClassField; 19 | this.defaultSuperClassField = defaultSuperClassField; 20 | this.protectedSuperClassField = protectedSuperClassField; 21 | this.privateSuperClassField = privateSuperClassField; 22 | } 23 | 24 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_with_constructor/no_visible_constructor_super_input.tjava: -------------------------------------------------------------------------------- 1 | 2 | package com.helospark.testpackage; 3 | 4 | public class TestSuperClass { 5 | public String publicSuperClassField; 6 | String defaultSuperClassField; 7 | protected String protectedSuperClassField; 8 | private String privateSuperClassField; 9 | 10 | private TestSuperClass(String publicSuperClassField, String defaultSuperClassField, String protectedSuperClassField, 11 | String privateSuperClassField) { 12 | this.publicSuperClassField = publicSuperClassField; 13 | this.defaultSuperClassField = defaultSuperClassField; 14 | this.protectedSuperClassField = protectedSuperClassField; 15 | this.privateSuperClassField = privateSuperClassField; 16 | } 17 | 18 | private TestSuperClass() { 19 | 20 | } 21 | 22 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_with_constructor/private_constructor_super_input.tjava: -------------------------------------------------------------------------------- 1 | 2 | package com.helospark.testpackage; 3 | 4 | public class TestSuperClass { 5 | public String publicSuperClassField; 6 | String defaultSuperClassField; 7 | protected String protectedSuperClassField; 8 | private String privateSuperClassField; 9 | 10 | private TestSuperClass(String publicSuperClassField, String defaultSuperClassField, String protectedSuperClassField, 11 | String privateSuperClassField) { 12 | this.publicSuperClassField = publicSuperClassField; 13 | this.defaultSuperClassField = defaultSuperClassField; 14 | this.protectedSuperClassField = protectedSuperClassField; 15 | this.privateSuperClassField = privateSuperClassField; 16 | } 17 | 18 | private TestSuperClass() { 19 | 20 | } 21 | 22 | public TestSuperClass(String privateSuperClassField) { 23 | this.privateSuperClassField = privateSuperClassField; 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_with_constructor/repro_issue_child_input.tjava: -------------------------------------------------------------------------------- 1 | /** 2 | * test class inheriting from TestBase 3 | * 4 | * @author tr 5 | * 6 | */ 7 | public class TestClass extends TestSuperClass { 8 | public final int b; 9 | 10 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_with_constructor/repro_issue_output.tjava: -------------------------------------------------------------------------------- 1 | 2 | 3 | /** 4 | * test class inheriting from TestBase 5 | * 6 | * @author tr 7 | * 8 | */ 9 | public class TestClass extends TestSuperClass { 10 | 11 | public final int b; 12 | 13 | private TestClass(Builder builder) { 14 | super(builder.a); 15 | this.b = builder.b; 16 | } 17 | 18 | public static Builder builder() { 19 | return new Builder(); 20 | } 21 | 22 | public static final class Builder { 23 | private int a; 24 | private int b; 25 | 26 | private Builder() { 27 | } 28 | 29 | public Builder witha(int a) { 30 | this.a = a; 31 | return this; 32 | } 33 | 34 | public Builder withb(int b) { 35 | this.b = b; 36 | return this; 37 | } 38 | 39 | public TestClass build() { 40 | return new TestClass(this); 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_with_constructor/repro_issue_output_staged.tjava: -------------------------------------------------------------------------------- 1 | /** 2 | * test class inheriting from TestBase 3 | * @author tr 4 | */ 5 | public class TestClass extends TestSuperClass { 6 | public final int b; 7 | 8 | private TestClass(Builder builder) { 9 | super(builder.a); 10 | this.b = builder.b; 11 | } 12 | 13 | public static IaStage builder() { 14 | return new Builder(); 15 | } 16 | 17 | public interface IaStage { 18 | public IbStage witha(int a); 19 | } 20 | 21 | public interface IbStage { 22 | public IBuildStage withb(int b); 23 | } 24 | 25 | public interface IBuildStage { 26 | public TestClass build(); 27 | } 28 | 29 | public static final class Builder implements IaStage, IbStage, IBuildStage { 30 | private int a; 31 | private int b; 32 | 33 | private Builder() { 34 | } 35 | 36 | @Override 37 | public IbStage witha(int a) { 38 | this.a = a; 39 | return this; 40 | } 41 | 42 | @Override 43 | public IBuildStage withb(int b) { 44 | this.b = b; 45 | return this; 46 | } 47 | 48 | @Override 49 | public TestClass build() { 50 | return new TestClass(this); 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_with_constructor/repro_issue_super_input.tjava: -------------------------------------------------------------------------------- 1 | /** 2 | * test class to show builder issue 3 | * 4 | * @author tr 5 | */ 6 | public class TestSuperClass { 7 | 8 | private final int a; 9 | 10 | public TestSuperClass(int a) { 11 | this.a = a; 12 | } 13 | 14 | /** 15 | * @return the a 16 | */ 17 | public int getA() { 18 | return a; 19 | } 20 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_with_default_value/childclass.tjava: -------------------------------------------------------------------------------- 1 | class B extends A { 2 | private int y = 10; 3 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_with_default_value/result.tjava: -------------------------------------------------------------------------------- 1 | class B extends A { 2 | private int y = 10; 3 | 4 | private B(Builder builder) { 5 | this.orig = builder.orig; 6 | this.x = builder.x; 7 | this.y = builder.y; 8 | } 9 | 10 | public static Builder builder() { 11 | return new Builder(); 12 | } 13 | 14 | public static final class Builder { 15 | private String orig = "asd"; 16 | private int x = 12; 17 | private int y = 10; 18 | 19 | private Builder() { 20 | } 21 | 22 | public Builder withOrig(String orig) { 23 | this.orig = orig; 24 | return this; 25 | } 26 | 27 | public Builder withx(int x) { 28 | this.x = x; 29 | return this; 30 | } 31 | 32 | public Builder withy(int y) { 33 | this.y = y; 34 | return this; 35 | } 36 | 37 | public B build() { 38 | return new B(this); 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_with_default_value/superclass.tjava: -------------------------------------------------------------------------------- 1 | abstract class A extends TestSuperSuperClass { 2 | public int x = 12; 3 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_with_default_value/supersuperclass.tjava: -------------------------------------------------------------------------------- 1 | abstract class TestSuperSuperClass { 2 | public String orig = "asd"; 3 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_with_setter/10_base_output_with_overridden_setter_output.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.testpackage; 2 | 3 | public class TestClass extends TestSuperClass { 4 | private String childField; 5 | 6 | private TestClass(Builder builder) { 7 | this.childField = builder.childField; 8 | super.setSuperSuperData(builder.superSuperData); 9 | } 10 | 11 | public static Builder builder() { 12 | return new Builder(); 13 | } 14 | 15 | public static final class Builder { 16 | private String childField; 17 | private String superSuperData; 18 | 19 | private Builder() { 20 | } 21 | 22 | public Builder withChildField(String childField) { 23 | this.childField = childField; 24 | return this; 25 | } 26 | 27 | public Builder withSuperSuperData(String superSuperData) { 28 | this.superSuperData = superSuperData; 29 | return this; 30 | } 31 | 32 | public TestClass build() { 33 | return new TestClass(this); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_with_setter/10_super_class_with_overridden_setter.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.testpackage; 2 | 3 | public class TestSuperClass { 4 | 5 | @Override 6 | public String setSuperSuperData(String superSuperData) { 7 | super.setSuperSuperData(superSuperData); 8 | } 9 | 10 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_with_setter/10_super_super_class_with_overridden_setter.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.testpackage; 2 | 3 | public class TestSuperSuperClass { 4 | private String superSuperData; 5 | 6 | public String setSuperSuperData(String superSuperData) { 7 | this.superSuperData = superSuperData; 8 | } 9 | 10 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_with_setter/1_base_child_input.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.testpackage; 2 | 3 | public class TestClass extends TestSuperClass { 4 | private String childField; 5 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_with_setter/1_base_output.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.testpackage; 2 | 3 | public class TestClass extends TestSuperClass { 4 | private String childField; 5 | 6 | private TestClass(Builder builder) { 7 | this.childField = builder.childField; 8 | super.setData(builder.data); 9 | } 10 | 11 | public static Builder builder() { 12 | return new Builder(); 13 | } 14 | 15 | public static final class Builder { 16 | private String childField; 17 | private String data; 18 | 19 | private Builder() { 20 | } 21 | 22 | public Builder withChildField(String childField) { 23 | this.childField = childField; 24 | return this; 25 | } 26 | 27 | public Builder withData(String data) { 28 | this.data = data; 29 | return this; 30 | } 31 | 32 | public TestClass build() { 33 | return new TestClass(this); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_with_setter/1_base_super_input.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.testpackage; 2 | 3 | public class TestSuperClass { 4 | private String data; 5 | 6 | public String setData(String data) { 7 | this.data = data; 8 | } 9 | 10 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_with_setter/2_base_output_with_duplicated_field.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.testpackage; 2 | 3 | public class TestClass extends TestSuperClass { 4 | private String childField; 5 | 6 | private TestClass(Builder builder) { 7 | this.childField = builder.childField; 8 | } 9 | 10 | public static Builder builder() { 11 | return new Builder(); 12 | } 13 | 14 | public static final class Builder { 15 | private String childField; 16 | 17 | private Builder() { 18 | } 19 | 20 | public Builder withChildField(String childField) { 21 | this.childField = childField; 22 | return this; 23 | } 24 | 25 | public TestClass build() { 26 | return new TestClass(this); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_with_setter/2_base_super_input_with_duplicated_field.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.testpackage; 2 | 3 | public class TestSuperClass { 4 | private String childField; 5 | 6 | public void setChildField(String childField) { 7 | this.childField = childField; 8 | } 9 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_with_setter/3_base_output_with_two_superclass.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.testpackage; 2 | 3 | public class TestClass extends TestSuperClass { 4 | private String childField; 5 | 6 | private TestClass(Builder builder) { 7 | this.childField = builder.childField; 8 | super.setData(builder.data); 9 | super.setSuperSuperData(builder.superSuperData); 10 | } 11 | 12 | public static Builder builder() { 13 | return new Builder(); 14 | } 15 | 16 | public static final class Builder { 17 | private String childField; 18 | private String data; 19 | private String superSuperData; 20 | 21 | private Builder() { 22 | } 23 | 24 | public Builder withChildField(String childField) { 25 | this.childField = childField; 26 | return this; 27 | } 28 | 29 | public Builder withData(String data) { 30 | this.data = data; 31 | return this; 32 | } 33 | 34 | public Builder withSuperSuperData(String superSuperData) { 35 | this.superSuperData = superSuperData; 36 | return this; 37 | } 38 | 39 | public TestClass build() { 40 | return new TestClass(this); 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_with_setter/3_super_class.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.testpackage; 2 | 3 | public class TestSuperClass { 4 | private String data; 5 | 6 | public String setData(String data) { 7 | this.data = data; 8 | } 9 | 10 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_with_setter/3_super_super_class.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.testpackage; 2 | 3 | public class TestSuperSuperClass { 4 | private String superSuperData; 5 | 6 | public String setSuperSuperData(String superSuperData) { 7 | this.superSuperData = superSuperData; 8 | } 9 | 10 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_with_setter/4_base_output_staged.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.testpackage; 2 | 3 | public class TestClass extends TestSuperClass { 4 | private String childField; 5 | 6 | private TestClass(Builder builder) { 7 | this.childField = builder.childField; 8 | super.setData(builder.data); 9 | } 10 | 11 | public static IChildFieldStage builder() { 12 | return new Builder(); 13 | } 14 | 15 | public interface IChildFieldStage { 16 | public IDataStage withChildField(String childField); 17 | } 18 | 19 | public interface IDataStage { 20 | public IBuildStage withData(String data); 21 | } 22 | 23 | public interface IBuildStage { 24 | public TestClass build(); 25 | } 26 | 27 | public static final class Builder implements IChildFieldStage, IDataStage, IBuildStage { 28 | private String childField; 29 | private String data; 30 | 31 | private Builder() { 32 | } 33 | 34 | @Override 35 | public IDataStage withChildField(String childField) { 36 | this.childField = childField; 37 | return this; 38 | } 39 | 40 | @Override 41 | public IBuildStage withData(String data) { 42 | this.data = data; 43 | return this; 44 | } 45 | 46 | @Override 47 | public TestClass build() { 48 | return new TestClass(this); 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_with_setter/5_base_child_input_without_superclass.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.testpackage; 2 | 3 | public class TestClass { 4 | private String childField; 5 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_with_setter/5_base_output_without_superclass.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.testpackage; 2 | 3 | public class TestClass { 4 | private String childField; 5 | 6 | private TestClass(Builder builder) { 7 | this.childField = builder.childField; 8 | } 9 | 10 | public static Builder builder() { 11 | return new Builder(); 12 | } 13 | 14 | public static final class Builder { 15 | private String childField; 16 | 17 | private Builder() { 18 | } 19 | 20 | public Builder withChildField(String childField) { 21 | this.childField = childField; 22 | return this; 23 | } 24 | 25 | public TestClass build() { 26 | return new TestClass(this); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_with_setter/6_base_output_with_wrong_setter.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.testpackage; 2 | 3 | public class TestClass extends TestSuperClass { 4 | private String childField; 5 | 6 | private TestClass(Builder builder) { 7 | this.childField = builder.childField; 8 | } 9 | 10 | public static Builder builder() { 11 | return new Builder(); 12 | } 13 | 14 | public static final class Builder { 15 | private String childField; 16 | 17 | private Builder() { 18 | } 19 | 20 | public Builder withChildField(String childField) { 21 | this.childField = childField; 22 | return this; 23 | } 24 | 25 | public TestClass build() { 26 | return new TestClass(this); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_with_setter/6_base_super_input_with_wrong_setter.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.testpackage; 2 | 3 | public class TestSuperClass { 4 | private String data; 5 | 6 | public String setData(String data, int otherValue) { 7 | this.data = data; 8 | } 9 | 10 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_with_setter/7_base_output_with_constructor.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.testpackage; 2 | 3 | public class TestClass extends TestSuperClass { 4 | private String childField; 5 | 6 | private TestClass(Builder builder) { 7 | super(builder.constructorData); 8 | this.childField = builder.childField; 9 | super.setData(builder.data); 10 | } 11 | 12 | public static Builder builder() { 13 | return new Builder(); 14 | } 15 | 16 | public static final class Builder { 17 | private String constructorData; 18 | private String childField; 19 | private String data; 20 | 21 | private Builder() { 22 | } 23 | 24 | public Builder withConstructorData(String constructorData) { 25 | this.constructorData = constructorData; 26 | return this; 27 | } 28 | 29 | public Builder withChildField(String childField) { 30 | this.childField = childField; 31 | return this; 32 | } 33 | 34 | public Builder withData(String data) { 35 | this.data = data; 36 | return this; 37 | } 38 | 39 | public TestClass build() { 40 | return new TestClass(this); 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_with_setter/7_base_super_input_with_constructor.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.testpackage; 2 | 3 | public class TestSuperClass { 4 | private String constructorData; 5 | private String data; 6 | 7 | public TestSuperClass(String constructorData) { 8 | this.constructorData = constructorData; 9 | } 10 | 11 | public String setData(String data) { 12 | this.data = data; 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_with_setter/8_base_output_with_deduplicated_field.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.testpackage; 2 | 3 | public class TestClass extends TestSuperClass { 4 | private String childField; 5 | 6 | private TestClass(Builder builder) { 7 | super(builder.data); 8 | this.childField = builder.childField; 9 | } 10 | 11 | public static Builder builder() { 12 | return new Builder(); 13 | } 14 | 15 | public static final class Builder { 16 | private String data; 17 | private String childField; 18 | 19 | private Builder() { 20 | } 21 | 22 | public Builder withData(String data) { 23 | this.data = data; 24 | return this; 25 | } 26 | 27 | public Builder withChildField(String childField) { 28 | this.childField = childField; 29 | return this; 30 | } 31 | 32 | public TestClass build() { 33 | return new TestClass(this); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_with_setter/8_base_super_input_with_constructor_and_setter.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.testpackage; 2 | 3 | public class TestSuperClass { 4 | private String data; 5 | 6 | public TestSuperClass(String data) { 7 | this.data = data; 8 | } 9 | 10 | public String setData(String data) { 11 | this.data = data; 12 | } 13 | 14 | } -------------------------------------------------------------------------------- /SparkBuilderGeneratorPlugin/test_resources/superclass_with_setter/9_turned_off_setting_output.tjava: -------------------------------------------------------------------------------- 1 | package com.helospark.testpackage; 2 | 3 | public class TestClass extends TestSuperClass { 4 | private String childField; 5 | 6 | private TestClass(Builder builder) { 7 | this.childField = builder.childField; 8 | } 9 | 10 | public static Builder builder() { 11 | return new Builder(); 12 | } 13 | 14 | public static final class Builder { 15 | private String childField; 16 | 17 | private Builder() { 18 | } 19 | 20 | public Builder withChildField(String childField) { 21 | this.childField = childField; 22 | return this; 23 | } 24 | 25 | public TestClass build() { 26 | return new TestClass(this); 27 | } 28 | } 29 | } --------------------------------------------------------------------------------