Compare commits

...

17 Commits
main ... dev

30 changed files with 4805 additions and 230 deletions

7
.checkstyle Normal file
View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<fileset-config file-format-version="1.2.0" simple-config="true" sync-formatter="false">
<fileset name="all" enabled="true" check-config-name="Ewol" local="false">
<file-match-pattern match-pattern="." include-pattern="true"/>
</fileset>
</fileset-config>

18
.gitignore vendored
View File

@ -1,3 +1,5 @@
/__pycache__/
# ---> Java # ---> Java
# Compiled class file # Compiled class file
*.class *.class
@ -23,3 +25,19 @@
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid* hs_err_pid*
*.class
*~
*.bck
build.number
/extern/
/out/
/.settings/
/junit/
/target/
*.pdfd
*.dbc
SchedulerConfig.txt
scenicView.properties
ScenariumConfig.txt
*.blend*

66
CheckStyle.xml Executable file
View File

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Checkstyle//DTD Check Configuration 1.3//EN" "https://checkstyle.org/dtds/configuration_1_3.dtd">
<!--
This configuration file was written by the eclipse-cs plugin configuration editor
-->
<!--
Checkstyle-Configuration: Marc Checks
Description:
Checkstyle configuration that checks the sun coding conventions.
-->
<module name="Checker">
<property name="severity" value="error"/>
<property name="fileExtensions" value="java, properties, xml"/>
<module name="TreeWalker">
<module name="ConstantName"/>
<module name="LocalFinalVariableName"/>
<module name="LocalVariableName"/>
<module name="MemberName"/>
<module name="MethodName"/>
<module name="PackageName"/>
<module name="ParameterName"/>
<module name="StaticVariableName"/>
<module name="TypeName"/>
<module name="AvoidStarImport"/>
<module name="IllegalImport"/>
<module name="RedundantImport"/>
<module name="UnusedImports">
<property name="processJavadoc" value="false"/>
</module>
<module name="ModifierOrder"/>
<module name="EmptyStatement"/>
<module name="EqualsHashCode"/>
<module name="IllegalInstantiation"/>
<module name="MissingSwitchDefault"/>
<module name="SimplifyBooleanExpression"/>
<module name="SimplifyBooleanReturn"/>
<module name="HideUtilityClassConstructor"/>
<module name="InterfaceIsType"/>
<module name="ArrayTypeStyle"/>
<module name="TodoComment"/>
<module name="UpperEll"/>
<module name="AnnotationUseStyle"/>
<module name="MissingDeprecated"/>
<module name="MissingOverride"/>
<module name="PackageAnnotation"/>
<module name="SuppressWarnings"/>
<module name="AnnotationLocation"/>
<module name="ClassTypeParameterName"/>
<module name="MethodTypeParameterName"/>
<module name="InterfaceTypeParameterName"/>
<module name="CatchParameterName"/>
<module name="LambdaParameterName"/>
<module name="Regexp"/>
<module name="RegexpSinglelineJava"/>
</module>
<module name="BeforeExecutionExclusionFileFilter">
<property name="fileNamePattern" value="module\-info\.java$"/>
</module>
<module name="Translation"/>
<module name="Header"/>
<module name="RegexpHeader"/>
<module name="RegexpMultiline"/>
<module name="RegexpOnFilename"/>
<module name="RegexpSingleline"/>
</module>

106
CleanUp.xml Normal file
View File

@ -0,0 +1,106 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<profiles version="2">
<profile kind="CleanUpProfile" name="EWOL" version="2">
<setting id="cleanup.use_autoboxing" value="false"/>
<setting id="cleanup.always_use_this_for_non_static_method_access" value="false"/>
<setting id="cleanup.remove_trailing_whitespaces_ignore_empty" value="false"/>
<setting id="cleanup.format_source_code_changes_only" value="false"/>
<setting id="cleanup.remove_redundant_semicolons" value="false"/>
<setting id="cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class" value="true"/>
<setting id="cleanup.useless_continue" value="false"/>
<setting id="cleanup.remove_redundant_type_arguments" value="true"/>
<setting id="cleanup.remove_unused_imports" value="true"/>
<setting id="cleanup.break_loop" value="false"/>
<setting id="cleanup.pull_up_assignment" value="false"/>
<setting id="cleanup.stringbuilder" value="false"/>
<setting id="cleanup.no_super" value="false"/>
<setting id="cleanup.arrays_fill" value="false"/>
<setting id="cleanup.use_lambda" value="true"/>
<setting id="cleanup.simplify_lambda_expression_and_method_ref" value="false"/>
<setting id="cleanup.always_use_blocks" value="true"/>
<setting id="cleanup.sort_members_all" value="false"/>
<setting id="cleanup.instanceof" value="false"/>
<setting id="cleanup.add_missing_annotations" value="true"/>
<setting id="cleanup.precompile_regex" value="false"/>
<setting id="cleanup.always_use_this_for_non_static_field_access" value="true"/>
<setting id="cleanup.boolean_literal" value="false"/>
<setting id="cleanup.always_use_parentheses_in_expressions" value="false"/>
<setting id="cleanup.sort_members" value="false"/>
<setting id="cleanup.remove_unused_local_variables" value="false"/>
<setting id="cleanup.add_missing_deprecated_annotations" value="true"/>
<setting id="cleanup.no_string_creation" value="false"/>
<setting id="cleanup.use_unboxing" value="false"/>
<setting id="cleanup.use_blocks_only_for_return_and_throw" value="false"/>
<setting id="cleanup.if_condition" value="false"/>
<setting id="cleanup.remove_trailing_whitespaces" value="true"/>
<setting id="cleanup.map_cloning" value="false"/>
<setting id="cleanup.add_serial_version_id" value="true"/>
<setting id="cleanup.try_with_resource" value="false"/>
<setting id="cleanup.use_this_for_non_static_method_access" value="false"/>
<setting id="cleanup.use_this_for_non_static_method_access_only_if_necessary" value="true"/>
<setting id="cleanup.make_local_variable_final" value="false"/>
<setting id="cleanup.add_missing_methods" value="false"/>
<setting id="cleanup.qualify_static_member_accesses_with_declaring_class" value="true"/>
<setting id="cleanup.add_missing__annotations" value="true"/>
<setting id="cleanup.use_blocks" value="true"/>
<setting id="cleanup.collection_cloning" value="false"/>
<setting id="cleanup.convert_to_enhanced_for_loop_if_loop_var_used" value="false"/>
<setting id="cleanup.make_variable_declarations_final" value="true"/>
<setting id="cleanup.remove_unused_private_types" value="true"/>
<setting id="cleanup.qualify_static_method_accesses_with_declaring_class" value="false"/>
<setting id="cleanup.organize_imports" value="true"/>
<setting id="cleanup.lazy_logical_operator" value="false"/>
<setting id="cleanup.bitwise_conditional_expression" value="false"/>
<setting id="cleanup.add_all" value="false"/>
<setting id="cleanup.use_directly_map_method" value="false"/>
<setting id="cleanup.qualify_static_field_accesses_with_declaring_class" value="false"/>
<setting id="cleanup.add_generated_serial_version_id" value="false"/>
<setting id="cleanup.primitive_serialization" value="false"/>
<setting id="cleanup.comparison_statement" value="false"/>
<setting id="cleanup.insert_inferred_type_arguments" value="false"/>
<setting id="cleanup.make_private_fields_final" value="true"/>
<setting id="cleanup.useless_return" value="false"/>
<setting id="cleanup.use_this_for_non_static_field_access_only_if_necessary" value="false"/>
<setting id="cleanup.remove_trailing_whitespaces_all" value="true"/>
<setting id="cleanup.remove_unnecessary_array_creation" value="false"/>
<setting id="cleanup.remove_private_ructors" value="true"/>
<setting id="cleanup.make_parameters_final" value="false"/>
<setting id="cleanup.ternary_operator" value="false"/>
<setting id="cleanup.merge_conditional_blocks" value="false"/>
<setting id="cleanup.convert_to_enhanced_for_loop" value="false"/>
<setting id="cleanup.remove_unused_private_fields" value="true"/>
<setting id="cleanup.never_use_blocks" value="false"/>
<setting id="cleanup.remove_redundant_modifiers" value="false"/>
<setting id="cleanup.redundant_falling_through_block_end" value="false"/>
<setting id="cleanup.switch" value="false"/>
<setting id="cleanup.number_suffix" value="false"/>
<setting id="cleanup.remove_unnecessary_nls_tags" value="true"/>
<setting id="cleanup.convert_to_switch_expressions" value="false"/>
<setting id="cleanup.use_this_for_non_static_field_access" value="true"/>
<setting id="cleanup.add_missing_nls_tags" value="false"/>
<setting id="cleanup.qualify_static_member_accesses_through_instances_with_declaring_class" value="true"/>
<setting id="cleanup.remove_unnecessary_casts" value="true"/>
<setting id="cleanup.objects_equals" value="false"/>
<setting id="cleanup.convert_functional_interfaces" value="true"/>
<setting id="cleanup.format_source_code" value="true"/>
<setting id="cleanup.else_if" value="true"/>
<setting id="cleanup.add_default_serial_version_id" value="true"/>
<setting id="cleanup.remove_unused_private_methods" value="true"/>
<setting id="cleanup.make_type_abstract_if_missing_method" value="false"/>
<setting id="cleanup.join" value="false"/>
<setting id="cleanup.embedded_if" value="false"/>
<setting id="cleanup.use_anonymous_class_creation" value="false"/>
<setting id="cleanup.add_missing__annotations_interface_methods" value="true"/>
<setting id="cleanup.remove_unused_private_members" value="false"/>
<setting id="cleanup.strictly_equal_or_different" value="false"/>
<setting id="cleanup.never_use_parentheses_in_expressions" value="true"/>
<setting id="cleanup.push_down_negation" value="false"/>
<setting id="cleanup.evaluate_nullable" value="false"/>
<setting id="cleanup.use_parentheses_in_expressions" value="true"/>
<setting id="cleanup.hash" value="false"/>
<setting id="cleanup.double_negation" value="false"/>
<setting id="cleanup.overridden_assignment" value="false"/>
<setting id="cleanup.correct_indentation" value="true"/>
<setting id="cleanup.use_var" value="false"/>
</profile>
</profiles>

390
Formatter.xml Normal file
View File

@ -0,0 +1,390 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<profiles version="20">
<profile kind="CodeFormatterProfile" name="EWOL" version="20">
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enuthis.declarations" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment" value="common_lines"/>
<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_ructor_declaration_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enuthis.ant" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="4"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_enuthis.ant_declaration" value="common_lines"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.align_with_spaces" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="2"/>
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_before_code_block" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_switch_case_expressions" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enuthis.ant" value="48"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.enabling_tag" value="@formatter:on"/>
<setting id="org.eclipse.jdt.core.formatter.comment.count_line_length_frothis.starting_position" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_record_components" value="49"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitructorcall_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_logical_operator" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_annotation_declaration_on_one_line" value="one_line_if_empty"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_record_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enuthis.ant" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_abstract_method" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.keep_enuthis.ant_declaration_on_one_line" value="one_line_if_empty"/>
<setting id="org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause" value="common_lines"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_ructor_call" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.keep_anonymous_type_declaration_on_one_line" value="one_line_if_empty"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_switch_case_expressions" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_shift_operator" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_code_block" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_ructor_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_type_parameters" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_loops" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.keep_simple_for_body_on_same_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_unary_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation" value="common_lines"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_ellipsis" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_enuthis.ant" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.text_block_indentation" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_module_statements" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.align_tags_names_descriptions" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enuthis.ant" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_if_then_body_block_on_one_line" value="one_line_if_empty"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_ructor_declaration_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_ructor_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression_chain" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_type_annotations" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_assertion_message_operator" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_method_declaration" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines" value="2147483647"/>
<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_resources_in_try" value="80"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_source_code" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_field" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_method" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_not_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_html" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration" value="common_lines"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_type_arguments" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enuthis.ant" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enuthis.declarations" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_package" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_label" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enuthis.declaration_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_case" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_record_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.indent_tag_description" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_record_ructor" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enuthis.declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_string_concatenation" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enuthis.ant_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_array_initializer" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_shift_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_shift_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_simple_do_while_body_on_same_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_record_components" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_additive_operator" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.keep_simple_getter_setter_on_one_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.join_lines_in_comments" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_record_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_relational_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_logical_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation" value="common_lines"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_imports" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_record_declaration" value="common_lines"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement" value="common_lines"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_default" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.disabling_tag" value="@formatter:off"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_enuthis.ants" value="49"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_method_body" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement" value="common_lines"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_case" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.align_tags_descriptions_grouped" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="200"/>
<setting id="org.eclipse.jdt.core.formatter.use_on_off_tags" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.keep_method_body_on_one_line" value="one_line_if_empty"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_loop_body_block_on_one_line" value="one_line_if_empty"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enuthis.ant" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line" value="one_line_if_empty"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_additive_operator" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_record_ructor" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_relational_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_record_declaration_on_one_line" value="one_line_if_empty"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_ructor_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_lambda_body" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_ructor_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_parameter" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_relational_operator" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_additive_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_record_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_after_code_block" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="80"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_type" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_local_variable" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enuthis.declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_default" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_between_different_tags" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_additive_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_ructor_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_field" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_conditional_operator" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_shift_operator" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause" value="common_lines"/>
<setting id="org.eclipse.jdt.core.formatter.keep_code_block_on_one_line" value="one_line_if_empty"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_ructor_declaration_throws" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_record_components" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_record_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enuthis.declaration" value="33"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_assignment_operator" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_switch" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_lambda_body_block_on_one_line" value="one_line_if_empty"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_method" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_record_ructor_on_one_line" value="one_line_if_empty"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_record_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_assertion_message" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_ructor_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_ructor_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_member_type" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_logical_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_record_declaration" value="33"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_relational_operator" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_block_comments" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_last_class_body_declaration" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_body" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.keep_simple_while_body_on_same_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_logical_operator" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_statement_group_in_switch" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enuthis.ant_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration" value="common_lines"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_enuthis.declaration_on_one_line" value="one_line_if_empty"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enuthis.ant" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enuthis.ant" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitructorcall_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enuthis.ant_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_ructor_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_ructor_declaration_throws" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_code_block" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="tab"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_string_concatenation" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="200"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/>
</profile>
</profiles>

517
LICENSE
View File

@ -1,312 +1,373 @@
Mozilla Public License Version 2.0 Mozilla Public License Version 2.0
==================================
1. Definitions 1. Definitions
--------------
1.1. "Contributor" means each individual or legal entity that creates, contributes 1.1. "Contributor"
to the creation of, or owns Covered Software. means each individual or legal entity that creates, contributes to
the creation of, or owns Covered Software.
1.2. "Contributor Version" means the combination of the Contributions of others 1.2. "Contributor Version"
(if any) used by a Contributor and that particular Contributor's Contribution. means the combination of the Contributions of others (if any) used
by a Contributor and that particular Contributor's Contribution.
1.3. "Contribution" means Covered Software of a particular Contributor. 1.3. "Contribution"
means Covered Software of a particular Contributor.
1.4. "Covered Software" means Source Code Form to which the initial Contributor 1.4. "Covered Software"
has attached the notice in Exhibit A, the Executable Form of such Source Code means Source Code Form to which the initial Contributor has attached
Form, and Modifications of such Source Code Form, in each case including portions the notice in Exhibit A, the Executable Form of such Source Code
thereof. Form, and Modifications of such Source Code Form, in each case
including portions thereof.
1.5. "Incompatible With Secondary Licenses" means 1.5. "Incompatible With Secondary Licenses"
means
(a) that the initial Contributor has attached the notice described in Exhibit (a) that the initial Contributor has attached the notice described
B to the Covered Software; or in Exhibit B to the Covered Software; or
(b) that the Covered Software was made available under the terms of version (b) that the Covered Software was made available under the terms of
1.1 or earlier of the License, but not also under the terms of a Secondary version 1.1 or earlier of the License, but not also under the
License. terms of a Secondary License.
1.6. "Executable Form" means any form of the work other than Source Code Form. 1.6. "Executable Form"
means any form of the work other than Source Code Form.
1.7. "Larger Work" means a work that combines Covered Software with other 1.7. "Larger Work"
material, in a separate file or files, that is not Covered Software. means a work that combines Covered Software with other material, in
a separate file or files, that is not Covered Software.
1.8. "License" means this document. 1.8. "License"
means this document.
1.9. "Licensable" means having the right to grant, to the maximum extent possible, 1.9. "Licensable"
whether at the time of the initial grant or subsequently, any and all of the means having the right to grant, to the maximum extent possible,
rights conveyed by this License. whether at the time of the initial grant or subsequently, any and
all of the rights conveyed by this License.
1.10. "Modifications" means any of the following: 1.10. "Modifications"
means any of the following:
(a) any file in Source Code Form that results from an addition to, deletion (a) any file in Source Code Form that results from an addition to,
from, or modification of the contents of Covered Software; or deletion from, or modification of the contents of Covered
Software; or
(b) any new file in Source Code Form that contains any Covered Software. (b) any new file in Source Code Form that contains any Covered
Software.
1.11. "Patent Claims" of a Contributor means any patent claim(s), including 1.11. "Patent Claims" of a Contributor
without limitation, method, process, and apparatus claims, in any patent Licensable means any patent claim(s), including without limitation, method,
by such Contributor that would be infringed, but for the grant of the License, process, and apparatus claims, in any patent Licensable by such
by the making, using, selling, offering for sale, having made, import, or Contributor that would be infringed, but for the grant of the
transfer of either its Contributions or its Contributor Version. License, by the making, using, selling, offering for sale, having
made, import, or transfer of either its Contributions or its
Contributor Version.
1.12. "Secondary License" means either the GNU General Public License, Version 1.12. "Secondary License"
2.0, the GNU Lesser General Public License, Version 2.1, the GNU Affero General means either the GNU General Public License, Version 2.0, the GNU
Public License, Version 3.0, or any later versions of those licenses. Lesser General Public License, Version 2.1, the GNU Affero General
Public License, Version 3.0, or any later versions of those
licenses.
1.13. "Source Code Form" means the form of the work preferred for making modifications. 1.13. "Source Code Form"
means the form of the work preferred for making modifications.
1.14. "You" (or "Your") means an individual or a legal entity exercising rights 1.14. "You" (or "Your")
under this License. For legal entities, "You" includes any entity that controls, means an individual or a legal entity exercising rights under this
is controlled by, or is under common control with You. For purposes of this License. For legal entities, "You" includes any entity that
definition, "control" means (a) the power, direct or indirect, to cause the controls, is controlled by, or is under common control with You. For
direction or management of such entity, whether by contract or otherwise, purposes of this definition, "control" means (a) the power, direct
or (b) ownership of more than fifty percent (50%) of the outstanding shares or indirect, to cause the direction or management of such entity,
or beneficial ownership of such entity. whether by contract or otherwise, or (b) ownership of more than
fifty percent (50%) of the outstanding shares or beneficial
ownership of such entity.
2. License Grants and Conditions 2. License Grants and Conditions
--------------------------------
2.1. Grants 2.1. Grants
Each Contributor hereby grants You a world-wide, royalty-free, non-exclusive Each Contributor hereby grants You a world-wide, royalty-free,
license: non-exclusive license:
(a) under intellectual property rights (other than patent or trademark) Licensable (a) under intellectual property rights (other than patent or trademark)
by such Contributor to use, reproduce, make available, modify, display, perform, Licensable by such Contributor to use, reproduce, make available,
distribute, and otherwise exploit its Contributions, either on an unmodified modify, display, perform, distribute, and otherwise exploit its
basis, with Modifications, or as part of a Larger Work; and Contributions, either on an unmodified basis, with Modifications, or
as part of a Larger Work; and
(b) under Patent Claims of such Contributor to make, use, sell, offer for (b) under Patent Claims of such Contributor to make, use, sell, offer
sale, have made, import, and otherwise transfer either its Contributions or for sale, have made, import, and otherwise transfer either its
its Contributor Version. Contributions or its Contributor Version.
2.2. Effective Date 2.2. Effective Date
The licenses granted in Section 2.1 with respect to any Contribution become The licenses granted in Section 2.1 with respect to any Contribution
effective for each Contribution on the date the Contributor first distributes become effective for each Contribution on the date the Contributor first
such Contribution. distributes such Contribution.
2.3. Limitations on Grant Scope 2.3. Limitations on Grant Scope
The licenses granted in this Section 2 are the only rights granted under this The licenses granted in this Section 2 are the only rights granted under
License. No additional rights or licenses will be implied from the distribution this License. No additional rights or licenses will be implied from the
or licensing of Covered Software under this License. Notwithstanding Section distribution or licensing of Covered Software under this License.
2.1(b) above, no patent license is granted by a Contributor: Notwithstanding Section 2.1(b) above, no patent license is granted by a
Contributor:
(a) for any code that a Contributor has removed from Covered Software; or (a) for any code that a Contributor has removed from Covered Software;
or
(b) for infringements caused by: (i) Your and any other third party's modifications (b) for infringements caused by: (i) Your and any other third party's
of Covered Software, or (ii) the combination of its Contributions with other modifications of Covered Software, or (ii) the combination of its
software (except as part of its Contributor Version); or Contributions with other software (except as part of its Contributor
Version); or
(c) under Patent Claims infringed by Covered Software in the absence of its (c) under Patent Claims infringed by Covered Software in the absence of
Contributions. its Contributions.
This License does not grant any rights in the trademarks, service marks, or This License does not grant any rights in the trademarks, service marks,
logos of any Contributor (except as may be necessary to comply with the notice or logos of any Contributor (except as may be necessary to comply with
requirements in Section 3.4). the notice requirements in Section 3.4).
2.4. Subsequent Licenses 2.4. Subsequent Licenses
No Contributor makes additional grants as a result of Your choice to distribute No Contributor makes additional grants as a result of Your choice to
the Covered Software under a subsequent version of this License (see Section distribute the Covered Software under a subsequent version of this
10.2) or under the terms of a Secondary License (if permitted under the terms License (see Section 10.2) or under the terms of a Secondary License (if
of Section 3.3). permitted under the terms of Section 3.3).
2.5. Representation 2.5. Representation
Each Contributor represents that the Contributor believes its Contributions Each Contributor represents that the Contributor believes its
are its original creation(s) or it has sufficient rights to grant the rights Contributions are its original creation(s) or it has sufficient rights
to its Contributions conveyed by this License. to grant the rights to its Contributions conveyed by this License.
2.6. Fair Use 2.6. Fair Use
This License is not intended to limit any rights You have under applicable This License is not intended to limit any rights You have under
copyright doctrines of fair use, fair dealing, or other equivalents. applicable copyright doctrines of fair use, fair dealing, or other
equivalents.
2.7. Conditions 2.7. Conditions
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
Section 2.1. in Section 2.1.
3. Responsibilities 3. Responsibilities
-------------------
3.1. Distribution of Source Form 3.1. Distribution of Source Form
All distribution of Covered Software in Source Code Form, including any Modifications All distribution of Covered Software in Source Code Form, including any
that You create or to which You contribute, must be under the terms of this Modifications that You create or to which You contribute, must be under
License. You must inform recipients that the Source Code Form of the Covered the terms of this License. You must inform recipients that the Source
Software is governed by the terms of this License, and how they can obtain Code Form of the Covered Software is governed by the terms of this
a copy of this License. You may not attempt to alter or restrict the recipients' License, and how they can obtain a copy of this License. You may not
rights in the Source Code Form. attempt to alter or restrict the recipients' rights in the Source Code
Form.
3.2. Distribution of Executable Form 3.2. Distribution of Executable Form
If You distribute Covered Software in Executable Form then: If You distribute Covered Software in Executable Form then:
(a) such Covered Software must also be made available in Source Code Form, (a) such Covered Software must also be made available in Source Code
as described in Section 3.1, and You must inform recipients of the Executable Form, as described in Section 3.1, and You must inform recipients of
Form how they can obtain a copy of such Source Code Form by reasonable means the Executable Form how they can obtain a copy of such Source Code
in a timely manner, at a charge no more than the cost of distribution to the Form by reasonable means in a timely manner, at a charge no more
recipient; and than the cost of distribution to the recipient; and
(b) You may distribute such Executable Form under the terms of this License, (b) You may distribute such Executable Form under the terms of this
or sublicense it under different terms, provided that the license for the License, or sublicense it under different terms, provided that the
Executable Form does not attempt to limit or alter the recipients' rights license for the Executable Form does not attempt to limit or alter
in the Source Code Form under this License. the recipients' rights in the Source Code Form under this License.
3.3. Distribution of a Larger Work 3.3. Distribution of a Larger Work
You may create and distribute a Larger Work under terms of Your choice, provided You may create and distribute a Larger Work under terms of Your choice,
that You also comply with the requirements of this License for the Covered provided that You also comply with the requirements of this License for
Software. If the Larger Work is a combination of Covered Software with a work the Covered Software. If the Larger Work is a combination of Covered
governed by one or more Secondary Licenses, and the Covered Software is not Software with a work governed by one or more Secondary Licenses, and the
Incompatible With Secondary Licenses, this License permits You to additionally Covered Software is not Incompatible With Secondary Licenses, this
distribute such Covered Software under the terms of such Secondary License(s), License permits You to additionally distribute such Covered Software
so that the recipient of the Larger Work may, at their option, further distribute under the terms of such Secondary License(s), so that the recipient of
the Covered Software under the terms of either this License or such Secondary the Larger Work may, at their option, further distribute the Covered
Software under the terms of either this License or such Secondary
License(s). License(s).
3.4. Notices 3.4. Notices
You may not remove or alter the substance of any license notices (including You may not remove or alter the substance of any license notices
copyright notices, patent notices, disclaimers of warranty, or limitations (including copyright notices, patent notices, disclaimers of warranty,
of liability) contained within the Source Code Form of the Covered Software, or limitations of liability) contained within the Source Code Form of
except that You may alter any license notices to the extent required to remedy the Covered Software, except that You may alter any license notices to
known factual inaccuracies. the extent required to remedy known factual inaccuracies.
3.5. Application of Additional Terms 3.5. Application of Additional Terms
You may choose to offer, and to charge a fee for, warranty, support, indemnity You may choose to offer, and to charge a fee for, warranty, support,
or liability obligations to one or more recipients of Covered Software. However, indemnity or liability obligations to one or more recipients of Covered
You may do so only on Your own behalf, and not on behalf of any Contributor. Software. However, You may do so only on Your own behalf, and not on
You must make it absolutely clear that any such warranty, support, indemnity, behalf of any Contributor. You must make it absolutely clear that any
or liability obligation is offered by You alone, and You hereby agree to indemnify such warranty, support, indemnity, or liability obligation is offered by
every Contributor for any liability incurred by such Contributor as a result You alone, and You hereby agree to indemnify every Contributor for any
of warranty, support, indemnity or liability terms You offer. You may include liability incurred by such Contributor as a result of warranty, support,
additional disclaimers of warranty and limitations of liability specific to indemnity or liability terms You offer. You may include additional
any jurisdiction. disclaimers of warranty and limitations of liability specific to any
jurisdiction.
4. Inability to Comply Due to Statute or Regulation 4. Inability to Comply Due to Statute or Regulation
---------------------------------------------------
If it is impossible for You to comply with any of the terms of this License If it is impossible for You to comply with any of the terms of this
with respect to some or all of the Covered Software due to statute, judicial License with respect to some or all of the Covered Software due to
order, or regulation then You must: (a) comply with the terms of this License statute, judicial order, or regulation then You must: (a) comply with
to the maximum extent possible; and (b) describe the limitations and the code the terms of this License to the maximum extent possible; and (b)
they affect. Such description must be placed in a text file included with describe the limitations and the code they affect. Such description must
all distributions of the Covered Software under this License. Except to the be placed in a text file included with all distributions of the Covered
extent prohibited by statute or regulation, such description must be sufficiently Software under this License. Except to the extent prohibited by statute
detailed for a recipient of ordinary skill to be able to understand it. or regulation, such description must be sufficiently detailed for a
recipient of ordinary skill to be able to understand it.
5. Termination 5. Termination
--------------
5.1. The rights granted under this License will terminate automatically if 5.1. The rights granted under this License will terminate automatically
You fail to comply with any of its terms. However, if You become compliant, if You fail to comply with any of its terms. However, if You become
then the rights granted under this License from a particular Contributor are compliant, then the rights granted under this License from a particular
reinstated (a) provisionally, unless and until such Contributor explicitly Contributor are reinstated (a) provisionally, unless and until such
and finally terminates Your grants, and (b) on an ongoing basis, if such Contributor Contributor explicitly and finally terminates Your grants, and (b) on an
fails to notify You of the non-compliance by some reasonable means prior to ongoing basis, if such Contributor fails to notify You of the
60 days after You have come back into compliance. Moreover, Your grants from non-compliance by some reasonable means prior to 60 days after You have
a particular Contributor are reinstated on an ongoing basis if such Contributor come back into compliance. Moreover, Your grants from a particular
notifies You of the non-compliance by some reasonable means, this is the first Contributor are reinstated on an ongoing basis if such Contributor
time You have received notice of non-compliance with this License from such notifies You of the non-compliance by some reasonable means, this is the
Contributor, and You become compliant prior to 30 days after Your receipt first time You have received notice of non-compliance with this License
of the notice. from such Contributor, and You become compliant prior to 30 days after
Your receipt of the notice.
5.2. If You initiate litigation against any entity by asserting a patent infringement 5.2. If You initiate litigation against any entity by asserting a patent
claim (excluding declaratory judgment actions, counter-claims, and cross-claims) infringement claim (excluding declaratory judgment actions,
alleging that a Contributor Version directly or indirectly infringes any patent, counter-claims, and cross-claims) alleging that a Contributor Version
then the rights granted to You by any and all Contributors for the Covered directly or indirectly infringes any patent, then the rights granted to
Software under Section 2.1 of this License shall terminate. You by any and all Contributors for the Covered Software under Section
2.1 of this License shall terminate.
5.3. In the event of termination under Sections 5.1 or 5.2 above, all end 5.3. In the event of termination under Sections 5.1 or 5.2 above, all
user license agreements (excluding distributors and resellers) which have end user license agreements (excluding distributors and resellers) which
been validly granted by You or Your distributors under this License prior have been validly granted by You or Your distributors under this License
to termination shall survive termination. prior to termination shall survive termination.
6. Disclaimer of Warranty ************************************************************************
* *
* 6. Disclaimer of Warranty *
* ------------------------- *
* *
* Covered Software is provided under this License on an "as is" *
* basis, without warranty of any kind, either expressed, implied, or *
* statutory, including, without limitation, warranties that the *
* Covered Software is free of defects, merchantable, fit for a *
* particular purpose or non-infringing. The entire risk as to the *
* quality and performance of the Covered Software is with You. *
* Should any Covered Software prove defective in any respect, You *
* (not any Contributor) assume the cost of any necessary servicing, *
* repair, or correction. This disclaimer of warranty constitutes an *
* essential part of this License. No use of any Covered Software is *
* authorized under this License except under this disclaimer. *
* *
************************************************************************
Covered Software is provided under this License on an "as is" basis, without ************************************************************************
warranty of any kind, either expressed, implied, or statutory, including, * *
without limitation, warranties that the Covered Software is free of defects, * 7. Limitation of Liability *
merchantable, fit for a particular purpose or non-infringing. The entire risk * -------------------------- *
as to the quality and performance of the Covered Software is with You. Should * *
any Covered Software prove defective in any respect, You (not any Contributor) * Under no circumstances and under no legal theory, whether tort *
assume the cost of any necessary servicing, repair, or correction. This disclaimer * (including negligence), contract, or otherwise, shall any *
of warranty constitutes an essential part of this License. No use of any Covered * Contributor, or anyone who distributes Covered Software as *
Software is authorized under this License except under this disclaimer. * permitted above, be liable to You for any direct, indirect, *
* special, incidental, or consequential damages of any character *
* including, without limitation, damages for lost profits, loss of *
* goodwill, work stoppage, computer failure or malfunction, or any *
* and all other commercial damages or losses, even if such party *
* shall have been informed of the possibility of such damages. This *
* limitation of liability shall not apply to liability for death or *
* personal injury resulting from such party's negligence to the *
* extent applicable law prohibits such limitation. Some *
* jurisdictions do not allow the exclusion or limitation of *
* incidental or consequential damages, so this exclusion and *
* limitation may not apply to You. *
* *
************************************************************************
7. Limitation of Liability 8. Litigation
-------------
Under no circumstances and under no legal theory, whether tort (including Any litigation relating to this License may be brought only in the
negligence), contract, or otherwise, shall any Contributor, or anyone who courts of a jurisdiction where the defendant maintains its principal
distributes Covered Software as permitted above, be liable to You for any place of business and such litigation shall be governed by laws of that
direct, indirect, special, incidental, or consequential damages of any character jurisdiction, without reference to its conflict-of-law provisions.
including, without limitation, damages for lost profits, loss of goodwill, Nothing in this Section shall prevent a party's ability to bring
work stoppage, computer failure or malfunction, or any and all other commercial cross-claims or counter-claims.
damages or losses, even if such party shall have been informed of the possibility
of such damages. This limitation of liability shall not apply to liability
for death or personal injury resulting from such party's negligence to the
extent applicable law prohibits such limitation. Some jurisdictions do not
allow the exclusion or limitation of incidental or consequential damages,
so this exclusion and limitation may not apply to You.
8. Litigation 9. Miscellaneous
----------------
Any litigation relating to this License may be brought only in the courts This License represents the complete agreement concerning the subject
of a jurisdiction where the defendant maintains its principal place of business matter hereof. If any provision of this License is held to be
and such litigation shall be governed by laws of that jurisdiction, without unenforceable, such provision shall be reformed only to the extent
reference to its conflict-of-law provisions. Nothing in this Section shall necessary to make it enforceable. Any law or regulation which provides
prevent a party's ability to bring cross-claims or counter-claims. that the language of a contract shall be construed against the drafter
shall not be used to construe this License against a Contributor.
9. Miscellaneous 10. Versions of the License
---------------------------
This License represents the complete agreement concerning the subject matter 10.1. New Versions
hereof. If any provision of this License is held to be unenforceable, such
provision shall be reformed only to the extent necessary to make it enforceable.
Any law or regulation which provides that the language of a contract shall
be construed against the drafter shall not be used to construe this License
against a Contributor.
10. Versions of the License Mozilla Foundation is the license steward. Except as provided in Section
10.3, no one other than the license steward has the right to modify or
publish new versions of this License. Each version will be given a
distinguishing version number.
10.1. New Versions 10.2. Effect of New Versions
Mozilla Foundation is the license steward. Except as provided in Section 10.3, You may distribute the Covered Software under the terms of the version
no one other than the license steward has the right to modify or publish new of the License under which You originally received the Covered Software,
versions of this License. Each version will be given a distinguishing version or under the terms of any subsequent version published by the license
number. steward.
10.2. Effect of New Versions 10.3. Modified Versions
You may distribute the Covered Software under the terms of the version of If you create software not governed by this License, and you want to
the License under which You originally received the Covered Software, or under create a new license for such software, you may create and use a
the terms of any subsequent version published by the license steward. modified version of this License if you rename the license and remove
any references to the name of the license steward (except to note that
such modified license differs from this License).
10.3. Modified Versions 10.4. Distributing Source Code Form that is Incompatible With Secondary
Licenses
If you create software not governed by this License, and you want to create If You choose to distribute Source Code Form that is Incompatible With
a new license for such software, you may create and use a modified version Secondary Licenses under the terms of this version of the License, the
of this License if you rename the license and remove any references to the notice described in Exhibit B of this License must be attached.
name of the license steward (except to note that such modified license differs
from this License).
10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses Exhibit A - Source Code Form License Notice
-------------------------------------------
If You choose to distribute Source Code Form that is Incompatible With Secondary This Source Code Form is subject to the terms of the Mozilla Public
Licenses under the terms of this version of the License, the notice described License, v. 2.0. If a copy of the MPL was not distributed with this
in Exhibit B of this License must be attached. Exhibit A - Source Code Form file, You can obtain one at http://mozilla.org/MPL/2.0/.
License Notice
This Source Code Form is subject to the terms of the Mozilla Public License, If it is not possible or desirable to put the notice in a particular
v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain file, then You may include the notice in a location (such as a LICENSE
one at http://mozilla.org/MPL/2.0/. file in a relevant directory) where a recipient would be likely to look
for such a notice.
If it is not possible or desirable to put the notice in a particular file,
then You may include the notice in a location (such as a LICENSE file in a
relevant directory) where a recipient would be likely to look for such a notice.
You may add additional accurate notices of copyright ownership. You may add additional accurate notices of copyright ownership.
Exhibit B - "Incompatible With Secondary Licenses" Notice Exhibit B - "Incompatible With Secondary Licenses" Notice
---------------------------------------------------------
This Source Code Form is "Incompatible With Secondary Licenses", as defined This Source Code Form is "Incompatible With Secondary Licenses", as
by the Mozilla Public License, v. 2.0. defined by the Mozilla Public License, v. 2.0.

View File

@ -1,3 +1,8 @@
# esignal Atria-soft EWOL
==============
[MPL-2] Mozilla public licence (V 2.0)
Ewol basic GUI
[MPL-2] Signal messaging model

View File

@ -0,0 +1,66 @@
#!/usr/bin/python
import realog.debug as debug
import lutin.tools as tools
import realog.debug as debug
import lutin.image as image
import os
import lutin.multiprocess as lutinMultiprocess
def get_type():
return "LIBRARY_DYNAMIC"
def get_desc():
return "Ewol Tool Kit"
def get_licence():
return "MPL-2"
def get_compagny_type():
return "org"
def get_compagny_name():
return "atria-soft"
#def get_maintainer():
# return "authors.txt"
#def get_version():
# return "version.txt"
def configure(target, my_module):
my_module.add_src_file([
'src/module-info.java',
'src/org/atriasoft/esignal/ConnectionRemoveInterface.java',
'src/org/atriasoft/esignal/GenericSignalInstrumented.java',
'src/org/atriasoft/esignal/internal/ConnectedElementTRefConsumerWeakObject.java',
'src/org/atriasoft/esignal/internal/ConnectedElementTRefConsumerWeakConnection.java',
'src/org/atriasoft/esignal/internal/ConnectedElementTRefConsumer.java',
'src/org/atriasoft/esignal/internal/ConnectedElementURefConsumerWeakObject.java',
'src/org/atriasoft/esignal/internal/ConnectedElementURefConsumerWeakObjectWeakConnection.java',
'src/org/atriasoft/esignal/internal/ConnectedElementInterface.java',
'src/org/atriasoft/esignal/internal/ConnectedElementTWeakConsumer.java',
'src/org/atriasoft/esignal/SignalEmpty.java',
'src/org/atriasoft/esignal/ISignalEmpty.java',
'src/org/atriasoft/esignal/Signal.java',
'src/org/atriasoft/esignal/ISignal.java',
'src/org/atriasoft/esignal/Connection.java',
'src/org/atriasoft/esignal/GenericSignal.java',
])
my_module.add_path('src/', type='java')
my_module.add_depend([
'org-atriasoft-etk'
])
#my_module.add_path([
# 'lib/spotbugs-annotations-4.2.2.jar'
# ],
# type='java',
# export=True
#);
my_module.add_flag('java', "RELEASE_15_PREVIEW");
return True

123
pom.xml Normal file
View File

@ -0,0 +1,123 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.atriasoft</groupId>
<artifactId>esignal</artifactId>
<version>0.1.0</version>
<properties>
<maven.compiler.version>3.13.0</maven.compiler.version>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<maven.dependency.version>3.1.1</maven.dependency.version>
</properties>
<repositories>
<repository>
<id>gitea</id>
<url>https://gitea.atria-soft.org/api/packages/org.atriasoft/maven</url>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>gitea</id>
<url>https://gitea.atria-soft.org/api/packages/org.atriasoft/maven</url>
</repository>
<snapshotRepository>
<id>gitea</id>
<url>https://gitea.atria-soft.org/api/packages/org.atriasoft/maven</url>
</snapshotRepository>
</distributionManagement>
<dependencies>
<dependency>
<groupId>org.atriasoft</groupId>
<artifactId>etk</artifactId>
<version>0.1.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.11.0-M2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.1.0-alpha1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test/src</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.version}</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<!--<encoding>${project.build.sourceEncoding}</encoding>-->
</configuration>
</plugin>
<!-- Create the source bundle -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- junit results -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>fully.qualified.MainClass</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
<!-- Java-doc generation for stand-alone site -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<show>private</show>
<nohelp>true</nohelp>
</configuration>
</plugin>
</plugins>
</build>
<!-- Generate Java-docs As Part Of Project Reports -->
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<show>public</show>
</configuration>
</plugin>
</plugins>
</reporting>
</project>

10
src/module-info.java Normal file
View File

@ -0,0 +1,10 @@
/** Basic module interface.
*
* @author Edouard DUPIN */
open module org.atriasoft.esignal {
exports org.atriasoft.esignal;
requires transitive org.atriasoft.etk;
requires com.github.spotbugs.annotations;
}

View File

@ -0,0 +1,43 @@
package org.atriasoft.esignal;
import java.lang.ref.WeakReference;
public class Connection implements AutoCloseable {
protected WeakReference<ConnectionRemoveInterface> connection;
public void connectionIsRemovedBySignal() {
this.connection = null;
}
public Connection( final ConnectionRemoveInterface object ) {
this.connection = new WeakReference<>(object);
}
public Connection() {
this.connection = null;
}
@Override
public void close() {
if (this.connection == null) {
return;
}
ConnectionRemoveInterface tmp = this.connection.get();
if (tmp == null) {
return;
}
tmp.disconnect(this);
this.connection = null;
}
public boolean isConnected() {
if (this.connection == null) {
return false;
}
ConnectionRemoveInterface tmp = this.connection.get();
if (tmp == null) {
return false;
}
return true;
}
}

View File

@ -0,0 +1,12 @@
package org.atriasoft.esignal;
/**
* Interface to permit to the connection to unlink itself.
*/
public interface ConnectionRemoveInterface {
/**
* Request the removing on the specify connection
* @param connection Connection to removed.
*/
void disconnect(final Connection connection);
}

View File

@ -0,0 +1,296 @@
package org.atriasoft.esignal;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.atriasoft.esignal.internal.ConnectedElementInterface;
import org.atriasoft.esignal.internal.ConnectedElementTRefConsumerWeakConnection;
import org.atriasoft.esignal.internal.ConnectedElementTRefConsumerWeakObject;
import org.atriasoft.esignal.internal.ConnectedElementTWeakConsumer;
import org.atriasoft.esignal.internal.ConnectedElementURefConsumerWeakObject;
import org.atriasoft.esignal.internal.ConnectedElementURefConsumerWeakObjectWeakConnection;
import edu.umd.cs.findbugs.annotations.CheckReturnValue;
/**
* Generic interface for a signaling model...
*
* @param <T> generic Runnable, Consumer, or BiConsumer template...
*/
public class GenericSignal<T, U> implements ConnectionRemoveInterface {
// List of all connected Links
protected List<ConnectedElementInterface<T, U>> data = new ArrayList<>();
/**
* Clear all connection on this signal.
*/
public void clear() {
List<ConnectedElementInterface<T, U>> data2 = this.data;
synchronized(this.data) {
this.data = new ArrayList<>();
}
final Iterator<ConnectedElementInterface<T, U>> iterator = data2.iterator();
while (iterator.hasNext()) {
final ConnectedElementInterface<T, U> elem = iterator.next();
elem.disconnect();
}
}
/**
* Connect a Function to this signal (the signal will keep only the weak pointer on the function)
* @param function Function to connect (Keep a WeakReference on it only)
* @apiNote Make some attention when you connect a global lamba, nothing can permit to remove it @see connectAutoRemoveObject()
*
* {@code
* // Create the connection
* // (1) create connection (direct):
* ConsumerXX tmp = this::onEventXXX;
* eventXXX.connectWeak(tmp);
* // (2) create connection (lambda):
* ConsumerXX tmp = (www) -> { ... };
* eventXXX.connectWeak(tmp);
*
* // Disconnect:
* // (1) remove connection (abstract way):
* tmp = null; // ==> the function scope will be removed only when the garbage collector is called.
* // (2) remove the connection from signal:
* eventXXX.disconnect(tmp);
* }
* @apiNote You can be called while the Garbage collected does not removed the reference on the function or the lambda...
*/
public void connectWeak(final T function) {
synchronized(this.data) {
this.data.add(new ConnectedElementTWeakConsumer<T, U>(function));
}
}
/**
* Connect to the signal with a @see Connection object that permit to remove the connection to the signal.
* @param function Function to connect (Keep a WeakReference on it only)
* @return The connection interface.
* {@code
* // Create the connection
* // (1) create connection (direct):
* Connection tmp = eventXXX.connect(this::onEventXXX);
* // (2) create connection (lambda):
* Connection tmp = eventXXX.connect((www) -> { ... });
*
* // Disconnect:
* // (1) remove connection (abstract way):
* tmp = null; // ==> the function scope will be removed only when the garbage collector is called.
* // (2) remove the connection from signal:
* tmp.close(); // use close instead of disconnect ==> permit to detect error (Connection is AutoClosable)
* // (3) remove the connection from signal:
* eventXXX.disconnect(tmp);
* }
*/
@CheckReturnValue
public Connection connect(final T function) {
Connection out = new Connection(this);
synchronized(this.data) {
this.data.add(new ConnectedElementTRefConsumerWeakConnection<T, U>(out, function));
}
return out;
}
/**
* Connect to the signal with Input object as first parameter with a @see Connection object that permit to remove the connection to the signal.
* This permit to remove hidden capture of the "this" in the lambda...
* @param function Function to connect (Keep a WeakReference on it only)
* @return The connection interface.
* {@code
* class MyClass {
* Connection tmp = null;
* MyClass() {
* // Create the connection
* // (1) create connection (direct):
* tmp = eventXXX.connect(this, this::onEventXXX);
* // (2) create connection (lambda):
* tmp = eventXXX.connect((self, www) -> { ... });
* }
* public static onEventXXX(Object self, ...) {
* MyClass mySelf = (MyClass) self;
* ...
* }
* // Disconnect:
* public void disconnect() {
* // (1) remove connection (abstract way):
* tmp = null; // ==> the function scope will be removed only when the garbage collector is called.
* // (2) remove the connection from signal:
* tmp.close(); // use close instead of disconnect ==> permit to detect error (Connection is AutoClosable)
* // (3) remove the connection from signal:
* eventXXX.disconnect(tmp);
* // OR
* eventXXX.disconnect(this);
* }
* }
* }
*/
@CheckReturnValue
public Connection connect(final Object object, final U function) {
Connection out = new Connection(this);
synchronized(this.data) {
this.data.add(new ConnectedElementURefConsumerWeakObjectWeakConnection<T, U>(out, object, function));
}
return out;
}
/**
* Connect to the signal and automatically disconnect when the object is removed
* @param object Object to check if remove to continue keeping the signal active (Keep a WeakReference on it only)
* @param function Function to connect (Keep a WeakReference on it only)
*/
public void connectAutoRemoveObject(final Object object, final T function) {
synchronized(this.data) {
this.data.add(new ConnectedElementTRefConsumerWeakObject<T, U>(object, function));
}
}
/**
* Connect to the signal and automatically disconnect when the object is removed
* @param object Object to check if remove to continue keeping the signal active (Keep a WeakReference on it only)
* @param function Function to connect (Keep a WeakReference on it only)
*/
public void connectAuto(final Object object, final U function) {
synchronized(this.data) {
this.data.add(new ConnectedElementURefConsumerWeakObject<T, U>(object, function));
}
}
/**
* Disconnect all connection that have this Object/function in reference
* @param obj Object to check the compatibility.
* @apiNote if you add a direct connection like {code connect(this::onEvent(...)) } you can not disconnect it
*/
public void disconnect(final T obj) {
synchronized(this.data) {
final Iterator<ConnectedElementInterface<T, U>> iterator = this.data.iterator();
while (iterator.hasNext()) {
final ConnectedElementInterface<T, U> elem = iterator.next();
if (elem.isCompatibleWith(obj)) {
iterator.remove();
}
}
}
}
@Override
public void disconnect(final Connection connection) {
synchronized(this.data) {
final Iterator<ConnectedElementInterface<T, U>> iterator = this.data.iterator();
while (iterator.hasNext()) {
final ConnectedElementInterface<T, U> elem = iterator.next();
if (elem.isCompatibleWith(connection)) {
elem.disconnect();
iterator.remove();
}
}
}
}
/**
* Get a copy on the List of current connection and remove all the deprecated connection.
* @return The copy of the available connection (Note: the connection can be removed when return)
*/
protected List<ConnectedElementInterface<T, U>> getACleanedList() {
// first clean the list
cleanedList();
// get a copy of elements
List<ConnectedElementInterface<T, U>> out = null;
// clean the list:
synchronized(this.data) {
// simple optimization:
if (this.data.isEmpty()) {
return null;
}
// clone the list to permit to have asynchronous remove call
out = new ArrayList<>(this.data);
}
return out;
}
/**
* Clean all the deprecated list of removed elements
*/
protected void cleanedList() {
// clean the list:
synchronized(this.data) {
final Iterator<ConnectedElementInterface<T, U>> iterator = this.data.iterator();
while (iterator.hasNext()) {
final ConnectedElementInterface<T, U> elem = iterator.next();
if (elem.isObjectDependent() && elem.lockObjects() == null) {
elem.disconnect();
iterator.remove();
} else if (elem.getConsumer() == null && elem.getConsumer2() == null) {
elem.disconnect();
iterator.remove();
}
}
}
}
/**
* Get the Number of current connection (clean is not done).
* @return Number of connection
*/
public int size() {
return this.data.size();
}
/**
* Get the Number of current connection (clean is done).
* @return Number of connection
*/
public int sizeCleaned() {
cleanedList();
return this.data.size();
}
/**
* Connect a class with his hunction name
* @param object
* @param function
* @return
*/
// @CheckReturnValue
// public <U> Connection connect(final U object, final String function) {
// Type typeParam = (Class) ((T) getClass());
// Method[] listMethod = object.getClass().getMethods();
// Method findElem = null;
// for (int iii=0; iii<listMethod.length; iii++) {
// Method elem = listMethod[iii];
// if (elem.getName().equals(function)) {
// if (elem.getParameterCount() != 2) {
//
// } else {
// Parameter[] params = elem.getParameters();
// Parameter param = params[0];
// if (!param.getType().equals(object.getClass()) ) {
// // error
//
// } else {
//
// }
// param = params[1];
// if (! T.class.isAssignableFrom(param.getType()) ) {
// // error
//
// } else {
//
// }
//
// }
//
// }
// }
// Method out = object.getClass().getMethod(function, U.class, T.class );
// return null;
// }
// public void connectWeak(final T function) {
// public <U> void connectWeak(final U object, final T+1 function) {
// public Connection connect(final T function) {
// public <U> Connection connect(final U object, final T+1 function) {
// public <U> Connection connect(final U object, final String functionName) {
}

View File

@ -0,0 +1,102 @@
package org.atriasoft.esignal;
import java.util.function.BiConsumer;
public class GenericSignalInstrumented<T, U> extends GenericSignal<T, U> {
BiConsumer<Integer, Integer> callback = null;
/**
* Notify to the callback that the number of connection change
* @param sizeStart Number of connection before call
* @param sizeEnd Number of connection after call
*/
protected synchronized void notifyChange(final int sizeStart, final int sizeEnd) {
if (sizeEnd == sizeStart) {
return;
}
if (this.callback == null) {
return;
}
BiConsumer<Integer, Integer> cb = this.callback;
if (cb == null) {
this.callback = null;
return;
}
// notify client
cb.accept(sizeEnd, sizeEnd - sizeStart);
}
/**
* Specify the consumer that managed the dynamic connection handle change
* @param callback BiConsumer that receive the number of current connection and the delta of connection since the previous call.
*/
public synchronized void setCallBackNotification(final BiConsumer<Integer, Integer> callback) {
this.callback = callback;
}
@Override
public void clear() {
int sizeStart = this.data.size();
super.clear();
notifyChange(sizeStart, this.data.size());
}
@Override
public Connection connect(final T function) {
int sizeStart = this.data.size();
Connection tmp = super.connect(function);
notifyChange(sizeStart, this.data.size());
return tmp;
}
@Override
public void disconnect(final T obj) {
int sizeStart = this.data.size();
super.disconnect(obj);
notifyChange(sizeStart, this.data.size());
}
@Override
public void connectWeak(final T function) {
int sizeStart = this.data.size();
super.connectWeak(function);
notifyChange(sizeStart, this.data.size());
}
@Override
public Connection connect(final Object object, final U function) {
int sizeStart = this.data.size();
Connection out = super.connect(object, function);
notifyChange(sizeStart, this.data.size());
return out;
}
@Override
public void connectAuto(final Object object, final U function) {
int sizeStart = this.data.size();
super.connectAuto(object, function);
notifyChange(sizeStart, this.data.size());
}
@Override
public void connectAutoRemoveObject(final Object object, final T function) {
int sizeStart = this.data.size();
super.connectAutoRemoveObject(object, function);
notifyChange(sizeStart, this.data.size());
}
@Override
public void disconnect(final Connection connection) {
int sizeStart = this.data.size();
super.disconnect(connection);
notifyChange(sizeStart, this.data.size());
}
@Override
protected void cleanedList() {
int sizeStart = this.data.size();
super.cleanedList();
notifyChange(sizeStart, this.data.size());
}
}

View File

@ -0,0 +1,81 @@
package org.atriasoft.esignal;
import java.util.Iterator;
import java.util.List;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import org.atriasoft.esignal.internal.ConnectedElementInterface;
import edu.umd.cs.findbugs.annotations.CheckReturnValue;
/**
* Simple interface to manage signal connection and disconnection with notification on connection change.
* @see Signal documentation
* <pre>{@code
* class EmiterSimple {
* public final ISignal<String> signalEvent = new ISignal<>();
* public EmiterSimple() {
* signalEvent.setCallBackNotification(this::onConnectionChange);
* }
* public void onConnectionChange(final int currentNumberConnection, final int deltaConnection) {
* LOGGER.info("Number of connection Change : {} dalta={}", currentNumberConnection, deltaConnection);
* }
* }
* }</pre>
*
* @param <T> Type of the signal
*
*/
public class ISignal<T> extends GenericSignalInstrumented<Consumer<T>, BiConsumer<Object, T>> {
@CheckReturnValue
@SuppressWarnings("unchecked")
public <V> Connection connect(final V object, final BiConsumer<V, T> function) {
return connect(object, (final Object obj, final T value) -> {
function.accept((V) obj, value);
});
}
/**
* Connect to the signal and automatically disconnect when the object is removed
* @param object Object to check if remove to continue keeping the signal active (Keep a WeakReference on it only)
* @param function Function to connect (Keep a WeakReference on it only)
*/
@SuppressWarnings("unchecked")
public <V> void connectAuto(final V object, final BiConsumer<V, T> function) {
connectAuto(object, (final Object obj, final T value) -> {
function.accept((V) obj, value);
});
}
/**
* Emit a signal on all element connect (and clean the list of unlinked elements).
* @param value Value to set in parameter.
*/
public void emit(final T value) {
final List<ConnectedElementInterface<Consumer<T>, BiConsumer<Object, T>>> tmp = getACleanedList();
if (tmp == null) {
return;
}
// real call elements
final Iterator<ConnectedElementInterface<Consumer<T>, BiConsumer<Object, T>>> iterator = tmp.iterator();
while (iterator.hasNext()) {
final ConnectedElementInterface<Consumer<T>, BiConsumer<Object, T>> elem = iterator.next();
final Object remoteLockObject = elem.lockObjects();
if (elem.isObjectDependent() && remoteLockObject == null) {
continue;
}
final Consumer<T> tmpConsumer = elem.getConsumer();
if (tmpConsumer != null) {
tmpConsumer.accept(value);
continue;
}
// Not a dead code, but very hard to simply test it.
final BiConsumer<Object, T> tmpConsumer2 = elem.getConsumer2();
if (tmpConsumer2 != null) {
tmpConsumer2.accept(elem.getObject(), value);
}
}
}
}

View File

@ -0,0 +1,78 @@
package org.atriasoft.esignal;
import java.util.Iterator;
import java.util.List;
import java.util.function.Consumer;
import org.atriasoft.esignal.internal.ConnectedElementInterface;
import edu.umd.cs.findbugs.annotations.CheckReturnValue;
/**
* Simple interface to manage signal connection and disconnection with notification on connection change.
* @see SignalEmpty documentation
* <pre>{@code
* class EmiterSimple {
* public final ISignalEmpty signalEvent = new ISignalEmpty();
* public EmiterSimple() {
* signalEvent.setCallBackNotification(this::onConnectionChange);
* }
* public void onConnectionChange(final int currentNumberConnection, final int deltaConnection) {
* LOGGER.info("Number of connection Change : {} delta={}", currentNumberConnection, deltaConnection);
* }
* }
* }</pre>
*
*/
public class ISignalEmpty extends GenericSignalInstrumented<Runnable, Consumer<Object>> {
@CheckReturnValue
@SuppressWarnings("unchecked")
public <V> Connection connect(final V object, final Consumer<V> function) {
return connect(object, (final Object obj) -> {
function.accept((V) obj);
});
}
/**
* Connect to the signal and automatically disconnect when the object is removed
* @param object Object to check if remove to continue keeping the signal active (Keep a WeakReference on it only)
* @param function Function to connect (Keep a WeakReference on it only)
*/
@SuppressWarnings("unchecked")
public <V> void connectAuto(final V object, final Consumer<V> function) {
connectAuto(object, (final Object obj) -> {
function.accept((V) obj);
});
}
/**
* Emit a signal on all element connect (and clean the list of unlinked elements).
*/
public void emit() {
final List<ConnectedElementInterface<Runnable, Consumer<Object>>> tmp = getACleanedList();
if (tmp == null) {
return;
}
// real call elements
final Iterator<ConnectedElementInterface<Runnable, Consumer<Object>>> iterator = tmp.iterator();
while (iterator.hasNext()) {
final ConnectedElementInterface<Runnable, Consumer<Object>> elem = iterator.next();
final Object remoteLockObject = elem.lockObjects();
if (elem.isObjectDependent() && remoteLockObject == null) {
continue;
}
final Runnable tmpConsumer = elem.getConsumer();
if (tmpConsumer != null) {
tmpConsumer.run();
continue;
}
// Not a dead code, but very hard to simply test it.
final Consumer<Object> tmpConsumer2 = elem.getConsumer2();
if (tmpConsumer2 != null) {
tmpConsumer2.accept(elem.getObject());
}
}
}
}

View File

@ -0,0 +1,107 @@
package org.atriasoft.esignal;
import java.util.Iterator;
import java.util.List;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import org.atriasoft.esignal.internal.ConnectedElementInterface;
import edu.umd.cs.findbugs.annotations.CheckReturnValue;
/**
* Simple interface to manage signal connection and disconnection
* <pre>{@code
* class EmiterSimple {
* public Signal<String> signalEvent = new Signal<>();
* }
*
* class ReceiverSimple {
* public void onEvent(String data) {
* LOGGER.error("function receive: {}", data);
* }
* public connectLambda(EmiterSimple other) {
* // Note : this lambda is reference a a global, then it will never removed in the connection list ==> refer the local class or @see connectAutoRemoveObject
* other.signalEvent.connect((data) -> {
* LOGGER.error("lambda receive: {}", data);
* });
* }
* }
* // use :
* EmiterSimple aaa = new EmiterSimple();
* ReceiverSimple bbb = new ReceiverSimple();
* // Emit a signal:
* aaa.signalEvent.emit("My message ...");
* // simple direct connection:
* aaa.signalEvent.connect(bbb::onEvent);
* //removable connection (2 possibilities:)
* // First solution (best way ==> does not need to lock a reference on the current object and the remote)
* {
* Connection connect = aaa.signalEvent.connectDynamic(bbb::onEvent());
* // disconnect
* connect.disconnect();
* }
* // Second solution
* {
* Consumer<?> connect = bbb::onEvent;
* aaa.signalEvent.connect(connect);
* // disconnect
* aaa.signalEvent.disconnect(connect);
* }
* }</pre>
*
* @param <T> Type of the signal
*
*/
public class Signal<T> extends GenericSignal<Consumer<T>, BiConsumer<Object, T>> {
@CheckReturnValue
@SuppressWarnings("unchecked")
public <V> Connection connect(final V object, final BiConsumer<V, T> function) {
return connect(object, (final Object obj, final T value) -> {
function.accept((V) obj, value);
});
}
/**
* Connect to the signal and automatically disconnect when the object is removed
* @param object Object to check if remove to continue keeping the signal active (Keep a WeakReference on it only)
* @param function Function to connect (Keep a WeakReference on it only)
*/
@SuppressWarnings("unchecked")
public <V> void connectAuto(final V object, final BiConsumer<V, T> function) {
connectAuto(object, (final Object obj, final T value) -> {
function.accept((V) obj, value);
});
}
/**
* Emit a signal on all element connect (and clean the list of unlinked elements).
* @param value Value to set in parameter.
*/
public void emit(final T value) {
final List<ConnectedElementInterface<Consumer<T>, BiConsumer<Object, T>>> tmp = getACleanedList();
if (tmp == null) {
return;
}
// real call elements
final Iterator<ConnectedElementInterface<Consumer<T>, BiConsumer<Object, T>>> iterator = tmp.iterator();
while (iterator.hasNext()) {
final ConnectedElementInterface<Consumer<T>, BiConsumer<Object, T>> elem = iterator.next();
final Object remoteLockObject = elem.lockObjects();
if (elem.isObjectDependent() && remoteLockObject == null) {
continue;
}
final Consumer<T> tmpConsumer = elem.getConsumer();
if (tmpConsumer != null) {
tmpConsumer.accept(value);
continue;
}
// Not a dead code, but very hard to simply test it.
final BiConsumer<Object, T> tmpConsumer2 = elem.getConsumer2();
if (tmpConsumer2 != null) {
tmpConsumer2.accept(elem.getObject(), value);
}
}
}
}

View File

@ -0,0 +1,106 @@
package org.atriasoft.esignal;
import java.util.Iterator;
import java.util.List;
import java.util.function.Consumer;
import org.atriasoft.esignal.internal.ConnectedElementInterface;
import edu.umd.cs.findbugs.annotations.CheckReturnValue;
/**
* Simple interface to manage signal connection and disconnection
* <pre>{@code
* class EmiterSimple {
* public SignalEmpty signalEvent = new SignalEmpty();
* }
*
* class ReceiverSimple {
* public void onEvent() {
* LOGGER.error("function receive event ...");
* }
* public connectLambda(EmiterSimple other) {
* // Note : this lambda is reference a a global, then it will never removed in the connection list ==> refer the local class or @see connectAutoRemoveObject
* other.signalEvent.connect(() -> {
* LOGGER.error("lambda receive event");
* });
* }
* }
* // use :
* EmiterSimple aaa = new EmiterSimple();
* ReceiverSimple bbb = new ReceiverSimple();
* // Emit a signal:
* aaa.signalEvent.emit();
* // simple direct connection:
* aaa.signalEvent.connect(bbb::onEvent);
* //removable connection (2 possibilities:)
* // First solution (best way ==> does not need to lock a reference on the current object and the remote)
* {
* Connection connect = aaa.signalEvent.connectDynamic(bbb::onEvent());
* // disconnect
* connect.disconnect();
* }
* // Second solution
* {
* Consumer<?> connect = bbb::onEvent;
* aaa.signalEvent.connect(connect);
* // disconnect
* aaa.signalEvent.disconnect(connect);
* }
* }</pre>
*
*/
public class SignalEmpty extends GenericSignal<Runnable, Consumer<Object>> {
/**
* Emit a signal on all element connect (and clean the list of unlinked elements).
*/
public void emit() {
List<ConnectedElementInterface<Runnable, Consumer<Object>>> tmp = getACleanedList();
if (tmp == null) {
return;
}
// real call elements
final Iterator<ConnectedElementInterface<Runnable, Consumer<Object>>> iterator = tmp.iterator();
while (iterator.hasNext()) {
final ConnectedElementInterface<Runnable, Consumer<Object>> elem = iterator.next();
Object remoteLockObject = elem.lockObjects();
if (elem.isObjectDependent() && remoteLockObject == null) {
continue;
}
Runnable tmpConsumer = elem.getConsumer();
if (tmpConsumer != null) {
tmpConsumer.run();
continue;
}
// Not a dead code, but very hard to simply test it.
Consumer<Object> tmpConsumer2 = elem.getConsumer2();
if (tmpConsumer2 != null) {
tmpConsumer2.accept(elem.getObject());
}
}
}
/**
* Connect to the signal and automatically disconnect when the object is removed
* @param object Object to check if remove to continue keeping the signal active (Keep a WeakReference on it only)
* @param function Function to connect (Keep a WeakReference on it only)
*/
@SuppressWarnings("unchecked")
public <V> void connectAuto(final V object, final Consumer<V> function) {
connectAuto(object,
(final Object obj) -> {
function.accept((V)obj);
});
}
@CheckReturnValue
@SuppressWarnings("unchecked")
public <V> Connection connect(final V object, final Consumer<V> function) {
return connect(object,
(final Object obj) -> {
function.accept((V)obj);
});
}
}

View File

@ -0,0 +1,26 @@
package org.atriasoft.esignal.internal;
/**
* Connected element on a consumer to Manage event
*
* @param <T> Type Of the Signal
*/
public interface ConnectedElementInterface<T, U> {
default T getConsumer() { return null; }
default boolean isObjectDependent() { return false; }
default U getConsumer2() { return null; }
/**
* Lock an Object that keep a reference on all object that need to be alive while the call is done
* @return An unusable Object (just keep a reference on it.
*/
default Object lockObjects() { return null; }
default Object getObject() { return null; }
boolean isCompatibleWith(final Object elem);
/**
* Permit to remove connection on the associated signal.
*/
default void disconnect() {}
}

View File

@ -0,0 +1,32 @@
package org.atriasoft.esignal.internal;
/**
* Connected element on a consumer to Manage event
*
* @param <T> Type Of the Signal
*/
public class ConnectedElementTRefConsumer<T, U> implements ConnectedElementInterface<T, U> {
protected final T consumer;
public ConnectedElementTRefConsumer(final T consumer) {
this.consumer = consumer;
}
@Override
public T getConsumer() {
return this.consumer;
}
@Override
public boolean isCompatibleWith(final Object elem) {
if (this.consumer == elem) {
return true;
}
return false;
}
@Override
public void disconnect() {
}
}

View File

@ -0,0 +1,49 @@
package org.atriasoft.esignal.internal;
import java.lang.ref.WeakReference;
import org.atriasoft.esignal.Connection;
/**
* Connected element with a dependency of an other object to auto remove the signals
*
* @param <T> Type Of the Signal
*/
public class ConnectedElementTRefConsumerWeakConnection<T, U> extends ConnectedElementTRefConsumer<T, U> {
protected final WeakReference<Connection> linkedConnection;
public ConnectedElementTRefConsumerWeakConnection(final Connection linkedConnection, final T consumer) {
super(consumer);
this.linkedConnection = new WeakReference<Connection>(linkedConnection);
}
@Override
public boolean isObjectDependent() {
return true;
}
@Override
public Object lockObjects() {
return this.linkedConnection.get();
}
@Override
public boolean isCompatibleWith(final Object elem) {
if (super.isCompatibleWith(elem)) {
return true;
}
Object obj = this.linkedConnection.get();
if (obj == elem) {
return true;
}
return false;
}
@Override
public void disconnect() {
Connection con = this.linkedConnection.get();
if (con != null) {
con.connectionIsRemovedBySignal();
}
}
}

View File

@ -0,0 +1,44 @@
package org.atriasoft.esignal.internal;
import java.lang.ref.WeakReference;
/**
* Connected element with a dependency of an other object to auto remove the signals
*
* @param <T> Type Of the Signal
*/
public class ConnectedElementTRefConsumerWeakObject<T, U> extends ConnectedElementTRefConsumer<T, U> {
protected final WeakReference<Object> linkedObject;
public ConnectedElementTRefConsumerWeakObject(final Object linkedObject, final T consumer) {
super(consumer);
this.linkedObject = new WeakReference<Object>(linkedObject);
}
@Override
public boolean isObjectDependent() {
return true;
}
@Override
public Object lockObjects() {
return this.linkedObject.get();
}
@Override
public Object getObject() {
return this.linkedObject.get();
}
@Override
public boolean isCompatibleWith(final Object elem) {
if (super.isCompatibleWith(elem)) {
return true;
}
Object obj = this.linkedObject.get();
if (obj == elem) {
return true;
}
return false;
}
}

View File

@ -0,0 +1,35 @@
package org.atriasoft.esignal.internal;
import java.lang.ref.WeakReference;
/**
* Connected element on a consumer to Manage event
*
* @param <T> Type Of the Signal
*/
public class ConnectedElementTWeakConsumer<T, U> implements ConnectedElementInterface<T, U> {
protected final WeakReference<T> consumer;
public ConnectedElementTWeakConsumer(final T consumer) {
this.consumer = new WeakReference<T>(consumer);
}
@Override
public T getConsumer() {
return this.consumer.get();
}
@Override
public boolean isCompatibleWith(final Object elem) {
Object out = this.consumer.get();
if (out == elem) {
return true;
}
return false;
}
@Override
public void disconnect() {
}
}

View File

@ -0,0 +1,51 @@
package org.atriasoft.esignal.internal;
import java.lang.ref.WeakReference;
/**
* Connected element on a consumer to Manage event
*
* @param <T> Type Of the Signal
* @param <U> Second type Of the Signal
*/
public class ConnectedElementURefConsumerWeakObject<T, U> implements ConnectedElementInterface<T, U> {
protected final U consumer;
protected final WeakReference<Object> linkedObject;
public ConnectedElementURefConsumerWeakObject(final Object linkedObject, final U consumer) {
this.consumer = consumer;
this.linkedObject = new WeakReference<Object>(linkedObject);
}
@Override
public boolean isObjectDependent() {
return true;
}
@Override
public U getConsumer2() {
return this.consumer;
}
@Override
public Object lockObjects() {
return this.linkedObject.get();
}
@Override
public Object getObject() {
return this.linkedObject.get();
}
@Override
public boolean isCompatibleWith(final Object elem) {
Object out = this.consumer;
if (out == elem) {
return true;
}
Object obj = this.linkedObject.get();
if (obj == elem) {
return true;
}
return false;
}
}

View File

@ -0,0 +1,51 @@
package org.atriasoft.esignal.internal;
import java.lang.ref.WeakReference;
import org.atriasoft.esignal.Connection;
record LockObject(Object aaa, Object bbb) {};
/**
* Connected element on a consumer to Manage event
*
* @param <T> Type Of the Signal
* @param <U> Second type Of the Signal
*/
public class ConnectedElementURefConsumerWeakObjectWeakConnection<T, U> extends ConnectedElementURefConsumerWeakObject<T, U> {
protected final WeakReference<Connection> linkedConnection;
public ConnectedElementURefConsumerWeakObjectWeakConnection(final Connection linkedConnection, final Object linkedObject, final U consumer) {
super(linkedObject, consumer);
this.linkedConnection = new WeakReference<Connection>(linkedConnection);
}
@Override
public Object lockObjects() {
Object tmp1 = this.linkedObject.get();
Object tmp2 = this.linkedConnection.get();
if (tmp1 != null && tmp2 != null) {
return new LockObject(tmp1, tmp2);
}
return null;
}
@Override
public boolean isCompatibleWith(final Object elem) {
if (super.isCompatibleWith(elem)) {
return true;
}
if (this.linkedConnection.get() == elem) {
return true;
}
return false;
}
@Override
public void disconnect() {
Connection con = this.linkedConnection.get();
if (con != null) {
con.connectionIsRemovedBySignal();
}
}
}

View File

@ -0,0 +1,657 @@
/*******************************************************************************
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* Contributors:
* Edouard DUPIN - initial API and implementation
******************************************************************************/
package test.atriasoft.esignal;
import java.lang.ref.WeakReference;
import java.util.function.Consumer;
import org.atriasoft.esignal.Connection;
import org.atriasoft.esignal.ISignal;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
//import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@TestMethodOrder(OrderAnnotation.class)
public class TestISignal {
static final Logger LOGGER = LoggerFactory.getLogger(TestISignal.class);
class EmiterSimple {
public ISignal<String> signalEvent = new ISignal<>();
public int currentNumberConnection = 0;
public int deltaConnection = 0;
public EmiterSimple() {
this.signalEvent.setCallBackNotification(this::onConnectionChange);
}
public void onConnectionChange(final int currentNumberConnection, final int deltaConnection) {
LOGGER.info(">>>>> Number of connection Change : " + currentNumberConnection + " delta=" + deltaConnection);
this.currentNumberConnection = currentNumberConnection;
this.deltaConnection = deltaConnection;
}
public void sendEvent(final String value) {
this.signalEvent.emit(value);
}
}
static class ReceiverSimple implements AutoCloseable {
private String dataReceive = null;
ReceiverSimple() {}
// record consumer
private Consumer<String> tmpConsumer1 = null;
private Connection tmpConnect = null;
@Override
public void close() {
this.tmpConsumer1 = null;
if (this.tmpConnect != null) {
this.tmpConnect.close();
this.tmpConnect = null;
}
this.dataReceive = null;
}
public void disconnectConnection() {
this.tmpConnect.close();
}
public boolean isConnected() {
return this.tmpConnect.isConnected();
}
public void connect1(final EmiterSimple other) {
final WeakReference<ReceiverSimple> self = new WeakReference<>(this);
this.tmpConnect = other.signalEvent.connect(data -> {
self.get().onData(data);
});
System.gc();
}
public void connect2(final EmiterSimple other) {
// the solo lambda will not depend on the object => the remove must be done manually...
this.tmpConnect = other.signalEvent.connect(data -> {
LOGGER.error("lambda receive: " + data);
});
System.gc();
}
public void connect3(final EmiterSimple other) {
// we reference the local object, then the lambda is alive while the object is alive...
this.tmpConnect = other.signalEvent.connect(data -> {
LOGGER.error("lambda receive: " + data);
this.dataReceive = data;
});
System.gc();
}
public void connect4(final EmiterSimple other) {
this.tmpConnect = other.signalEvent.connect(data -> {
onData(data);
});
System.gc();
}
public void connect5(final EmiterSimple other) {
this.tmpConsumer1 = this::onData;
other.signalEvent.connectWeak(this.tmpConsumer1);
System.gc();
}
public void disconnectConsumer1(final EmiterSimple other) {
other.signalEvent.disconnect(this.tmpConsumer1);
this.tmpConsumer1 = null;
}
public void connect6(final EmiterSimple other) {
// the solo lambda will not depend on the object => the remove must be done manually...
other.signalEvent.connectAutoRemoveObject(this, data -> {
LOGGER.error("lambda receive: " + data);
});
System.gc();
}
public void connect7(final EmiterSimple other) {
this.tmpConnect = other.signalEvent.connect(this::onData);
System.gc();
}
public void disconnect7(final EmiterSimple other) {
other.signalEvent.disconnect(this.tmpConnect);
}
public void onData(final String data) {
LOGGER.error("Retrive data : " + data);
this.dataReceive = data;
}
public void connect8(final EmiterSimple other) {
this.tmpConnect = other.signalEvent.connect(this, ReceiverSimple::onDataStatic);
System.gc();
}
public void connect9(final EmiterSimple other) {
other.signalEvent.connectAuto(this, ReceiverSimple::onDataStatic);
System.gc();
}
public static void onDataStatic(final Object local, final String data) {
final ReceiverSimple self = (ReceiverSimple) local;
LOGGER.error("Retrive data : " + data);
self.dataReceive = data;
}
public void connect10(final EmiterSimple other) {
this.tmpConnect = other.signalEvent.connect(this, ReceiverSimple::onDataStatic2);
System.gc();
}
public void connect11(final EmiterSimple other) {
other.signalEvent.connectAuto(this, ReceiverSimple::onDataStatic2);
System.gc();
}
public static void onDataStatic2(final ReceiverSimple self, final String data) {
LOGGER.error("Retrive data : " + data);
self.dataReceive = data;
}
public void connect12(final EmiterSimple other) {
this.tmpConnect = other.signalEvent.connect(this, (final ReceiverSimple self, final String data) -> {
LOGGER.error("Retrive data : " + data);
self.dataReceive = data;
});
System.gc();
}
public void connect13(final EmiterSimple other) {
other.signalEvent.connectAuto(this, (final ReceiverSimple self, final String data) -> {
LOGGER.error("Retrive data : " + data);
self.dataReceive = data;
});
System.gc();
}
public String getDataAndClean() {
final String tmp = this.dataReceive;
this.dataReceive = null;
return tmp;
}
}
@Test
@Order(1)
public void testConnectAndTransmit1() {
LOGGER.warn("Test 1 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
receiver.connect1(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
Assertions.assertEquals(1, sender.currentNumberConnection);
Assertions.assertEquals(1, sender.deltaConnection);
final String testData1 = "MUST receive this data...";
sender.sendEvent(testData1);
Assertions.assertEquals(testData1, receiver.getDataAndClean());
receiver = null;
Assertions.assertEquals(1, sender.signalEvent.size());
System.gc();
final String testData2 = "MUST NOT receive this data...";
sender.sendEvent(testData2);
Assertions.assertEquals(0, sender.signalEvent.size());
Assertions.assertEquals(0, sender.currentNumberConnection);
Assertions.assertEquals(-1, sender.deltaConnection);
LOGGER.warn("Test 1 [ END ]");
}
@Test
@Order(2)
public void testConnectAndTransmit2() {
LOGGER.warn("Test 2 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
receiver.connect2(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
Assertions.assertEquals(1, sender.currentNumberConnection);
Assertions.assertEquals(1, sender.deltaConnection);
final String testData1 = "MUST receive this data...";
sender.sendEvent(testData1);
// No data stored ... assertEquals(testData1, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
// !!!! NO need to close lambda does not capture the THIS
receiver = null;
System.gc();
final String testData2 = "Solo Lambda MUST receive this data...";
sender.sendEvent(testData2);
Assertions.assertEquals(0, sender.signalEvent.size());
Assertions.assertEquals(0, sender.currentNumberConnection);
Assertions.assertEquals(-1, sender.deltaConnection);
LOGGER.warn("Test 2 [ END ]");
}
@Test
@Order(3)
public void testConnectAndTransmit3() {
LOGGER.warn("Test 3 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
receiver.connect3(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
Assertions.assertEquals(1, sender.currentNumberConnection);
Assertions.assertEquals(1, sender.deltaConnection);
final String testData1 = "MUST receive this data...";
sender.sendEvent(testData1);
Assertions.assertEquals(testData1, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
Assertions.assertEquals(1, sender.currentNumberConnection);
Assertions.assertEquals(1, sender.deltaConnection);
// Need to close ==> capture Of this
receiver.close();
receiver = null;
System.gc();
final String testData2 = "MUST NOT receive this data...";
sender.sendEvent(testData2);
Assertions.assertEquals(0, sender.signalEvent.size());
Assertions.assertEquals(0, sender.currentNumberConnection);
Assertions.assertEquals(-1, sender.deltaConnection);
LOGGER.warn("Test 3 [ END ]");
}
@Test
@Order(4)
public void testConnectAndTransmit4() {
LOGGER.warn("Test 4 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
receiver.connect4(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
final String testData1 = "MUST receive this data...";
sender.sendEvent(testData1);
Assertions.assertEquals(testData1, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
// Need to close ==> capture Of this
receiver.close();
receiver = null;
System.gc();
final String testData2 = "MUST NOT receive this data...";
sender.sendEvent(testData2);
Assertions.assertEquals(0, sender.signalEvent.size());
LOGGER.warn("Test 4 [ END ]");
}
@Test
@Order(5)
public void testConnectAndTransmit5() {
LOGGER.warn("Test 5 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
//connect step 1
receiver.connect5(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
final String testData1 = "MUST receive this data... 111";
sender.sendEvent(testData1);
Assertions.assertEquals(testData1, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
// remove connection
receiver.disconnectConsumer1(sender);
Assertions.assertEquals(0, sender.signalEvent.size());
System.gc();
final String testData2 = "MUST NOT receive this data... 222";
sender.sendEvent(testData2);
Assertions.assertEquals(null, receiver.getDataAndClean());
// reconnect (step 2
receiver.connect5(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
final String testData3 = "MUST receive this data... 333";
sender.sendEvent(testData3);
Assertions.assertEquals(testData3, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
// No need to close ==> the capture seams does not increase the cumber of Reference ....
// check auto remove...
receiver = null;
System.gc();
final String testData4 = "MUST NOT receive this data... 444";
sender.sendEvent(testData4);
Assertions.assertEquals(0, sender.signalEvent.size());
LOGGER.warn("Test 5 [ END ]");
}
@Test
@Order(6)
public void testConnectAndTransmit6() {
LOGGER.warn("Test 6 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
receiver.connect6(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
final String testData1 = "MUST receive this data...";
sender.sendEvent(testData1);
//assertEquals(testData1, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
receiver = null;
System.gc();
final String testData2 = "MUST NOT receive this data...";
sender.sendEvent(testData2);
Assertions.assertEquals(0, sender.signalEvent.size());
LOGGER.warn("Test 6 [ END ]");
}
@Test
@Order(7)
public void testConnectAndTransmit7() {
LOGGER.warn("Test 7 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
//connect step 1
receiver.connect7(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
final String testData1 = "MUST receive this data... 111";
sender.sendEvent(testData1);
Assertions.assertEquals(testData1, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
Assertions.assertEquals(true, receiver.isConnected());
// remove connection
receiver.disconnect7(sender);
Assertions.assertEquals(false, receiver.isConnected());
System.gc();
final String testData2 = "MUST NOT receive this data... 222";
sender.sendEvent(testData2);
Assertions.assertEquals(0, sender.signalEvent.size());
Assertions.assertEquals(null, receiver.getDataAndClean());
// reconnect (step 2
receiver.connect7(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
final String testData3 = "MUST receive this data... 333";
sender.sendEvent(testData3);
Assertions.assertEquals(testData3, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
Assertions.assertEquals(true, receiver.isConnected());
// remove connection
receiver.disconnectConnection();
Assertions.assertEquals(false, receiver.isConnected());
Assertions.assertEquals(0, sender.signalEvent.size());
System.gc();
final String testData4 = "MUST NOT receive this data... 444";
sender.sendEvent(testData4);
Assertions.assertEquals(null, receiver.getDataAndClean());
// reconnect (step 2
receiver.connect7(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
final String testData5 = "MUST receive this data... 555";
sender.sendEvent(testData5);
Assertions.assertEquals(testData5, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
// Need to close to prevent miss removing of connection.
receiver.close();
// check auto remove...
receiver = null;
System.gc();
final String testData6 = "MUST NOT receive this data... 666";
sender.sendEvent(testData6);
Assertions.assertEquals(0, sender.signalEvent.size());
LOGGER.warn("Test 7 [ END ]");
}
@Test
@Order(8)
public void testConnectAndTransmit8() {
LOGGER.warn("Test 8 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
//connect step 1
receiver.connect8(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
final String testData1 = "MUST receive this data... 111";
sender.sendEvent(testData1);
Assertions.assertEquals(testData1, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
Assertions.assertEquals(true, receiver.isConnected());
// remove connection
receiver.disconnectConnection();
Assertions.assertEquals(false, receiver.isConnected());
System.gc();
final String testData2 = "MUST NOT receive this data... 222";
sender.sendEvent(testData2);
Assertions.assertEquals(0, sender.signalEvent.size());
Assertions.assertEquals(null, receiver.getDataAndClean());
// reconnect (step 2
receiver.connect8(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
final String testData3 = "MUST receive this data... 333";
sender.sendEvent(testData3);
Assertions.assertEquals(testData3, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
Assertions.assertEquals(true, receiver.isConnected());
// remove connection
receiver.disconnectConnection();
Assertions.assertEquals(false, receiver.isConnected());
Assertions.assertEquals(0, sender.signalEvent.size());
System.gc();
final String testData4 = "MUST NOT receive this data... 444";
sender.sendEvent(testData4);
Assertions.assertEquals(null, receiver.getDataAndClean());
// reconnect (step 2
receiver.connect8(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
final String testData5 = "MUST receive this data... 555";
sender.sendEvent(testData5);
Assertions.assertEquals(testData5, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
// check auto remove...
receiver = null;
System.gc();
final String testData6 = "MUST NOT receive this data... 666";
sender.sendEvent(testData6);
Assertions.assertEquals(0, sender.signalEvent.size());
LOGGER.warn("Test 8 [ END ]");
}
@Test
@Order(9)
public void testConnectAndTransmit9() {
LOGGER.warn("Test 9 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
//connect step 1
receiver.connect9(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
final String testData1 = "MUST receive this data... 111";
sender.sendEvent(testData1);
Assertions.assertEquals(testData1, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
// remove connection (check auto remove)...
receiver = null;
System.gc();
final String testData6 = "MUST NOT receive this data... 666";
sender.sendEvent(testData6);
Assertions.assertEquals(0, sender.signalEvent.size());
LOGGER.warn("Test 9 [ END ]");
}
@Test
@Order(10)
public void testConnectAndTransmit10() {
LOGGER.warn("Test 10 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
//connect step 1
receiver.connect10(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
final String testData1 = "MUST receive this data... 111";
sender.sendEvent(testData1);
Assertions.assertEquals(testData1, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
Assertions.assertEquals(true, receiver.isConnected());
// remove connection
receiver.disconnectConnection();
Assertions.assertEquals(false, receiver.isConnected());
System.gc();
final String testData2 = "MUST NOT receive this data... 222";
sender.sendEvent(testData2);
Assertions.assertEquals(0, sender.signalEvent.size());
Assertions.assertEquals(null, receiver.getDataAndClean());
// reconnect (step 2
receiver.connect10(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
final String testData3 = "MUST receive this data... 333";
sender.sendEvent(testData3);
Assertions.assertEquals(testData3, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
Assertions.assertEquals(true, receiver.isConnected());
// remove connection
receiver.disconnectConnection();
Assertions.assertEquals(false, receiver.isConnected());
Assertions.assertEquals(0, sender.signalEvent.size());
System.gc();
final String testData4 = "MUST NOT receive this data... 444";
sender.sendEvent(testData4);
Assertions.assertEquals(null, receiver.getDataAndClean());
// reconnect (step 2
receiver.connect10(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
final String testData5 = "MUST receive this data... 555";
sender.sendEvent(testData5);
Assertions.assertEquals(testData5, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
// check auto remove...
receiver = null;
System.gc();
final String testData6 = "MUST NOT receive this data... 666";
sender.sendEvent(testData6);
Assertions.assertEquals(0, sender.signalEvent.size());
LOGGER.warn("Test 10 [ END ]");
}
@Test
@Order(11)
public void testConnectAndTransmit11() {
LOGGER.warn("Test 11 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
//connect step 1
receiver.connect11(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
final String testData1 = "MUST receive this data... 111";
sender.sendEvent(testData1);
Assertions.assertEquals(testData1, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
// remove connection (check auto remove)...
receiver = null;
System.gc();
final String testData6 = "MUST NOT receive this data... 666";
sender.sendEvent(testData6);
Assertions.assertEquals(0, sender.signalEvent.size());
LOGGER.warn("Test 11 [ END ]");
}
@Test
@Order(12)
public void testConnectAndTransmit12() {
LOGGER.warn("Test 12 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
//connect step 1
receiver.connect12(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
final String testData1 = "MUST receive this data... 111";
sender.sendEvent(testData1);
Assertions.assertEquals(testData1, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
Assertions.assertEquals(true, receiver.isConnected());
// remove connection
receiver.disconnectConnection();
Assertions.assertEquals(false, receiver.isConnected());
System.gc();
final String testData2 = "MUST NOT receive this data... 222";
sender.sendEvent(testData2);
Assertions.assertEquals(0, sender.signalEvent.size());
Assertions.assertEquals(null, receiver.getDataAndClean());
// reconnect (step 2
receiver.connect12(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
final String testData3 = "MUST receive this data... 333";
sender.sendEvent(testData3);
Assertions.assertEquals(testData3, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
Assertions.assertEquals(true, receiver.isConnected());
// remove connection
receiver.disconnectConnection();
Assertions.assertEquals(false, receiver.isConnected());
Assertions.assertEquals(0, sender.signalEvent.size());
System.gc();
final String testData4 = "MUST NOT receive this data... 444";
sender.sendEvent(testData4);
Assertions.assertEquals(null, receiver.getDataAndClean());
// reconnect (step 2
receiver.connect12(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
final String testData5 = "MUST receive this data... 555";
sender.sendEvent(testData5);
Assertions.assertEquals(testData5, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
// check auto remove...
receiver = null;
System.gc();
final String testData6 = "MUST NOT receive this data... 666";
sender.sendEvent(testData6);
Assertions.assertEquals(0, sender.signalEvent.size());
LOGGER.warn("Test 12 [ END ]");
}
@Test
@Order(13)
public void testConnectAndTransmit13() {
LOGGER.warn("Test 13 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
//connect step 1
receiver.connect13(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
final String testData1 = "MUST receive this data... 131";
sender.sendEvent(testData1);
Assertions.assertEquals(testData1, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
// remove connection (check auto remove)...
receiver = null;
System.gc();
final String testData6 = "MUST NOT receive this data... 666";
sender.sendEvent(testData6);
Assertions.assertEquals(0, sender.signalEvent.size());
LOGGER.warn("Test 13 [ END ]");
}
@Test
public void testClearConnection() {
final EmiterSimple sender = new EmiterSimple();
final ReceiverSimple receiver = new ReceiverSimple();
//connect step 1
receiver.connect7(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
sender.signalEvent.clear();
}
}

View File

@ -0,0 +1,691 @@
/*******************************************************************************
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* Contributors:
* Edouard DUPIN - initial API and implementation
******************************************************************************/
package test.atriasoft.esignal;
import java.lang.ref.WeakReference;
import org.atriasoft.esignal.Connection;
import org.atriasoft.esignal.ISignalEmpty;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
//import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@TestMethodOrder(OrderAnnotation.class)
public class TestISignalEmpty {
static final Logger LOGGER = LoggerFactory.getLogger(TestISignalEmpty.class);
class EmiterSimple {
public ISignalEmpty signalEvent = new ISignalEmpty();
public int currentNumberConnection = 0;
public int deltaConnection = 0;
public EmiterSimple() {
this.signalEvent.setCallBackNotification(this::onConnectionChange);
}
public void onConnectionChange(final int currentNumberConnection, final int deltaConnection) {
LOGGER.info(">>>>> Number of connection Change : " + currentNumberConnection + " delta=" + deltaConnection);
this.currentNumberConnection = currentNumberConnection;
this.deltaConnection = deltaConnection;
}
public void sendEvent() {
this.signalEvent.emit();
}
}
static class ReceiverSimple implements AutoCloseable {
private boolean dataReceive = false;
ReceiverSimple() {}
// record consumer
private Runnable tmpConsumer1 = null;
private Connection tmpConnect = null;
@Override
public void close() {
this.tmpConsumer1 = null;
if (this.tmpConnect != null) {
this.tmpConnect.close();
this.tmpConnect = null;
}
this.dataReceive = false;
}
public void disconnectConnection() {
this.tmpConnect.close();
}
public boolean isConnected() {
return this.tmpConnect.isConnected();
}
public void connect1(final EmiterSimple other) {
final WeakReference<ReceiverSimple> self = new WeakReference<>(this);
this.tmpConnect = other.signalEvent.connect(() -> {
self.get().onData();
});
System.gc();
}
public void connect2(final EmiterSimple other) {
// the solo lambda will not depend on the object => the remove must be done manually...
this.tmpConnect = other.signalEvent.connect(() -> {
LOGGER.error("lambda receive: ");
});
System.gc();
}
public void connect3(final EmiterSimple other) {
// we reference the local object, then the lambda is alive while the object is alive...
this.tmpConnect = other.signalEvent.connect(() -> {
LOGGER.error("lambda receive: ");
this.dataReceive = true;
});
System.gc();
}
public void connect4(final EmiterSimple other) {
this.tmpConnect = other.signalEvent.connect(() -> {
onData();
});
System.gc();
}
public void connect5(final EmiterSimple other) {
this.tmpConsumer1 = this::onData;
other.signalEvent.connectWeak(this.tmpConsumer1);
System.gc();
}
public void disconnectConsumer1(final EmiterSimple other) {
other.signalEvent.disconnect(this.tmpConsumer1);
this.tmpConsumer1 = null;
}
public void connect6(final EmiterSimple other) {
// the solo lambda will not depend on the object => the remove must be done manually...
other.signalEvent.connectAutoRemoveObject(this, () -> {
LOGGER.error("lambda receive: ");
});
System.gc();
}
public void connect7(final EmiterSimple other) {
this.tmpConnect = other.signalEvent.connect(this::onData);
System.gc();
}
public void disconnect7(final EmiterSimple other) {
other.signalEvent.disconnect(this.tmpConnect);
}
public void onData() {
LOGGER.error("Retrive data : ");
this.dataReceive = true;
}
public void connect8(final EmiterSimple other) {
this.tmpConnect = other.signalEvent.connect(this, ReceiverSimple::onDataStatic);
System.gc();
}
public void connect9(final EmiterSimple other) {
other.signalEvent.connectAuto(this, ReceiverSimple::onDataStatic);
System.gc();
}
public static void onDataStatic(final Object local) {
final ReceiverSimple self = (ReceiverSimple) local;
LOGGER.error("Retrive data : ");
self.dataReceive = true;
}
public void connect10(final EmiterSimple other) {
this.tmpConnect = other.signalEvent.connect(this, ReceiverSimple::onDataStatic2);
System.gc();
}
public void connect11(final EmiterSimple other) {
other.signalEvent.connectAuto(this, ReceiverSimple::onDataStatic2);
System.gc();
}
public static void onDataStatic2(final ReceiverSimple self) {
LOGGER.error("Retrive data : ");
self.dataReceive = true;
}
public void connect12(final EmiterSimple other) {
this.tmpConnect = other.signalEvent.connect(this, (final ReceiverSimple self) -> {
LOGGER.error("Retrive data : ");
self.dataReceive = true;
});
System.gc();
}
public void connect13(final EmiterSimple other) {
other.signalEvent.connectAuto(this, (final ReceiverSimple self) -> {
LOGGER.error("Retrive data : ");
self.dataReceive = true;
});
System.gc();
}
public boolean getDataAndClean() {
final boolean tmp = this.dataReceive;
this.dataReceive = false;
return tmp;
}
}
@Test
@Order(1)
public void testConnectAndTransmit1() {
LOGGER.warn("Test 1 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
receiver.connect1(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
sender.sendEvent();
Assertions.assertEquals(true, receiver.getDataAndClean());
receiver = null;
Assertions.assertEquals(1, sender.signalEvent.size());
System.gc();
sender.sendEvent();
Assertions.assertEquals(0, sender.signalEvent.size());
LOGGER.warn("Test 1 [ END ]");
}
@Test
@Order(2)
public void testConnectAndTransmit2() {
LOGGER.warn("Test 2 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
receiver.connect2(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
sender.sendEvent();
// No data stored ... assertEquals(true, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
// !!!! NO need to close lambda does not capture the THIS
receiver = null;
System.gc();
sender.sendEvent();
Assertions.assertEquals(0, sender.signalEvent.size());
LOGGER.warn("Test 2 [ END ]");
}
@Test
@Order(3)
public void testConnectAndTransmit3() {
LOGGER.warn("Test 3 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
receiver.connect3(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
Assertions.assertEquals(1, sender.currentNumberConnection);
Assertions.assertEquals(1, sender.deltaConnection);
sender.sendEvent();
Assertions.assertEquals(true, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
// Need to close ==> capture Of this
receiver.close();
receiver = null;
System.gc();
Assertions.assertEquals(0, sender.currentNumberConnection);
Assertions.assertEquals(-1, sender.deltaConnection);
sender.sendEvent();
Assertions.assertEquals(0, sender.signalEvent.size());
LOGGER.warn("Test 3 [ END ]");
}
@Test
@Order(4)
public void testConnectAndTransmit4() {
LOGGER.warn("Test 4 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
receiver.connect4(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
Assertions.assertEquals(1, sender.currentNumberConnection);
Assertions.assertEquals(1, sender.deltaConnection);
sender.sendEvent();
Assertions.assertEquals(true, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
// Need to close ==> capture Of this
receiver.close();
receiver = null;
System.gc();
Assertions.assertEquals(0, sender.currentNumberConnection);
Assertions.assertEquals(-1, sender.deltaConnection);
sender.sendEvent();
Assertions.assertEquals(0, sender.signalEvent.size());
LOGGER.warn("Test 4 [ END ]");
}
@Test
@Order(5)
public void testConnectAndTransmit5() {
LOGGER.warn("Test 5 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
//connect step 1
receiver.connect5(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
Assertions.assertEquals(1, sender.currentNumberConnection);
Assertions.assertEquals(1, sender.deltaConnection);
sender.sendEvent();
Assertions.assertEquals(true, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
// remove connection
receiver.disconnectConsumer1(sender);
Assertions.assertEquals(0, sender.signalEvent.size());
System.gc();
sender.sendEvent();
Assertions.assertEquals(false, receiver.getDataAndClean());
// reconnect (step 2
receiver.connect5(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
sender.sendEvent();
Assertions.assertEquals(true, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
// No need to close ==> the capture seams does not increase the cumber of Reference ....
// check auto remove...
receiver = null;
System.gc();
Assertions.assertEquals(1, sender.currentNumberConnection);
Assertions.assertEquals(1, sender.deltaConnection);
sender.sendEvent();
Assertions.assertEquals(0, sender.currentNumberConnection);
Assertions.assertEquals(-1, sender.deltaConnection);
Assertions.assertEquals(0, sender.signalEvent.size());
LOGGER.warn("Test 5 [ END ]");
}
@Test
@Order(6)
public void testConnectAndTransmit6() {
LOGGER.warn("Test 6 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
receiver.connect6(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
sender.sendEvent();
//assertEquals(true, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
receiver = null;
System.gc();
sender.sendEvent();
Assertions.assertEquals(0, sender.signalEvent.size());
LOGGER.warn("Test 6 [ END ]");
}
@Test
@Order(7)
public void testConnectAndTransmit7() {
LOGGER.warn("Test 7 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
//connect step 1
receiver.connect7(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
sender.sendEvent();
Assertions.assertEquals(true, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
Assertions.assertEquals(true, receiver.isConnected());
// remove connection
receiver.disconnect7(sender);
Assertions.assertEquals(false, receiver.isConnected());
System.gc();
sender.sendEvent();
Assertions.assertEquals(0, sender.signalEvent.size());
Assertions.assertEquals(false, receiver.getDataAndClean());
// reconnect (step 2
receiver.connect7(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
sender.sendEvent();
Assertions.assertEquals(true, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
Assertions.assertEquals(true, receiver.isConnected());
// remove connection
receiver.disconnectConnection();
Assertions.assertEquals(false, receiver.isConnected());
Assertions.assertEquals(0, sender.signalEvent.size());
System.gc();
sender.sendEvent();
Assertions.assertEquals(false, receiver.getDataAndClean());
// reconnect (step 2
receiver.connect7(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
sender.sendEvent();
Assertions.assertEquals(true, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
// Need to close to prevent miss removing of connection.
receiver.close();
// check auto remove...
receiver = null;
System.gc();
sender.sendEvent();
Assertions.assertEquals(0, sender.signalEvent.size());
LOGGER.warn("Test 7 [ END ]");
}
@Test
@Order(8)
public void testConnectAndTransmit8() {
LOGGER.warn("Test 8 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
//connect step 1
receiver.connect8(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
sender.sendEvent();
Assertions.assertEquals(true, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
Assertions.assertEquals(true, receiver.isConnected());
// remove connection
receiver.disconnectConnection();
Assertions.assertEquals(false, receiver.isConnected());
System.gc();
sender.sendEvent();
Assertions.assertEquals(0, sender.signalEvent.size());
Assertions.assertEquals(false, receiver.getDataAndClean());
// reconnect (step 2
receiver.connect8(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
sender.sendEvent();
Assertions.assertEquals(true, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
Assertions.assertEquals(true, receiver.isConnected());
// remove connection
receiver.disconnectConnection();
Assertions.assertEquals(false, receiver.isConnected());
Assertions.assertEquals(0, sender.signalEvent.size());
System.gc();
sender.sendEvent();
Assertions.assertEquals(false, receiver.getDataAndClean());
// reconnect (step 2
receiver.connect8(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
sender.sendEvent();
Assertions.assertEquals(true, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
// check auto remove...
receiver = null;
System.gc();
sender.sendEvent();
Assertions.assertEquals(0, sender.signalEvent.size());
LOGGER.warn("Test 8 [ END ]");
}
@Test
@Order(9)
public void testConnectAndTransmit9() {
LOGGER.warn("Test 9 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
//connect step 1
receiver.connect9(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
sender.sendEvent();
Assertions.assertEquals(true, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
// remove connection (check auto remove)...
receiver = null;
System.gc();
sender.sendEvent();
Assertions.assertEquals(0, sender.signalEvent.size());
LOGGER.warn("Test 9 [ END ]");
}
@Test
@Order(10)
public void testConnectAndTransmit10() {
LOGGER.warn("Test 10 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
//connect step 1
receiver.connect10(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
sender.sendEvent();
Assertions.assertEquals(true, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
Assertions.assertEquals(true, receiver.isConnected());
// remove connection
receiver.disconnectConnection();
Assertions.assertEquals(false, receiver.isConnected());
System.gc();
sender.sendEvent();
Assertions.assertEquals(0, sender.signalEvent.size());
Assertions.assertEquals(false, receiver.getDataAndClean());
// reconnect (step 2
receiver.connect10(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
sender.sendEvent();
Assertions.assertEquals(true, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
Assertions.assertEquals(true, receiver.isConnected());
// remove connection
receiver.disconnectConnection();
Assertions.assertEquals(false, receiver.isConnected());
Assertions.assertEquals(0, sender.signalEvent.size());
System.gc();
sender.sendEvent();
Assertions.assertEquals(false, receiver.getDataAndClean());
// reconnect (step 2
receiver.connect10(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
sender.sendEvent();
Assertions.assertEquals(true, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
// check auto remove...
receiver = null;
System.gc();
sender.sendEvent();
Assertions.assertEquals(0, sender.signalEvent.size());
LOGGER.warn("Test 10 [ END ]");
}
@Test
@Order(11)
public void testConnectAndTransmit11() {
LOGGER.warn("Test 11 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
//connect step 1
receiver.connect11(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
sender.sendEvent();
Assertions.assertEquals(true, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
// remove connection (check auto remove)...
receiver = null;
System.gc();
sender.sendEvent();
Assertions.assertEquals(0, sender.signalEvent.size());
LOGGER.warn("Test 11 [ END ]");
}
@Test
@Order(12)
public void testConnectAndTransmit12() {
LOGGER.warn("Test 12 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
//connect step 1
receiver.connect12(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
sender.sendEvent();
Assertions.assertEquals(true, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
Assertions.assertEquals(true, receiver.isConnected());
// remove connection
receiver.disconnectConnection();
Assertions.assertEquals(false, receiver.isConnected());
System.gc();
sender.sendEvent();
Assertions.assertEquals(0, sender.signalEvent.size());
Assertions.assertEquals(false, receiver.getDataAndClean());
// reconnect (step 2
receiver.connect12(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
sender.sendEvent();
Assertions.assertEquals(true, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
Assertions.assertEquals(true, receiver.isConnected());
// remove connection
receiver.disconnectConnection();
Assertions.assertEquals(false, receiver.isConnected());
Assertions.assertEquals(0, sender.signalEvent.size());
System.gc();
sender.sendEvent();
Assertions.assertEquals(false, receiver.getDataAndClean());
// reconnect (step 2
receiver.connect12(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
sender.sendEvent();
Assertions.assertEquals(true, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
// check auto remove...
receiver = null;
System.gc();
sender.sendEvent();
Assertions.assertEquals(0, sender.signalEvent.size());
LOGGER.warn("Test 12 [ END ]");
}
@Test
@Order(13)
public void testConnectAndTransmit13() {
LOGGER.warn("Test 13 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
//connect step 1
receiver.connect13(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
sender.sendEvent();
Assertions.assertEquals(true, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
// remove connection (check auto remove)...
receiver = null;
System.gc();
sender.sendEvent();
Assertions.assertEquals(0, sender.signalEvent.size());
LOGGER.warn("Test 13 [ END ]");
}
@Test
public void testEmptyConnection() {
LOGGER.warn("Test 8 [BEGIN]");
final Connection con = new Connection();
Assertions.assertEquals(false, con.isConnected());
con.close();
LOGGER.warn("Test 8 [ END ]");
}
@Test
public void testClearConnection() {
LOGGER.warn("Test 9 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
final ReceiverSimple receiver = new ReceiverSimple();
//connect step 1
receiver.connect7(sender);
Assertions.assertEquals(1, sender.currentNumberConnection);
Assertions.assertEquals(1, sender.deltaConnection);
receiver.connect5(sender);
Assertions.assertEquals(2, sender.currentNumberConnection);
Assertions.assertEquals(1, sender.deltaConnection);
Assertions.assertEquals(2, sender.signalEvent.size());
sender.signalEvent.clear();
Assertions.assertEquals(0, sender.currentNumberConnection);
Assertions.assertEquals(-2, sender.deltaConnection);
LOGGER.warn("Test 9 [ END ]");
}
@Test
public void testDisconnectionRemovedSignal() {
LOGGER.warn("Test 10 [BEGIN]");
EmiterSimple sender = new EmiterSimple();
final ReceiverSimple receiver = new ReceiverSimple();
//connect step 1
receiver.connect7(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
sender = null;
System.gc();
Assertions.assertEquals(false, receiver.isConnected());
receiver.close();
LOGGER.warn("Test 10 [ END ]");
}
}

View File

@ -0,0 +1,631 @@
/*******************************************************************************
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* Contributors:
* Edouard DUPIN - initial API and implementation
******************************************************************************/
package test.atriasoft.esignal;
import java.lang.ref.WeakReference;
import java.util.function.Consumer;
import org.atriasoft.esignal.Connection;
import org.atriasoft.esignal.Signal;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
//import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@TestMethodOrder(OrderAnnotation.class)
public class TestSignal {
static final Logger LOGGER = LoggerFactory.getLogger(TestSignal.class);
class EmiterSimple {
public Signal<String> signalEvent = new Signal<>();
public void sendEvent(final String value) {
this.signalEvent.emit(value);
}
}
static class ReceiverSimple implements AutoCloseable {
private String dataReceive = null;
ReceiverSimple() {}
// record consumer
private Consumer<String> tmpConsumer1 = null;
private Connection tmpConnect = null;
@Override
public void close() {
this.tmpConsumer1 = null;
if (this.tmpConnect != null) {
this.tmpConnect.close();
this.tmpConnect = null;
}
this.dataReceive = null;
}
public void disconnectConnection() {
this.tmpConnect.close();
}
public boolean isConnected() {
return this.tmpConnect.isConnected();
}
public void connect1(final EmiterSimple other) {
final WeakReference<ReceiverSimple> self = new WeakReference<>(this);
this.tmpConnect = other.signalEvent.connect(data -> {
self.get().onData(data);
});
System.gc();
}
public void connect2(final EmiterSimple other) {
// the solo lambda will not depend on the object => the remove must be done manually...
this.tmpConnect = other.signalEvent.connect(data -> {
LOGGER.error("lambda receive: " + data);
});
System.gc();
}
public void connect3(final EmiterSimple other) {
// we reference the local object, then the lambda is alive while the object is alive...
this.tmpConnect = other.signalEvent.connect(data -> {
LOGGER.error("lambda receive: " + data);
this.dataReceive = data;
});
System.gc();
}
public void connect4(final EmiterSimple other) {
this.tmpConnect = other.signalEvent.connect(data -> {
onData(data);
});
System.gc();
}
public void connect5(final EmiterSimple other) {
this.tmpConsumer1 = this::onData;
other.signalEvent.connectWeak(this.tmpConsumer1);
System.gc();
}
public void disconnectConsumer1(final EmiterSimple other) {
other.signalEvent.disconnect(this.tmpConsumer1);
this.tmpConsumer1 = null;
}
public void connect6(final EmiterSimple other) {
// the solo lambda will not depend on the object => the remove must be done manually...
other.signalEvent.connectAutoRemoveObject(this, data -> {
LOGGER.error("lambda receive: " + data);
});
System.gc();
}
public void connect7(final EmiterSimple other) {
this.tmpConnect = other.signalEvent.connect(this::onData);
System.gc();
}
public void disconnect7(final EmiterSimple other) {
other.signalEvent.disconnect(this.tmpConnect);
}
public void onData(final String data) {
LOGGER.error("Retrive data : " + data);
this.dataReceive = data;
}
public void connect8(final EmiterSimple other) {
this.tmpConnect = other.signalEvent.connect(this, ReceiverSimple::onDataStatic);
System.gc();
}
public void connect9(final EmiterSimple other) {
other.signalEvent.connectAuto(this, ReceiverSimple::onDataStatic);
System.gc();
}
public static void onDataStatic(final Object local, final String data) {
final ReceiverSimple self = (ReceiverSimple) local;
LOGGER.error("Retrive data : " + data);
self.dataReceive = data;
}
public void connect10(final EmiterSimple other) {
this.tmpConnect = other.signalEvent.connect(this, ReceiverSimple::onDataStatic2);
System.gc();
}
public void connect11(final EmiterSimple other) {
other.signalEvent.connectAuto(this, ReceiverSimple::onDataStatic2);
System.gc();
}
public static void onDataStatic2(final ReceiverSimple self, final String data) {
LOGGER.error("Retrive data : " + data);
self.dataReceive = data;
}
public void connect12(final EmiterSimple other) {
this.tmpConnect = other.signalEvent.connect(this, (final ReceiverSimple self, final String data) -> {
LOGGER.error("Retrive data : " + data);
self.dataReceive = data;
});
System.gc();
}
public void connect13(final EmiterSimple other) {
other.signalEvent.connectAuto(this, (final ReceiverSimple self, final String data) -> {
LOGGER.error("Retrive data : " + data);
self.dataReceive = data;
});
System.gc();
}
public String getDataAndClean() {
final String tmp = this.dataReceive;
this.dataReceive = null;
return tmp;
}
}
@Test
@Order(1)
public void testConnectAndTransmit1() {
LOGGER.warn("Test 1 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
receiver.connect1(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
final String testData1 = "MUST receive this data...";
sender.sendEvent(testData1);
Assertions.assertEquals(testData1, receiver.getDataAndClean());
receiver = null;
Assertions.assertEquals(1, sender.signalEvent.size());
System.gc();
final String testData2 = "MUST NOT receive this data...";
sender.sendEvent(testData2);
Assertions.assertEquals(0, sender.signalEvent.size());
LOGGER.warn("Test 1 [ END ]");
}
@Test
@Order(2)
public void testConnectAndTransmit2() {
LOGGER.warn("Test 2 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
receiver.connect2(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
final String testData1 = "MUST receive this data...";
sender.sendEvent(testData1);
// No data stored ... assertEquals(testData1, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
// !!!! NO need to close lambda does not capture the THIS
receiver = null;
System.gc();
final String testData2 = "Solo Lambda MUST receive this data...";
sender.sendEvent(testData2);
Assertions.assertEquals(0, sender.signalEvent.size());
LOGGER.warn("Test 2 [ END ]");
}
@Test
@Order(3)
public void testConnectAndTransmit3() {
LOGGER.warn("Test 3 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
receiver.connect3(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
final String testData1 = "MUST receive this data...";
sender.sendEvent(testData1);
Assertions.assertEquals(testData1, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
// Need to close ==> capture Of this
receiver.close();
receiver = null;
System.gc();
final String testData2 = "MUST NOT receive this data...";
sender.sendEvent(testData2);
Assertions.assertEquals(0, sender.signalEvent.size());
LOGGER.warn("Test 3 [ END ]");
}
@Test
@Order(4)
public void testConnectAndTransmit4() {
LOGGER.warn("Test 4 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
receiver.connect4(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
final String testData1 = "MUST receive this data...";
sender.sendEvent(testData1);
Assertions.assertEquals(testData1, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
// Need to close ==> capture Of this
receiver.close();
receiver = null;
System.gc();
final String testData2 = "MUST NOT receive this data...";
sender.sendEvent(testData2);
Assertions.assertEquals(0, sender.signalEvent.size());
LOGGER.warn("Test 4 [ END ]");
}
@Test
@Order(5)
public void testConnectAndTransmit5() {
LOGGER.warn("Test 5 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
//connect step 1
receiver.connect5(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
final String testData1 = "MUST receive this data... 111";
sender.sendEvent(testData1);
Assertions.assertEquals(testData1, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
// remove connection
receiver.disconnectConsumer1(sender);
Assertions.assertEquals(0, sender.signalEvent.size());
System.gc();
final String testData2 = "MUST NOT receive this data... 222";
sender.sendEvent(testData2);
Assertions.assertEquals(null, receiver.getDataAndClean());
// reconnect (step 2
receiver.connect5(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
final String testData3 = "MUST receive this data... 333";
sender.sendEvent(testData3);
Assertions.assertEquals(testData3, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
// No need to close ==> the capture seams does not increase the cumber of Reference ....
// check auto remove...
receiver = null;
System.gc();
final String testData4 = "MUST NOT receive this data... 444";
sender.sendEvent(testData4);
Assertions.assertEquals(0, sender.signalEvent.size());
LOGGER.warn("Test 5 [ END ]");
}
@Test
@Order(6)
public void testConnectAndTransmit6() {
LOGGER.warn("Test 6 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
receiver.connect6(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
final String testData1 = "MUST receive this data...";
sender.sendEvent(testData1);
//assertEquals(testData1, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
receiver = null;
System.gc();
final String testData2 = "MUST NOT receive this data...";
sender.sendEvent(testData2);
Assertions.assertEquals(0, sender.signalEvent.size());
LOGGER.warn("Test 6 [ END ]");
}
@Test
@Order(7)
public void testConnectAndTransmit7() {
LOGGER.warn("Test 7 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
//connect step 1
receiver.connect7(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
final String testData1 = "MUST receive this data... 111";
sender.sendEvent(testData1);
Assertions.assertEquals(testData1, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
Assertions.assertEquals(true, receiver.isConnected());
// remove connection
receiver.disconnect7(sender);
Assertions.assertEquals(false, receiver.isConnected());
System.gc();
final String testData2 = "MUST NOT receive this data... 222";
sender.sendEvent(testData2);
Assertions.assertEquals(0, sender.signalEvent.size());
Assertions.assertEquals(null, receiver.getDataAndClean());
// reconnect (step 2
receiver.connect7(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
final String testData3 = "MUST receive this data... 333";
sender.sendEvent(testData3);
Assertions.assertEquals(testData3, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
Assertions.assertEquals(true, receiver.isConnected());
// remove connection
receiver.disconnectConnection();
Assertions.assertEquals(false, receiver.isConnected());
Assertions.assertEquals(0, sender.signalEvent.size());
System.gc();
final String testData4 = "MUST NOT receive this data... 444";
sender.sendEvent(testData4);
Assertions.assertEquals(null, receiver.getDataAndClean());
// reconnect (step 2
receiver.connect7(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
final String testData5 = "MUST receive this data... 555";
sender.sendEvent(testData5);
Assertions.assertEquals(testData5, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
// Need to close to prevent miss removing of connection.
receiver.close();
// check auto remove...
receiver = null;
System.gc();
final String testData6 = "MUST NOT receive this data... 666";
sender.sendEvent(testData6);
Assertions.assertEquals(0, sender.signalEvent.size());
LOGGER.warn("Test 7 [ END ]");
}
@Test
@Order(8)
public void testConnectAndTransmit8() {
LOGGER.warn("Test 8 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
//connect step 1
receiver.connect8(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
final String testData1 = "MUST receive this data... 111";
sender.sendEvent(testData1);
Assertions.assertEquals(testData1, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
Assertions.assertEquals(true, receiver.isConnected());
// remove connection
receiver.disconnectConnection();
Assertions.assertEquals(false, receiver.isConnected());
System.gc();
final String testData2 = "MUST NOT receive this data... 222";
sender.sendEvent(testData2);
Assertions.assertEquals(0, sender.signalEvent.size());
Assertions.assertEquals(null, receiver.getDataAndClean());
// reconnect (step 2
receiver.connect8(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
final String testData3 = "MUST receive this data... 333";
sender.sendEvent(testData3);
Assertions.assertEquals(testData3, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
Assertions.assertEquals(true, receiver.isConnected());
// remove connection
receiver.disconnectConnection();
Assertions.assertEquals(false, receiver.isConnected());
Assertions.assertEquals(0, sender.signalEvent.size());
System.gc();
final String testData4 = "MUST NOT receive this data... 444";
sender.sendEvent(testData4);
Assertions.assertEquals(null, receiver.getDataAndClean());
// reconnect (step 2
receiver.connect8(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
final String testData5 = "MUST receive this data... 555";
sender.sendEvent(testData5);
Assertions.assertEquals(testData5, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
// check auto remove...
receiver = null;
System.gc();
final String testData6 = "MUST NOT receive this data... 666";
sender.sendEvent(testData6);
Assertions.assertEquals(0, sender.signalEvent.size());
LOGGER.warn("Test 8 [ END ]");
}
@Test
@Order(9)
public void testConnectAndTransmit9() {
LOGGER.warn("Test 9 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
//connect step 1
receiver.connect9(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
final String testData1 = "MUST receive this data... 111";
sender.sendEvent(testData1);
Assertions.assertEquals(testData1, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
// remove connection (check auto remove)...
receiver = null;
System.gc();
final String testData6 = "MUST NOT receive this data... 666";
sender.sendEvent(testData6);
Assertions.assertEquals(0, sender.signalEvent.size());
LOGGER.warn("Test 9 [ END ]");
}
@Test
@Order(10)
public void testConnectAndTransmit10() {
LOGGER.warn("Test 10 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
//connect step 1
receiver.connect10(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
final String testData1 = "MUST receive this data... 111";
sender.sendEvent(testData1);
Assertions.assertEquals(testData1, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
Assertions.assertEquals(true, receiver.isConnected());
// remove connection
receiver.disconnectConnection();
Assertions.assertEquals(false, receiver.isConnected());
System.gc();
final String testData2 = "MUST NOT receive this data... 222";
sender.sendEvent(testData2);
Assertions.assertEquals(0, sender.signalEvent.size());
Assertions.assertEquals(null, receiver.getDataAndClean());
// reconnect (step 2
receiver.connect10(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
final String testData3 = "MUST receive this data... 333";
sender.sendEvent(testData3);
Assertions.assertEquals(testData3, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
Assertions.assertEquals(true, receiver.isConnected());
// remove connection
receiver.disconnectConnection();
Assertions.assertEquals(false, receiver.isConnected());
Assertions.assertEquals(0, sender.signalEvent.size());
System.gc();
final String testData4 = "MUST NOT receive this data... 444";
sender.sendEvent(testData4);
Assertions.assertEquals(null, receiver.getDataAndClean());
// reconnect (step 2
receiver.connect10(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
final String testData5 = "MUST receive this data... 555";
sender.sendEvent(testData5);
Assertions.assertEquals(testData5, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
// check auto remove...
receiver = null;
System.gc();
final String testData6 = "MUST NOT receive this data... 666";
sender.sendEvent(testData6);
Assertions.assertEquals(0, sender.signalEvent.size());
LOGGER.warn("Test 10 [ END ]");
}
@Test
@Order(11)
public void testConnectAndTransmit11() {
LOGGER.warn("Test 11 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
//connect step 1
receiver.connect11(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
final String testData1 = "MUST receive this data... 111";
sender.sendEvent(testData1);
Assertions.assertEquals(testData1, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
// remove connection (check auto remove)...
receiver = null;
System.gc();
final String testData6 = "MUST NOT receive this data... 666";
sender.sendEvent(testData6);
Assertions.assertEquals(0, sender.signalEvent.size());
LOGGER.warn("Test 11 [ END ]");
}
@Test
@Order(12)
public void testConnectAndTransmit12() {
LOGGER.warn("Test 12 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
//connect step 1
receiver.connect12(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
final String testData1 = "MUST receive this data... 111";
sender.sendEvent(testData1);
Assertions.assertEquals(testData1, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
Assertions.assertEquals(true, receiver.isConnected());
// remove connection
receiver.disconnectConnection();
Assertions.assertEquals(false, receiver.isConnected());
System.gc();
final String testData2 = "MUST NOT receive this data... 222";
sender.sendEvent(testData2);
Assertions.assertEquals(0, sender.signalEvent.size());
Assertions.assertEquals(null, receiver.getDataAndClean());
// reconnect (step 2
receiver.connect12(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
final String testData3 = "MUST receive this data... 333";
sender.sendEvent(testData3);
Assertions.assertEquals(testData3, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
Assertions.assertEquals(true, receiver.isConnected());
// remove connection
receiver.disconnectConnection();
Assertions.assertEquals(false, receiver.isConnected());
Assertions.assertEquals(0, sender.signalEvent.size());
System.gc();
final String testData4 = "MUST NOT receive this data... 444";
sender.sendEvent(testData4);
Assertions.assertEquals(null, receiver.getDataAndClean());
// reconnect (step 2
receiver.connect12(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
final String testData5 = "MUST receive this data... 555";
sender.sendEvent(testData5);
Assertions.assertEquals(testData5, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
// check auto remove...
receiver = null;
System.gc();
final String testData6 = "MUST NOT receive this data... 666";
sender.sendEvent(testData6);
Assertions.assertEquals(0, sender.signalEvent.size());
LOGGER.warn("Test 12 [ END ]");
}
@Test
@Order(13)
public void testConnectAndTransmit13() {
LOGGER.warn("Test 13 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
//connect step 1
receiver.connect13(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
final String testData1 = "MUST receive this data... 131";
sender.sendEvent(testData1);
Assertions.assertEquals(testData1, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
// remove connection (check auto remove)...
receiver = null;
System.gc();
final String testData6 = "MUST NOT receive this data... 666";
sender.sendEvent(testData6);
Assertions.assertEquals(0, sender.signalEvent.size());
LOGGER.warn("Test 13 [ END ]");
}
@Test
public void testClearConnection() {
final EmiterSimple sender = new EmiterSimple();
final ReceiverSimple receiver = new ReceiverSimple();
//connect step 1
receiver.connect7(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
sender.signalEvent.clear();
}
}

View File

@ -0,0 +1,630 @@
/*******************************************************************************
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* Contributors:
* Edouard DUPIN - initial API and implementation
******************************************************************************/
package test.atriasoft.esignal;
import java.lang.ref.WeakReference;
import org.atriasoft.esignal.Connection;
import org.atriasoft.esignal.SignalEmpty;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
//import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@TestMethodOrder(OrderAnnotation.class)
public class TestSignalEmpty {
static final Logger LOGGER = LoggerFactory.getLogger(TestSignalEmpty.class);
class EmiterSimple {
public SignalEmpty signalEvent = new SignalEmpty();
public void sendEvent() {
this.signalEvent.emit();
}
}
static class ReceiverSimple implements AutoCloseable {
private boolean dataReceive = false;
ReceiverSimple() {}
// record consumer
private Runnable tmpConsumer1 = null;
private Connection tmpConnect = null;
@Override
public void close() {
this.tmpConsumer1 = null;
if (this.tmpConnect != null) {
this.tmpConnect.close();
this.tmpConnect = null;
}
this.dataReceive = false;
}
public void disconnectConnection() {
this.tmpConnect.close();
}
public boolean isConnected() {
return this.tmpConnect.isConnected();
}
public void connect1(final EmiterSimple other) {
final WeakReference<ReceiverSimple> self = new WeakReference<>(this);
this.tmpConnect = other.signalEvent.connect(() -> {
self.get().onData();
});
System.gc();
}
public void connect2(final EmiterSimple other) {
// the solo lambda will not depend on the object => the remove must be done manually...
this.tmpConnect = other.signalEvent.connect(() -> {
LOGGER.error("lambda receive: ");
});
System.gc();
}
public void connect3(final EmiterSimple other) {
// we reference the local object, then the lambda is alive while the object is alive...
this.tmpConnect = other.signalEvent.connect(() -> {
LOGGER.error("lambda receive: ");
this.dataReceive = true;
});
System.gc();
}
public void connect4(final EmiterSimple other) {
this.tmpConnect = other.signalEvent.connect(() -> {
onData();
});
System.gc();
}
public void connect5(final EmiterSimple other) {
this.tmpConsumer1 = this::onData;
other.signalEvent.connectWeak(this.tmpConsumer1);
System.gc();
}
public void disconnectConsumer1(final EmiterSimple other) {
other.signalEvent.disconnect(this.tmpConsumer1);
this.tmpConsumer1 = null;
}
public void connect6(final EmiterSimple other) {
// the solo lambda will not depend on the object => the remove must be done manually...
other.signalEvent.connectAutoRemoveObject(this, () -> {
LOGGER.error("lambda receive: ");
});
System.gc();
}
public void connect7(final EmiterSimple other) {
this.tmpConnect = other.signalEvent.connect(this::onData);
System.gc();
}
public void disconnect7(final EmiterSimple other) {
other.signalEvent.disconnect(this.tmpConnect);
}
public void onData() {
LOGGER.error("Retrive data : ");
this.dataReceive = true;
}
public void connect8(final EmiterSimple other) {
this.tmpConnect = other.signalEvent.connect(this, ReceiverSimple::onDataStatic);
System.gc();
}
public void connect9(final EmiterSimple other) {
other.signalEvent.connectAuto(this, ReceiverSimple::onDataStatic);
System.gc();
}
public static void onDataStatic(final Object local) {
final ReceiverSimple self = (ReceiverSimple) local;
LOGGER.error("Retrive data : ");
self.dataReceive = true;
}
public void connect10(final EmiterSimple other) {
this.tmpConnect = other.signalEvent.connect(this, ReceiverSimple::onDataStatic2);
System.gc();
}
public void connect11(final EmiterSimple other) {
other.signalEvent.connectAuto(this, ReceiverSimple::onDataStatic2);
System.gc();
}
public static void onDataStatic2(final ReceiverSimple self) {
LOGGER.error("Retrive data : ");
self.dataReceive = true;
}
public void connect12(final EmiterSimple other) {
this.tmpConnect = other.signalEvent.connect(this, (final ReceiverSimple self) -> {
LOGGER.error("Retrive data : ");
self.dataReceive = true;
});
System.gc();
}
public void connect13(final EmiterSimple other) {
other.signalEvent.connectAuto(this, (final ReceiverSimple self) -> {
LOGGER.error("Retrive data : ");
self.dataReceive = true;
});
System.gc();
}
public boolean getDataAndClean() {
final boolean tmp = this.dataReceive;
this.dataReceive = false;
return tmp;
}
}
@Test
@Order(1)
public void testConnectAndTransmit1() {
LOGGER.warn("Test 1 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
receiver.connect1(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
sender.sendEvent();
Assertions.assertEquals(true, receiver.getDataAndClean());
receiver = null;
Assertions.assertEquals(1, sender.signalEvent.size());
System.gc();
sender.sendEvent();
Assertions.assertEquals(0, sender.signalEvent.size());
LOGGER.warn("Test 1 [ END ]");
}
@Test
@Order(2)
public void testConnectAndTransmit2() {
LOGGER.warn("Test 2 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
receiver.connect2(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
sender.sendEvent();
// No data stored ... assertEquals(true, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
// !!!! NO need to close lambda does not capture the THIS
receiver = null;
System.gc();
sender.sendEvent();
Assertions.assertEquals(0, sender.signalEvent.size());
LOGGER.warn("Test 2 [ END ]");
}
@Test
@Order(3)
public void testConnectAndTransmit3() {
LOGGER.warn("Test 3 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
receiver.connect3(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
sender.sendEvent();
Assertions.assertEquals(true, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
// Need to close ==> capture Of this
receiver.close();
receiver = null;
System.gc();
sender.sendEvent();
Assertions.assertEquals(0, sender.signalEvent.size());
LOGGER.warn("Test 3 [ END ]");
}
@Test
@Order(4)
public void testConnectAndTransmit4() {
LOGGER.warn("Test 4 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
receiver.connect4(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
sender.sendEvent();
Assertions.assertEquals(true, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
// Need to close ==> capture Of this
receiver.close();
receiver = null;
System.gc();
sender.sendEvent();
Assertions.assertEquals(0, sender.signalEvent.size());
LOGGER.warn("Test 4 [ END ]");
}
@Test
@Order(5)
public void testConnectAndTransmit5() {
LOGGER.warn("Test 5 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
//connect step 1
receiver.connect5(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
sender.sendEvent();
Assertions.assertEquals(true, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
// remove connection
receiver.disconnectConsumer1(sender);
Assertions.assertEquals(0, sender.signalEvent.size());
System.gc();
sender.sendEvent();
Assertions.assertEquals(false, receiver.getDataAndClean());
// reconnect (step 2
receiver.connect5(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
sender.sendEvent();
Assertions.assertEquals(true, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
// No need to close ==> the capture seams does not increase the cumber of Reference ....
// check auto remove...
receiver = null;
System.gc();
sender.sendEvent();
Assertions.assertEquals(0, sender.signalEvent.size());
LOGGER.warn("Test 5 [ END ]");
}
@Test
@Order(6)
public void testConnectAndTransmit6() {
LOGGER.warn("Test 6 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
receiver.connect6(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
sender.sendEvent();
//assertEquals(true, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
receiver = null;
System.gc();
sender.sendEvent();
Assertions.assertEquals(0, sender.signalEvent.size());
LOGGER.warn("Test 6 [ END ]");
}
@Test
@Order(7)
public void testConnectAndTransmit7() {
LOGGER.warn("Test 7 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
//connect step 1
receiver.connect7(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
sender.sendEvent();
Assertions.assertEquals(true, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
Assertions.assertEquals(true, receiver.isConnected());
// remove connection
receiver.disconnect7(sender);
Assertions.assertEquals(false, receiver.isConnected());
System.gc();
sender.sendEvent();
Assertions.assertEquals(0, sender.signalEvent.size());
Assertions.assertEquals(false, receiver.getDataAndClean());
// reconnect (step 2
receiver.connect7(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
sender.sendEvent();
Assertions.assertEquals(true, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
Assertions.assertEquals(true, receiver.isConnected());
// remove connection
receiver.disconnectConnection();
Assertions.assertEquals(false, receiver.isConnected());
Assertions.assertEquals(0, sender.signalEvent.size());
System.gc();
sender.sendEvent();
Assertions.assertEquals(false, receiver.getDataAndClean());
// reconnect (step 2
receiver.connect7(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
sender.sendEvent();
Assertions.assertEquals(true, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
// Need to close to prevent miss removing of connection.
receiver.close();
// check auto remove...
receiver = null;
System.gc();
sender.sendEvent();
Assertions.assertEquals(0, sender.signalEvent.size());
LOGGER.warn("Test 7 [ END ]");
}
@Test
@Order(8)
public void testConnectAndTransmit8() {
LOGGER.warn("Test 8 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
//connect step 1
receiver.connect8(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
sender.sendEvent();
Assertions.assertEquals(true, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
Assertions.assertEquals(true, receiver.isConnected());
// remove connection
receiver.disconnectConnection();
Assertions.assertEquals(false, receiver.isConnected());
System.gc();
sender.sendEvent();
Assertions.assertEquals(0, sender.signalEvent.size());
Assertions.assertEquals(false, receiver.getDataAndClean());
// reconnect (step 2
receiver.connect8(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
sender.sendEvent();
Assertions.assertEquals(true, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
Assertions.assertEquals(true, receiver.isConnected());
// remove connection
receiver.disconnectConnection();
Assertions.assertEquals(false, receiver.isConnected());
Assertions.assertEquals(0, sender.signalEvent.size());
System.gc();
sender.sendEvent();
Assertions.assertEquals(false, receiver.getDataAndClean());
// reconnect (step 2
receiver.connect8(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
sender.sendEvent();
Assertions.assertEquals(true, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
// check auto remove...
receiver = null;
System.gc();
sender.sendEvent();
Assertions.assertEquals(0, sender.signalEvent.size());
LOGGER.warn("Test 8 [ END ]");
}
@Test
@Order(9)
public void testConnectAndTransmit9() {
LOGGER.warn("Test 9 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
//connect step 1
receiver.connect9(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
sender.sendEvent();
Assertions.assertEquals(true, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
// remove connection (check auto remove)...
receiver = null;
System.gc();
sender.sendEvent();
Assertions.assertEquals(0, sender.signalEvent.size());
LOGGER.warn("Test 9 [ END ]");
}
@Test
@Order(10)
public void testConnectAndTransmit10() {
LOGGER.warn("Test 10 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
//connect step 1
receiver.connect10(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
sender.sendEvent();
Assertions.assertEquals(true, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
Assertions.assertEquals(true, receiver.isConnected());
// remove connection
receiver.disconnectConnection();
Assertions.assertEquals(false, receiver.isConnected());
System.gc();
sender.sendEvent();
Assertions.assertEquals(0, sender.signalEvent.size());
Assertions.assertEquals(false, receiver.getDataAndClean());
// reconnect (step 2
receiver.connect10(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
sender.sendEvent();
Assertions.assertEquals(true, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
Assertions.assertEquals(true, receiver.isConnected());
// remove connection
receiver.disconnectConnection();
Assertions.assertEquals(false, receiver.isConnected());
Assertions.assertEquals(0, sender.signalEvent.size());
System.gc();
sender.sendEvent();
Assertions.assertEquals(false, receiver.getDataAndClean());
// reconnect (step 2
receiver.connect10(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
sender.sendEvent();
Assertions.assertEquals(true, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
// check auto remove...
receiver = null;
System.gc();
sender.sendEvent();
Assertions.assertEquals(0, sender.signalEvent.size());
LOGGER.warn("Test 10 [ END ]");
}
@Test
@Order(11)
public void testConnectAndTransmit11() {
LOGGER.warn("Test 11 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
//connect step 1
receiver.connect11(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
sender.sendEvent();
Assertions.assertEquals(true, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
// remove connection (check auto remove)...
receiver = null;
System.gc();
sender.sendEvent();
Assertions.assertEquals(0, sender.signalEvent.size());
LOGGER.warn("Test 11 [ END ]");
}
@Test
@Order(12)
public void testConnectAndTransmit12() {
LOGGER.warn("Test 12 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
//connect step 1
receiver.connect12(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
sender.sendEvent();
Assertions.assertEquals(true, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
Assertions.assertEquals(true, receiver.isConnected());
// remove connection
receiver.disconnectConnection();
Assertions.assertEquals(false, receiver.isConnected());
System.gc();
sender.sendEvent();
Assertions.assertEquals(0, sender.signalEvent.size());
Assertions.assertEquals(false, receiver.getDataAndClean());
// reconnect (step 2
receiver.connect12(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
sender.sendEvent();
Assertions.assertEquals(true, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
Assertions.assertEquals(true, receiver.isConnected());
// remove connection
receiver.disconnectConnection();
Assertions.assertEquals(false, receiver.isConnected());
Assertions.assertEquals(0, sender.signalEvent.size());
System.gc();
sender.sendEvent();
Assertions.assertEquals(false, receiver.getDataAndClean());
// reconnect (step 2
receiver.connect12(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
sender.sendEvent();
Assertions.assertEquals(true, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
// check auto remove...
receiver = null;
System.gc();
sender.sendEvent();
Assertions.assertEquals(0, sender.signalEvent.size());
LOGGER.warn("Test 12 [ END ]");
}
@Test
@Order(13)
public void testConnectAndTransmit13() {
LOGGER.warn("Test 13 [BEGIN]");
final EmiterSimple sender = new EmiterSimple();
ReceiverSimple receiver = new ReceiverSimple();
//connect step 1
receiver.connect13(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
sender.sendEvent();
Assertions.assertEquals(true, receiver.getDataAndClean());
Assertions.assertEquals(1, sender.signalEvent.size());
// remove connection (check auto remove)...
receiver = null;
System.gc();
sender.sendEvent();
Assertions.assertEquals(0, sender.signalEvent.size());
LOGGER.warn("Test 13 [ END ]");
}
@Test
public void testClearConnection() {
final EmiterSimple sender = new EmiterSimple();
final ReceiverSimple receiver = new ReceiverSimple();
//connect step 1
receiver.connect7(sender);
Assertions.assertEquals(1, sender.signalEvent.size());
sender.signalEvent.clear();
}
}

1
version.txt Normal file
View File

@ -0,0 +1 @@
0.1.0