Merge remote-tracking branch 'common/develop' into develop
This commit is contained in:
commit
79cb8e821c
28
.classpath
Normal file
28
.classpath
Normal file
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||
<attributes>
|
||||
<attribute name="test" value="true"/>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
1
.github/CODEOWNERS
vendored
Normal file
1
.github/CODEOWNERS
vendored
Normal file
@ -0,0 +1 @@
|
||||
* @CyB3RC0nN0R
|
38
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
38
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: bug
|
||||
assignees: CyB3RC0nN0R, delvh
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Desktop (please complete the following information):**
|
||||
- OS: [e.g. iOS]
|
||||
- Browser [e.g. chrome, safari]
|
||||
- Version [e.g. 22]
|
||||
|
||||
**Smartphone (please complete the following information):**
|
||||
- Device: [e.g. iPhone6]
|
||||
- OS: [e.g. iOS8.1]
|
||||
- Browser [e.g. stock browser, safari]
|
||||
- Version [e.g. 22]
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: enhancement
|
||||
assignees: CyB3RC0nN0R, delvh
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
10
.github/PULL_REQUEST_TEMPLATE/bugfix.md
vendored
Normal file
10
.github/PULL_REQUEST_TEMPLATE/bugfix.md
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
---
|
||||
name: Bug fix
|
||||
title: Fixed Bug
|
||||
labels: bug
|
||||
assignees: CyB3RC0nN0R, delvh, DieGurke
|
||||
reviewers: CyB3RC0nN0R, delvh
|
||||
projects: Envoy
|
||||
milestone: Envoy v0.3-alpha
|
||||
---
|
||||
Fixes #{issue}
|
9
.github/PULL_REQUEST_TEMPLATE/feature_integration.md
vendored
Normal file
9
.github/PULL_REQUEST_TEMPLATE/feature_integration.md
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
---
|
||||
name: Feature integration
|
||||
title: Added feature
|
||||
labels: enhancement
|
||||
assignees: CyB3RC0nN0R, delvh, DieGurke
|
||||
reviewers: CyB3RC0nN0R, delvh
|
||||
projects: Envoy
|
||||
milestone: Envoy v0.3-alpha
|
||||
---
|
9
.github/PULL_REQUEST_TEMPLATE/javadoc_upgrade.md
vendored
Normal file
9
.github/PULL_REQUEST_TEMPLATE/javadoc_upgrade.md
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
---
|
||||
name: Updated Javadoc
|
||||
title: Updated Javadoc
|
||||
labels: documentation
|
||||
assignees: CyB3RC0nN0R, delvh
|
||||
reviewers: CyB3RC0nN0R, delvh
|
||||
projects: Envoy
|
||||
milestone: Envoy v0.3-alpha
|
||||
---
|
17
.github/workflows/maven.yml
vendored
Normal file
17
.github/workflows/maven.yml
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
name: Java CI
|
||||
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Set up JDK 11
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 11
|
||||
- name: Build with Maven
|
||||
run: mvn -B package --file pom.xml
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target/
|
46
.project
Normal file
46
.project
Normal file
@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>envoy-common</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.wst.common.project.facet.core.builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.jboss.tools.jst.web.kb.kbbuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.jboss.tools.cdi.core.cdibuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.wst.validation.validationbuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
|
||||
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
5
.settings/org.eclipse.core.resources.prefs
Normal file
5
.settings/org.eclipse.core.resources.prefs
Normal file
@ -0,0 +1,5 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding//src/main/java=UTF-8
|
||||
encoding//src/test/java=UTF-8
|
||||
encoding//src/test/resources=UTF-8
|
||||
encoding/<project>=UTF-8
|
472
.settings/org.eclipse.jdt.core.prefs
Normal file
472
.settings/org.eclipse.jdt.core.prefs
Normal file
@ -0,0 +1,472 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled
|
||||
org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
|
||||
org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull
|
||||
org.eclipse.jdt.core.compiler.annotation.nonnull.secondary=
|
||||
org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
|
||||
org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary=
|
||||
org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
|
||||
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
|
||||
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
|
||||
org.eclipse.jdt.core.compiler.compliance=11
|
||||
org.eclipse.jdt.core.compiler.problem.APILeak=warning
|
||||
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
|
||||
org.eclipse.jdt.core.compiler.problem.deadCode=warning
|
||||
org.eclipse.jdt.core.compiler.problem.deprecation=warning
|
||||
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.emptyStatement=info
|
||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=warning
|
||||
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
|
||||
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
|
||||
org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
|
||||
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning
|
||||
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
|
||||
org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning
|
||||
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
|
||||
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
|
||||
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
|
||||
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning
|
||||
org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning
|
||||
org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
|
||||
org.eclipse.jdt.core.compiler.problem.nullReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
|
||||
org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning
|
||||
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
|
||||
org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=warning
|
||||
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
|
||||
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning
|
||||
org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=warning
|
||||
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
|
||||
org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
|
||||
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.suppressWarningsNotFullyAnalysed=info
|
||||
org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.terminalDeprecation=warning
|
||||
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
|
||||
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentType=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentTypeStrict=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.unlikelyEqualsArgumentType=info
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unstableAutoModuleName=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameter=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
|
||||
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
|
||||
org.eclipse.jdt.core.compiler.release=disabled
|
||||
org.eclipse.jdt.core.compiler.source=11
|
||||
org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=true
|
||||
org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=1
|
||||
org.eclipse.jdt.core.formatter.align_type_members_on_columns=true
|
||||
org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns=true
|
||||
org.eclipse.jdt.core.formatter.align_with_spaces=false
|
||||
org.eclipse.jdt.core.formatter.alignment_for_additive_operator=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=84
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=80
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=20
|
||||
org.eclipse.jdt.core.formatter.alignment_for_assignment=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_compact_loops=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
|
||||
org.eclipse.jdt.core.formatter.alignment_for_conditional_expression_chain=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_enum_constants=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_logical_operator=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_module_statements=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_relational_operator=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80
|
||||
org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=84
|
||||
org.eclipse.jdt.core.formatter.alignment_for_shift_operator=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_string_concatenation=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_type_arguments=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_type_parameters=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16
|
||||
org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_after_last_class_body_declaration=0
|
||||
org.eclipse.jdt.core.formatter.blank_lines_after_package=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_abstract_method=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_field=0
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_method=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_package=0
|
||||
org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_between_statement_group_in_switch=0
|
||||
org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.comment.align_tags_descriptions_grouped=true
|
||||
org.eclipse.jdt.core.formatter.comment.align_tags_names_descriptions=false
|
||||
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=true
|
||||
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
|
||||
org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position=true
|
||||
org.eclipse.jdt.core.formatter.comment.format_block_comments=true
|
||||
org.eclipse.jdt.core.formatter.comment.format_header=true
|
||||
org.eclipse.jdt.core.formatter.comment.format_html=true
|
||||
org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true
|
||||
org.eclipse.jdt.core.formatter.comment.format_line_comments=true
|
||||
org.eclipse.jdt.core.formatter.comment.format_source_code=true
|
||||
org.eclipse.jdt.core.formatter.comment.indent_parameter_description=false
|
||||
org.eclipse.jdt.core.formatter.comment.indent_root_tags=false
|
||||
org.eclipse.jdt.core.formatter.comment.indent_tag_description=false
|
||||
org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
|
||||
org.eclipse.jdt.core.formatter.comment.insert_new_line_between_different_tags=do not insert
|
||||
org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert
|
||||
org.eclipse.jdt.core.formatter.comment.line_length=80
|
||||
org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true
|
||||
org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true
|
||||
org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false
|
||||
org.eclipse.jdt.core.formatter.compact_else_if=true
|
||||
org.eclipse.jdt.core.formatter.continuation_indentation=2
|
||||
org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
|
||||
org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off
|
||||
org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on
|
||||
org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=true
|
||||
org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true
|
||||
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
|
||||
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
|
||||
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
|
||||
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
|
||||
org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
|
||||
org.eclipse.jdt.core.formatter.indent_empty_lines=false
|
||||
org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
|
||||
org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
|
||||
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
|
||||
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true
|
||||
org.eclipse.jdt.core.formatter.indentation.size=4
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_label=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_additive_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_case=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_default=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_switch_case_expressions=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_logical_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_not_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_relational_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_shift_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_additive_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_case=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_default=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_switch_case_expressions=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_logical_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_relational_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_shift_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
|
||||
org.eclipse.jdt.core.formatter.join_lines_in_comments=false
|
||||
org.eclipse.jdt.core.formatter.join_wrapped_lines=true
|
||||
org.eclipse.jdt.core.formatter.keep_annotation_declaration_on_one_line=one_line_if_single_item
|
||||
org.eclipse.jdt.core.formatter.keep_anonymous_type_declaration_on_one_line=one_line_never
|
||||
org.eclipse.jdt.core.formatter.keep_code_block_on_one_line=one_line_if_empty
|
||||
org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=true
|
||||
org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
|
||||
org.eclipse.jdt.core.formatter.keep_enum_constant_declaration_on_one_line=one_line_never
|
||||
org.eclipse.jdt.core.formatter.keep_enum_declaration_on_one_line=one_line_never
|
||||
org.eclipse.jdt.core.formatter.keep_if_then_body_block_on_one_line=one_line_if_single_item
|
||||
org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
|
||||
org.eclipse.jdt.core.formatter.keep_lambda_body_block_on_one_line=one_line_always
|
||||
org.eclipse.jdt.core.formatter.keep_loop_body_block_on_one_line=one_line_if_empty
|
||||
org.eclipse.jdt.core.formatter.keep_method_body_on_one_line=one_line_if_single_item
|
||||
org.eclipse.jdt.core.formatter.keep_simple_do_while_body_on_same_line=false
|
||||
org.eclipse.jdt.core.formatter.keep_simple_for_body_on_same_line=false
|
||||
org.eclipse.jdt.core.formatter.keep_simple_getter_setter_on_one_line=true
|
||||
org.eclipse.jdt.core.formatter.keep_simple_while_body_on_same_line=false
|
||||
org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=true
|
||||
org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line=one_line_never
|
||||
org.eclipse.jdt.core.formatter.lineSplit=150
|
||||
org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
|
||||
org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
|
||||
org.eclipse.jdt.core.formatter.number_of_blank_lines_after_code_block=0
|
||||
org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_code_block=0
|
||||
org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
|
||||
org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_code_block=0
|
||||
org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_method_body=0
|
||||
org.eclipse.jdt.core.formatter.number_of_blank_lines_before_code_block=0
|
||||
org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
|
||||
org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation=separate_lines_if_wrapped
|
||||
org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause=common_lines
|
||||
org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration=common_lines
|
||||
org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment=common_lines
|
||||
org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement=common_lines
|
||||
org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration=common_lines
|
||||
org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration=common_lines
|
||||
org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation=common_lines
|
||||
org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement=common_lines
|
||||
org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause=common_lines
|
||||
org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
|
||||
org.eclipse.jdt.core.formatter.tabulation.char=tab
|
||||
org.eclipse.jdt.core.formatter.tabulation.size=4
|
||||
org.eclipse.jdt.core.formatter.text_block_indentation=0
|
||||
org.eclipse.jdt.core.formatter.use_on_off_tags=false
|
||||
org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
|
||||
org.eclipse.jdt.core.formatter.wrap_before_additive_operator=true
|
||||
org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false
|
||||
org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator=true
|
||||
org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true
|
||||
org.eclipse.jdt.core.formatter.wrap_before_logical_operator=true
|
||||
org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator=true
|
||||
org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true
|
||||
org.eclipse.jdt.core.formatter.wrap_before_relational_operator=true
|
||||
org.eclipse.jdt.core.formatter.wrap_before_shift_operator=true
|
||||
org.eclipse.jdt.core.formatter.wrap_before_string_concatenation=true
|
||||
org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
|
||||
org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter
|
5
.settings/org.eclipse.jdt.ui.prefs
Normal file
5
.settings/org.eclipse.jdt.ui.prefs
Normal file
File diff suppressed because one or more lines are too long
4
.settings/org.eclipse.m2e.core.prefs
Normal file
4
.settings/org.eclipse.m2e.core.prefs
Normal file
@ -0,0 +1,4 @@
|
||||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
37
.settings/org.eclipse.wst.common.component
Normal file
37
.settings/org.eclipse.wst.common.component
Normal file
@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<wb-module deploy-name="envoy-common">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<wb-resource deploy-path="/" source-path="/src/main/java"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</wb-module>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</project-modules>
|
5
.settings/org.eclipse.wst.common.project.facet.core.xml
Normal file
5
.settings/org.eclipse.wst.common.project.facet.core.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<faceted-project>
|
||||
<installed facet="jst.utility" version="1.0"/>
|
||||
<installed facet="java" version="11"/>
|
||||
</faceted-project>
|
2
.settings/org.eclipse.wst.validation.prefs
Normal file
2
.settings/org.eclipse.wst.validation.prefs
Normal file
@ -0,0 +1,2 @@
|
||||
disabled=06target
|
||||
eclipse.preferences.version=1
|
76
CODE_OF_CONDUCT.md
Normal file
76
CODE_OF_CONDUCT.md
Normal file
@ -0,0 +1,76 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and maintainers pledge to making participation in our project and
|
||||
our community a harassment-free experience for everyone, regardless of age, body
|
||||
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
||||
level of experience, education, socio-economic status, nationality, personal
|
||||
appearance, race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment
|
||||
include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||
advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic
|
||||
address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable
|
||||
behavior and are expected to take appropriate and fair corrective action in
|
||||
response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or
|
||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||
permanently any contributor for other behaviors that they deem inappropriate,
|
||||
threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces
|
||||
when an individual is representing the project or its community. Examples of
|
||||
representing a project or community include using an official project e-mail
|
||||
address, posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event. Representation of a project may be
|
||||
further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported by contacting the project team at kske@outlook.de. All
|
||||
complaints will be reviewed and investigated and will result in a response that
|
||||
is deemed necessary and appropriate to the circumstances. The project team is
|
||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||
Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||
faith may face temporary or permanent repercussions as determined by other
|
||||
members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
|
||||
For answers to common questions about this code of conduct, see
|
||||
https://www.contributor-covenant.org/faq
|
161
CONTRIBUTING.md
Normal file
161
CONTRIBUTING.md
Normal file
@ -0,0 +1,161 @@
|
||||
# Contributing to Envoy
|
||||
|
||||
Looking to contribute something to Envoy? **Here's how you can help.**
|
||||
|
||||
Please take a moment to review this document in order to make the contribution
|
||||
process easy and effective for everyone involved.
|
||||
|
||||
Following these guidelines helps to communicate that you respect the time of
|
||||
the developers managing and developing this open source project. In return,
|
||||
they should reciprocate that respect in addressing your issue or assessing
|
||||
patches and features.
|
||||
|
||||
|
||||
## Using the issue tracker
|
||||
|
||||
The [issue tracker](https://github.com/informatik-ag-ngl/envoy-common/issues) is
|
||||
the preferred channel for [bug reports](#bug-reports), [features requests](#feature-requests)
|
||||
and [submitting pull requests](#pull-requests), but please respect the following
|
||||
restrictions:
|
||||
|
||||
* Please **do not** derail or troll issues. Keep the discussion on topic and
|
||||
respect the opinions of others.
|
||||
|
||||
* Please **do not** post comments consisting solely of "+1" or ":thumbsup:".
|
||||
Use [GitHub's "reactions" feature](https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/)
|
||||
instead. We reserve the right to delete comments which violate this rule.
|
||||
|
||||
However, as we know, we are all software engineers that like being funny hence doing it on purpose. Please also refrain from that kind of behaviour.
|
||||
|
||||
## Issues and labels
|
||||
|
||||
Our bug tracker utilizes several labels to help organize and identify issues. Here's what they represent and how we use them:
|
||||
|
||||
- `Documentation` & `Javadoc`- Issues regarding the documentation of Envoy
|
||||
- `Enhancement` & `Feature` - Issues suggesting a new feature
|
||||
- `Maven` - Issues concerned with Maven problems
|
||||
- `Bug` - Issues concerned with a general bug
|
||||
|
||||
For a complete look at our labels, see the [project labels page](https://github.com/informatik-ag-ngl/envoy-common/labels).
|
||||
|
||||
## Bug reports
|
||||
|
||||
A bug is a _demonstrable problem_ that is caused by the code in the repository.
|
||||
Good bug reports are extremely helpful, so thanks!
|
||||
|
||||
Guidelines for bug reports:
|
||||
|
||||
0. **ensure your problem isn't caused by a simple error in your own code**.
|
||||
|
||||
1. **Use the GitHub issue search** — check if the issue has already been
|
||||
reported.
|
||||
|
||||
2. **Check if the issue has been fixed** — try to reproduce it using the
|
||||
latest `master` or development branch in the repository.
|
||||
|
||||
3. **Isolate the problem** — ideally create a reduced test
|
||||
case and a live example.
|
||||
|
||||
|
||||
A good bug report shouldn't leave others needing to chase you up for more
|
||||
information. Please try to be as detailed as possible in your report. What is
|
||||
your environment? What steps will reproduce the issue? These details will help people to fix
|
||||
any potential bugs.
|
||||
|
||||
Example:
|
||||
|
||||
> Short and descriptive example bug report title
|
||||
>
|
||||
> 1. This is the first step
|
||||
> 2. This is the second step
|
||||
> 3. Further steps, etc.
|
||||
>
|
||||
> Any other information you want to share that is relevant to the issue being
|
||||
> reported. This might include the lines of code that you have identified as
|
||||
> causing the bug, and potential solutions (and your opinions on their
|
||||
> merits).
|
||||
|
||||
## Feature requests
|
||||
|
||||
Feature requests are welcome. But take a moment to find out whether your idea
|
||||
fits with the scope and aims of the project. It's up to *you* to make a strong
|
||||
case to convince the project's developers of the merits of this feature. Please
|
||||
provide as much detail and context as possible.
|
||||
|
||||
|
||||
## Pull requests
|
||||
|
||||
Good pull requests—patches, improvements, new features—are a fantastic
|
||||
help. They should remain focused in scope and avoid containing unrelated
|
||||
commits.
|
||||
|
||||
**Please ask first** before embarking on any significant pull request (e.g.
|
||||
implementing features, refactoring code, porting to a different language),
|
||||
otherwise you risk spending a lot of time working on something that the
|
||||
project's developers might not want to merge into the project.
|
||||
|
||||
Please adhere to the [coding guidelines](#code-guidelines) used throughout the
|
||||
project (indentation, accurate comments, etc.) and any other requirements
|
||||
(such as test coverage).
|
||||
|
||||
Adhering to the following process is the best way to get your work
|
||||
included in the project:
|
||||
|
||||
1. Download, clone or [Fork](https://help.github.com/articles/fork-a-repo/) the project, using [https://github.com/informatik-ag-ngl/envoy-common/](https://github.com/informatik-ag-ngl/envoy-common/)as Remote.
|
||||
|
||||
2. If you cloned a while ago, get the latest changes from upstream:
|
||||
|
||||
```bash
|
||||
git checkout master
|
||||
git pull upstream master
|
||||
```
|
||||
Or, if your IDE of choice supports this, simply use `pull`
|
||||
|
||||
3. Create a new topic branch (off the main project development branch) to
|
||||
contain your feature, change, or fix:
|
||||
|
||||
```bash
|
||||
git checkout -b <topic-branch-name>
|
||||
```
|
||||
Or, simply use "New branch" if your IDE supports this
|
||||
|
||||
4. Commit your changes in logical chunks. Please adhere to these [git commit
|
||||
message guidelines](https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)
|
||||
or your code is unlikely be merged into the main project. Use Git's
|
||||
[interactive rebase](https://help.github.com/articles/about-git-rebase/)
|
||||
feature to tidy up your commits before making them public.
|
||||
|
||||
5. Locally merge (or rebase) the upstream development branch into your topic branch:
|
||||
|
||||
```bash
|
||||
git pull [--rebase] upstream master
|
||||
```
|
||||
|
||||
6. Push your topic branch up to your fork:
|
||||
|
||||
```bash
|
||||
git push origin <topic-branch-name>
|
||||
```
|
||||
|
||||
7. [Open a Pull Request](https://help.github.com/articles/about-pull-requests/)
|
||||
with a clear title and description against the `master` branch.
|
||||
|
||||
**IMPORTANT**: By submitting a patch, you agree to allow the project owners to
|
||||
license your work under the terms of the [MIT License](../LICENSE) (if it
|
||||
includes code changes) and under the terms of the
|
||||
[Creative Commons Attribution 3.0 Unported License](https://creativecommons.org/licenses/by/3.0/)
|
||||
(if it includes documentation changes).
|
||||
|
||||
|
||||
## Code guidelines
|
||||
|
||||
### Java
|
||||
|
||||
Please use the formatter provided with this project. Especially before saving. For best results, select the option "format code" in the "Save Actions" tab in Preferences in Eclipse, so that you never accidentally forget it.
|
||||
Every public function (not annotated with `@Override`) must be delivered with Javadoc. For best project-appropriate Javadoc please take a look at the other functions which are all already equipped with Javadoc.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
By contributing your code, you agree to license your contribution under the [MIT License](../LICENSE).
|
||||
By contributing to the documentation, you agree to license your contribution under the [Creative Commons Attribution 3.0 Unported License](https://creativecommons.org/licenses/by/3.0/).
|
21
LICENSE
Normal file
21
LICENSE
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019 Informatik-AG (NGL)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
25
README.md
Normal file
25
README.md
Normal file
@ -0,0 +1,25 @@
|
||||
# Envoy Common
|
||||
|
||||
<a href="https://github.com/informatik-ag-ngl/envoy-client"><img src="https://raw.githubusercontent.com/informatik-ag-ngl/envoy-client/develop/src/main/resources/icons/envoy_logo.png" align="left" width="200" height="200"></a>
|
||||
|
||||
**Envoy Common** is a library required to build the client and server of the messenger Envoy.<br>
|
||||
<br><br><br><br><br><br><br>
|
||||
|
||||
## Features
|
||||
|
||||
Envoy Common consists of all classes that are used both on client side and the server side, thus making them "common".
|
||||
Currently used features are:
|
||||
|
||||
* Messages
|
||||
* Users
|
||||
* LoginCredentials
|
||||
* Logging
|
||||
* Event System
|
||||
* EnvoyException
|
||||
|
||||
## Resources
|
||||
|
||||
* [API Reference (later on)](https://github.com/informatik-ag-ngl/envoy-common/wiki)
|
||||
* [Release Notes](https://github.com/informatik-ag-ngl/envoy-common/releases)
|
||||
* [Gallery (later on)](https://github.com/informatik-ag-ngl/envoy-common/wiki/Gallery)
|
||||
* [Wiki](https://github.com/informatik-ag-ngl/envoy-common/wiki)
|
73
pom.xml
Normal file
73
pom.xml
Normal file
@ -0,0 +1,73 @@
|
||||
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>informatik-ag-ngl</groupId>
|
||||
<artifactId>envoy-common</artifactId>
|
||||
<version>0.1-beta</version>
|
||||
|
||||
<name>Envoy Common</name>
|
||||
<url>https://github.com/informatik-ag-ngl/envoy-common</url>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<version>5.5.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<finalName>envoy-common</finalName>
|
||||
|
||||
<!-- Disable resource folder -->
|
||||
<resources />
|
||||
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>3.2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.1.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<doclint>none</doclint>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
84
src/main/java/envoy/data/Attachment.java
Normal file
84
src/main/java/envoy/data/Attachment.java
Normal file
@ -0,0 +1,84 @@
|
||||
package envoy.data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* This interface should be used for any type supposed to be a {@link Message}
|
||||
* attachment (i.e. images or sound).
|
||||
* <p>
|
||||
* Project: <strong>envoy-common</strong><br>
|
||||
* File: <strong>Attachment.java</strong><br>
|
||||
* Created: <strong>30 Dec 2019</strong><br>
|
||||
*
|
||||
* @author Leon Hofmeister
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public class Attachment implements Serializable {
|
||||
|
||||
/**
|
||||
* Defines the type of the attachment.
|
||||
*
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public enum AttachmentType {
|
||||
|
||||
/**
|
||||
* This attachment type denotes a picture.
|
||||
*
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
PICTURE,
|
||||
|
||||
|
||||
/**
|
||||
* This attachment type denotes a video.
|
||||
*
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
VIDEO,
|
||||
|
||||
/**
|
||||
* This attachment type denotes a voice message.
|
||||
*
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
VOICE,
|
||||
|
||||
/**
|
||||
* This attachment type denotes a document.
|
||||
*
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
DOCUMENT
|
||||
}
|
||||
|
||||
private final byte[] data;
|
||||
private final AttachmentType type;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Constructs an attachment.
|
||||
*
|
||||
* @param data the data of the attachment
|
||||
* @param type the type of the attachment
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public Attachment(byte[] data, AttachmentType type) {
|
||||
this.data = data;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the data of the attachment
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public byte[] getData() { return data; }
|
||||
|
||||
/**
|
||||
* @return the type of the attachment
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public AttachmentType getType() { return type; }
|
||||
}
|
86
src/main/java/envoy/data/Config.java
Normal file
86
src/main/java/envoy/data/Config.java
Normal file
@ -0,0 +1,86 @@
|
||||
package envoy.data;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import envoy.exception.EnvoyException;
|
||||
|
||||
/**
|
||||
* Manages all application settings that are set during application startup by
|
||||
* either loading them from the {@link Properties} file
|
||||
* {@code client.properties} or parsing them from the command line arguments of
|
||||
* the application.<br>
|
||||
* <br>
|
||||
* Project: <strong>envoy-client</strong><br>
|
||||
* File: <strong>Config.java</strong><br>
|
||||
* Created: <strong>12 Oct 2019</strong><br>
|
||||
*
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public class Config {
|
||||
|
||||
protected Map<String, ConfigItem<?>> items = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Parses config items from a properties object.
|
||||
*
|
||||
* @param properties the properties object to parse
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public void load(Properties properties) {
|
||||
items.entrySet()
|
||||
.stream()
|
||||
.filter(e -> properties.containsKey(e.getKey()))
|
||||
.forEach(e -> e.getValue().parse(properties.getProperty(e.getKey())));
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses config items from an array of command line arguments.
|
||||
*
|
||||
* @param args the command line arguments to parse
|
||||
* @throws EnvoyException if the command line arguments contain an unknown token
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public void load(String[] args) throws EnvoyException {
|
||||
for (int i = 0; i < args.length; i++)
|
||||
for (ConfigItem<?> item : items.values())
|
||||
if (args[i].startsWith("--")) {
|
||||
if (args[i].length() == 2) throw new EnvoyException("Malformed command line argument at position " + i);
|
||||
final String commandLong = args[i].substring(2);
|
||||
if (item.getCommandLong().equals(commandLong)) {
|
||||
item.parse(args[++i]);
|
||||
break;
|
||||
}
|
||||
} else if (args[i].startsWith("-")) {
|
||||
if (args[i].length() == 1) throw new EnvoyException("Malformed command line argument at position " + i);
|
||||
final String commandShort = args[i].substring(1);
|
||||
if (item.getCommandShort().equals(commandShort)) {
|
||||
item.parse(args[++i]);
|
||||
break;
|
||||
}
|
||||
} else throw new EnvoyException("Malformed command line argument at position " + i);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes config items from a map.
|
||||
*
|
||||
* @param items the items to include in this config
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public void load(Map<String, ConfigItem<?>> items) { this.items.putAll(items); }
|
||||
|
||||
/**
|
||||
* @return {@code true} if all mandatory config items are initialized
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public boolean isInitialized() {
|
||||
return items.values().stream().filter(ConfigItem::isMandatory).map(ConfigItem::get).noneMatch(Objects::isNull);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name the name of the config item to return
|
||||
* @return the config item with the specified name
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public ConfigItem<?> get(String name) { return items.get(name); }
|
||||
}
|
92
src/main/java/envoy/data/ConfigItem.java
Normal file
92
src/main/java/envoy/data/ConfigItem.java
Normal file
@ -0,0 +1,92 @@
|
||||
package envoy.data;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Contains a single {@link Config} value as well as the corresponding command
|
||||
* line arguments and its default value.<br>
|
||||
* <br>
|
||||
* Project: <strong>envoy-clientChess</strong><br>
|
||||
* File: <strong>ConfigItem.javaEvent.java</strong><br>
|
||||
* Created: <strong>21.12.2019</strong><br>
|
||||
*
|
||||
* @author Kai S. K. Engelbart
|
||||
* @param <T> the type of the config item's value
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public class ConfigItem<T> {
|
||||
|
||||
private final String commandLong, commandShort;
|
||||
private final Function<String, T> parseFunction;
|
||||
private final boolean mandatory;
|
||||
|
||||
private T value;
|
||||
|
||||
/**
|
||||
* Initializes a {@link ConfigItem}.
|
||||
*
|
||||
* @param commandLong the long command line argument to set this value
|
||||
* @param commandShort the short command line argument to set this value
|
||||
* @param parseFunction the {@code Function<String, T>} that parses the value
|
||||
* from a string
|
||||
* @param defaultValue the optional default value to set before parsing
|
||||
* @param mandatory indicated that this config item must be initialized with
|
||||
* a non-null value
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public ConfigItem(String commandLong, String commandShort, Function<String, T> parseFunction, T defaultValue, boolean mandatory) {
|
||||
this.commandLong = commandLong;
|
||||
this.commandShort = commandShort;
|
||||
this.parseFunction = parseFunction;
|
||||
this.mandatory = mandatory;
|
||||
value = defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes an optional {@link ConfigItem} without a default value.
|
||||
*
|
||||
* @param commandLong the long command line argument to set this value
|
||||
* @param commandShort the short command line argument to set this value
|
||||
* @param parseFunction the {@code Function<String, T>} that parses the value
|
||||
* from a string
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public ConfigItem(String commandLong, String commandShort, Function<String, T> parseFunction) {
|
||||
this(commandLong, commandShort, parseFunction, null, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses this {@ConfigItem}'s value from a string.
|
||||
*
|
||||
* @param input the string to parse from
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public void parse(String input) { value = parseFunction.apply(input); }
|
||||
|
||||
/**
|
||||
* @return The long command line argument to set the value of this
|
||||
* {@link ConfigItem}
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public String getCommandLong() { return commandLong; }
|
||||
|
||||
/**
|
||||
* @return The short command line argument to set the value of this
|
||||
* {@link ConfigItem}
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public String getCommandShort() { return commandShort; }
|
||||
|
||||
/**
|
||||
* @return the value of this {@link ConfigItem}
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public T get() { return value; }
|
||||
|
||||
/**
|
||||
* @return {@code true} if this {@link ConfigItem} is mandatory for successful
|
||||
* application initialization
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public boolean isMandatory() { return mandatory; }
|
||||
}
|
91
src/main/java/envoy/data/Contact.java
Normal file
91
src/main/java/envoy/data/Contact.java
Normal file
@ -0,0 +1,91 @@
|
||||
package envoy.data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* This class is the superclass for both {@link User} and {@link Group}.<br>
|
||||
* It provides an id and a name for each user and group.<br>
|
||||
* <br>
|
||||
* Project: <strong>envoy-common</strong><br>
|
||||
* File: <strong>Contact.java</strong><br>
|
||||
* Created: <strong>24 Mar 2020</strong><br>
|
||||
*
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy v0.1-beta
|
||||
*/
|
||||
public abstract class Contact implements Serializable {
|
||||
|
||||
private final long id;
|
||||
private final transient Set<? extends Contact> contacts;
|
||||
private String name;
|
||||
|
||||
private static final long serialVersionUID = 0L;
|
||||
|
||||
/**
|
||||
* Creates a new instance of a {@link Contact}.
|
||||
*
|
||||
* @param id the ID of this contact
|
||||
* @param name the name of this contact
|
||||
* @param contacts the contacts of this {@link Contact}
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public Contact(long id, String name, Set<? extends Contact> contacts) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.contacts = contacts;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ID of this {@link Contact}
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public long getID() { return id; }
|
||||
|
||||
/**
|
||||
* @return the name of this {@link Contact}
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public String getName() { return name; }
|
||||
|
||||
/**
|
||||
* @param name the new name of this {@link Contact}
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public void setName(String name) { this.name = name; }
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String toString() { return String.format("Contact[id=%d,name=%s, contacts=%s]", id, name, contacts); }
|
||||
|
||||
/**
|
||||
* Provides a hash code based on the ID of this contact.
|
||||
*
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() { return Objects.hash(id); }
|
||||
|
||||
/**
|
||||
* Tests equality to another object. If that object is a contact as well,
|
||||
* equality is determined by the ID.
|
||||
*
|
||||
* @param obj the object to test for equality to this contact
|
||||
* @return {code true} if both objects are contacts and have identical IDs
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (!(obj instanceof Contact)) return false;
|
||||
return id == ((Contact) obj).id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the contacts of this {@link Contact}
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public Set<? extends Contact> getContacts() { return contacts; }
|
||||
}
|
55
src/main/java/envoy/data/Group.java
Normal file
55
src/main/java/envoy/data/Group.java
Normal file
@ -0,0 +1,55 @@
|
||||
package envoy.data;
|
||||
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Project: <strong>envoy-common</strong><br>
|
||||
* File: <strong>Group.java</strong><br>
|
||||
* Created: <strong>24 Mar 2020</strong><br>
|
||||
*
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public final class Group extends Contact {
|
||||
|
||||
private static final long serialVersionUID = 0L;
|
||||
|
||||
/**
|
||||
* Creates a new instance of a {@link Group} without any members.
|
||||
*
|
||||
* @param id the ID of this group
|
||||
* @param name the name of this group
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public Group(long id, String name) { this(id, name, new HashSet<User>()); }
|
||||
|
||||
/**
|
||||
* Creates an instance of a {@link Group}.
|
||||
*
|
||||
* @param id the ID of this group
|
||||
* @param name the name of this group
|
||||
* @param members all members that should be preinitialized
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public Group(long id, String name, Set<User> members) { super(id, name, members); }
|
||||
|
||||
private void readObject(ObjectInputStream inputStream) throws Exception {
|
||||
inputStream.defaultReadObject();
|
||||
var contacts = Contact.class.getDeclaredField("contacts");
|
||||
contacts.setAccessible(true);
|
||||
contacts.set(this, inputStream.readObject());
|
||||
}
|
||||
|
||||
private void writeObject(ObjectOutputStream outputStream) throws Exception {
|
||||
outputStream.defaultWriteObject();
|
||||
getContacts().forEach(user -> user.serializeContacts(false));
|
||||
outputStream.writeObject(getContacts());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Set<User> getContacts() { return (Set<User>) super.getContacts(); }
|
||||
}
|
71
src/main/java/envoy/data/GroupMessage.java
Normal file
71
src/main/java/envoy/data/GroupMessage.java
Normal file
@ -0,0 +1,71 @@
|
||||
package envoy.data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Project: <strong>envoy-common</strong><br>
|
||||
* File: <strong>GroupMessage.java</strong><br>
|
||||
* Created: <strong>26.03.2020</strong><br>
|
||||
*
|
||||
* @author Maximilian Käfer
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public final class GroupMessage extends Message {
|
||||
|
||||
private final Map<Long, MessageStatus> memberStatuses;
|
||||
|
||||
private static final long serialVersionUID = 0L;
|
||||
|
||||
/**
|
||||
* Initializes a {@link GroupMessage} with values for all of its properties. The
|
||||
* use
|
||||
* of this constructor is only intended for the {@link MessageBuilder} class, as
|
||||
* this class provides {@code null} checks and default values for all
|
||||
* properties.
|
||||
*
|
||||
* @param id unique ID
|
||||
* @param senderID the ID of the user who sends the message
|
||||
* @param groupID the ID of the group which receives the message
|
||||
* @param creationDate the creation date of the message
|
||||
* @param receivedDate the received date of the message
|
||||
* @param readDate the read date of the message
|
||||
* @param text the text content of the message
|
||||
* @param attachment the attachment of the message, if present
|
||||
* @param status the current {@link Message.MessageStatus} of the
|
||||
* message
|
||||
* @param forwarded whether this message was forwarded
|
||||
* @param memberStatuses a map of all members and their status according to this
|
||||
* {@link GroupMessage}
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
GroupMessage(long id, long senderID, long groupID, LocalDateTime creationDate, LocalDateTime receivedDate, LocalDateTime readDate, String text,
|
||||
Attachment attachment, MessageStatus status, boolean forwarded, Map<Long, MessageStatus> memberStatuses) {
|
||||
super(id, senderID, groupID, creationDate, receivedDate, readDate, text, attachment, status, forwarded);
|
||||
this.memberStatuses = memberStatuses;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the status to be the minimum of all members.
|
||||
*
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public void updateStatus() {
|
||||
setStatus(Collections.min(memberStatuses.values()));
|
||||
switch (getStatus()) {
|
||||
case RECEIVED:
|
||||
setReceivedDate(LocalDateTime.now());
|
||||
break;
|
||||
case READ:
|
||||
setReadDate(LocalDateTime.now());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the map of all statuses in this {@link GroupMessage}
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public Map<Long, MessageStatus> getMemberStatuses() { return memberStatuses; }
|
||||
}
|
51
src/main/java/envoy/data/IDGenerator.java
Normal file
51
src/main/java/envoy/data/IDGenerator.java
Normal file
@ -0,0 +1,51 @@
|
||||
package envoy.data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Generates increasing IDs between two numbers.<br>
|
||||
* <br>
|
||||
* Project: <strong>envoy-common</strong><br>
|
||||
* File: <strong>IDGenerator.java</strong><br>
|
||||
* Created: <strong>31.12.2019</strong><br>
|
||||
*
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public class IDGenerator implements Serializable {
|
||||
|
||||
private final long end;
|
||||
private long current;
|
||||
|
||||
private static final long serialVersionUID = 0L;
|
||||
|
||||
/**
|
||||
* Creates an instance of {@link IDGenerator}.
|
||||
*
|
||||
* @param begin the first ID
|
||||
* @param size the amount of IDs to provide
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public IDGenerator(long begin, long size) {
|
||||
current = begin;
|
||||
end = begin + size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() { return String.format("IDGenerator[current=%d,end=%d]", current, end); }
|
||||
|
||||
/**
|
||||
* @return {@code true} if there are unused IDs remaining
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public boolean hasNext() { return current < end; }
|
||||
|
||||
/**
|
||||
* @return the next ID
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public long next() {
|
||||
if (!hasNext()) throw new IllegalStateException("All IDs have been used");
|
||||
return current++;
|
||||
}
|
||||
}
|
69
src/main/java/envoy/data/LoginCredentials.java
Normal file
69
src/main/java/envoy/data/LoginCredentials.java
Normal file
@ -0,0 +1,69 @@
|
||||
package envoy.data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Contains a {@link User}'s login / registration information as well as the
|
||||
* client version.
|
||||
* <p>
|
||||
* Project: <strong>envoy-common</strong><br>
|
||||
* File: <strong>LoginCredentials.java</strong><br>
|
||||
* Created: <strong>29.12.2019</strong><br>
|
||||
*
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public final class LoginCredentials implements Serializable {
|
||||
|
||||
private final String identifier, password, clientVersion;
|
||||
private final boolean registration;
|
||||
|
||||
private static final long serialVersionUID = 2;
|
||||
|
||||
/**
|
||||
* Initializes login credentials for a handshake.
|
||||
*
|
||||
* @param identifier the identifier of the user
|
||||
* @param password the password of the user
|
||||
* @param registration signifies that these credentials are used for user
|
||||
* registration instead of user login
|
||||
* @param clientVersion the version of the client sending these credentials
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public LoginCredentials(String identifier, String password, boolean registration, String clientVersion) {
|
||||
this.identifier = identifier;
|
||||
this.password = password;
|
||||
this.registration = registration;
|
||||
this.clientVersion = clientVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("LoginCredentials[identifier=%s,registration=%b,clientVersion=%s]", identifier, registration, clientVersion);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the identifier of the user performing the login
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public String getIdentifier() { return identifier; }
|
||||
|
||||
/**
|
||||
* @return the password of the user performing the login
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public String getPassword() { return password; }
|
||||
|
||||
/**
|
||||
* @return {@code true} if these credentials are used for user registration
|
||||
* instead of user login
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public boolean isRegistration() { return registration; }
|
||||
|
||||
/**
|
||||
* @return the version of the client sending these credentials
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public String getClientVersion() { return clientVersion; }
|
||||
}
|
212
src/main/java/envoy/data/Message.java
Normal file
212
src/main/java/envoy/data/Message.java
Normal file
@ -0,0 +1,212 @@
|
||||
package envoy.data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
/**
|
||||
* Represents a unique message with a unique, numeric ID. Further metadata
|
||||
* includes the sender and recipient {@link User}s, as well as the creation
|
||||
* date and the current {@link MessageStatus}.<br>
|
||||
* <br>
|
||||
* Project: <strong>envoy-common</strong><br>
|
||||
* File: <strong>Message.java</strong><br>
|
||||
* Created: <strong>28.12.2019</strong><br>
|
||||
*
|
||||
* @author Kai S. K. Engelbart
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public class Message implements Serializable {
|
||||
|
||||
/**
|
||||
* This enumeration defines all possible statuses a {link Message} can have.
|
||||
*
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public enum MessageStatus {
|
||||
|
||||
/**
|
||||
* is selected, if a message was sent but not received by the server yet.
|
||||
*/
|
||||
WAITING,
|
||||
|
||||
/**
|
||||
* is selected, if a sent message was received by the server.
|
||||
*/
|
||||
SENT,
|
||||
|
||||
/**
|
||||
* is selected, if a message was delivered from the server to the recipient, but
|
||||
* has not been read yet.
|
||||
*/
|
||||
RECEIVED,
|
||||
|
||||
/**
|
||||
* is selected, if a recipient opened the corresponding chat of said message.
|
||||
*/
|
||||
READ
|
||||
}
|
||||
|
||||
private final long id, senderID, recipientID;
|
||||
private final boolean forwarded;
|
||||
private final LocalDateTime creationDate;
|
||||
private final String text;
|
||||
private final Attachment attachment;
|
||||
|
||||
private LocalDateTime receivedDate, readDate;
|
||||
private MessageStatus status;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Initializes a {@link Message} with values for all of its properties. The use
|
||||
* of this constructor is only intended for the {@link MessageBuilder} class, as
|
||||
* this class provides {@code null} checks and default values for all
|
||||
* properties.
|
||||
*
|
||||
* @param id unique ID
|
||||
* @param senderID the ID of the user who sends the message
|
||||
* @param recipientID the ID of the user who receives the message
|
||||
* @param creationDate the creation date of the message
|
||||
* @param receivedDate the received date of the message
|
||||
* @param readDate the read date of the message
|
||||
* @param text the text content of the message
|
||||
* @param attachment the attachment of the message, if present
|
||||
* @param status the current {@link MessageStatus} of the message
|
||||
* @param forwarded whether this message was forwarded
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
Message(long id, long senderID, long recipientID, LocalDateTime creationDate, LocalDateTime receivedDate, LocalDateTime readDate, String text,
|
||||
Attachment attachment, MessageStatus status, boolean forwarded) {
|
||||
this.id = id;
|
||||
this.senderID = senderID;
|
||||
this.recipientID = recipientID;
|
||||
this.creationDate = creationDate;
|
||||
this.receivedDate = receivedDate;
|
||||
this.readDate = readDate;
|
||||
this.text = text;
|
||||
this.attachment = attachment;
|
||||
this.status = status;
|
||||
this.forwarded = forwarded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the current {@link MessageStatus} to the next logical status.<br>
|
||||
* <br>
|
||||
* The underlying order is as follows:
|
||||
* <ol>
|
||||
* <li>{@link MessageStatus#WAITING}
|
||||
* <li>{@link MessageStatus#SENT}
|
||||
* <li>{@link MessageStatus#RECEIVED}
|
||||
* <li>{@link MessageStatus#READ}
|
||||
* </ol>
|
||||
*
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public void nextStatus() {
|
||||
if (status == MessageStatus.READ) throw new IllegalStateException("Message status READ is already reached");
|
||||
status = MessageStatus.values()[status.ordinal() + 1];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("Message[id=%d,sender=%s,recipient=%s,date=%s,status=%s,text=%s,forwarded=%b,hasAttachment=%b]",
|
||||
id,
|
||||
senderID,
|
||||
recipientID,
|
||||
DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm:ss").format(creationDate),
|
||||
status,
|
||||
text,
|
||||
forwarded,
|
||||
attachment != null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ID of this message
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public long getID() { return id; }
|
||||
|
||||
/**
|
||||
* @return the sender ID of this message
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public long getSenderID() { return senderID; }
|
||||
|
||||
/**
|
||||
* @return the recipient ID of this message
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public long getRecipientID() { return recipientID; }
|
||||
|
||||
/**
|
||||
* @return the date at which this message was created
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public LocalDateTime getCreationDate() { return creationDate; }
|
||||
|
||||
/**
|
||||
* @return the date at which the message has been received by the sender
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public LocalDateTime getReceivedDate() { return receivedDate; }
|
||||
|
||||
/**
|
||||
* @param receivedDate the date at which the message has been received by the
|
||||
* sender
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public void setReceivedDate(LocalDateTime receivedDate) { this.receivedDate = receivedDate; }
|
||||
|
||||
/**
|
||||
* @return the date at which the message has been read by the sender
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public LocalDateTime getReadDate() { return readDate; }
|
||||
|
||||
/**
|
||||
* @param readDate at which the message has been read by the sender
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public void setReadDate(LocalDateTime readDate) { this.readDate = readDate; }
|
||||
|
||||
/**
|
||||
* @return the text content of this message
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public String getText() { return text; }
|
||||
|
||||
/**
|
||||
* @return the messageAttachment
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public Attachment getAttachment() { return attachment; }
|
||||
|
||||
/**
|
||||
* @return {@code true} if an attachment is present
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public boolean hasAttachment() { return attachment != null; }
|
||||
|
||||
/**
|
||||
* @return the current status of this message
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public MessageStatus getStatus() { return status; }
|
||||
|
||||
/**
|
||||
* @param status the new {@link MessageStatus}, if permitted
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public void setStatus(MessageStatus status) {
|
||||
if (status.ordinal() < this.status.ordinal()) throw new IllegalStateException("This message is moving backwards in time");
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return whether this message was forwarded
|
||||
* @since Envoy common v0.1-beta
|
||||
*/
|
||||
public boolean isForwarded() { return forwarded; }
|
||||
}
|
240
src/main/java/envoy/data/MessageBuilder.java
Normal file
240
src/main/java/envoy/data/MessageBuilder.java
Normal file
@ -0,0 +1,240 @@
|
||||
package envoy.data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import envoy.data.Message.MessageStatus;
|
||||
|
||||
/**
|
||||
* Provides a method of constructing the {@link Message} class.<br>
|
||||
* <br>
|
||||
* Project: <strong>envoy-common</strong><br>
|
||||
* File: <strong>MessageBuilder.java</strong><br>
|
||||
* Created: <strong>31.12.2019</strong><br>
|
||||
*
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public class MessageBuilder {
|
||||
|
||||
// Mandatory properties without default values
|
||||
private final long senderID, recipientID;
|
||||
|
||||
// Properties with default values
|
||||
private long id;
|
||||
private LocalDateTime creationDate, receivedDate, readDate;
|
||||
private String text;
|
||||
private Attachment attachment;
|
||||
private Message.MessageStatus status;
|
||||
private boolean forwarded;
|
||||
|
||||
/**
|
||||
* Creates an instance of {@link MessageBuilder} with all mandatory values
|
||||
* without defaults for the {@link Message} class.
|
||||
*
|
||||
* @param senderID the ID of the user who sends the {@link Message}
|
||||
* @param recipientID the ID of the user who receives the {@link Message}
|
||||
* @param idGenerator the ID generator used to generate a unique {@link Message}
|
||||
* id
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public MessageBuilder(long senderID, long recipientID, IDGenerator idGenerator) { this(senderID, recipientID, idGenerator.next()); }
|
||||
|
||||
/**
|
||||
* Creates an instance of {@link MessageBuilder} with all mandatory values
|
||||
* without defaults for the {@link Message} class.
|
||||
*
|
||||
* @param senderID the ID of the user who sends the {@link Message}
|
||||
* @param recipientID the ID of the user who receives the {@link Message}
|
||||
* @param messageId the ID of the {@link Message}
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public MessageBuilder(long senderID, long recipientID, long messageId) {
|
||||
this.senderID = senderID;
|
||||
this.recipientID = recipientID;
|
||||
id = messageId;
|
||||
}
|
||||
|
||||
/**
|
||||
* This constructor transforms a given {@link Message} into a new message for a
|
||||
* new receiver.
|
||||
* This makes it especially useful in the case of forwarding messages.
|
||||
*
|
||||
* @param msg the message to copy
|
||||
* @param recipientID the ID of the user who receives the {@link Message}
|
||||
* @param iDGenerator the ID generator used to generate a unique {@link Message}
|
||||
* id
|
||||
* @since Envoy v0.1-beta
|
||||
*/
|
||||
public MessageBuilder(Message msg, long recipientID, IDGenerator iDGenerator) {
|
||||
this(msg.getRecipientID(), recipientID, iDGenerator.next());
|
||||
this.attachment = msg.getAttachment();
|
||||
this.creationDate = LocalDateTime.now();
|
||||
this.forwarded = true;
|
||||
this.text = msg.getText();
|
||||
this.status = MessageStatus.WAITING;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an instance of {@link Message} with the previously supplied values.
|
||||
* If a mandatory value is not set, a default value will be used instead:<br>
|
||||
* <br>
|
||||
* <table border="1">
|
||||
* <tr>
|
||||
* <td>{@code date}</td>
|
||||
* <td>{@code LocalDateTime.now()} and {@code null} for {@code receivedDate} and
|
||||
* {@code readDate}</td>
|
||||
* <tr>
|
||||
* <tr>
|
||||
* <td>{@code text}</td>
|
||||
* <td>{@code ""}</td>
|
||||
* <tr>
|
||||
* <tr>
|
||||
* <td>{@code status}</td>
|
||||
* <td>{@code MessageStatus.WAITING}</td>
|
||||
* <tr>
|
||||
* </table>
|
||||
*
|
||||
* @return a new instance of {@link Message}
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public Message build() {
|
||||
supplyDefaults();
|
||||
return new Message(id, senderID, recipientID, creationDate, receivedDate, readDate, text, attachment, status, forwarded);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an instance of {@link GroupMessage} with the previously supplied
|
||||
* values. <br>
|
||||
* <b> Sets all member statuses to {@link MessageStatus#WAITING}.</b><br>
|
||||
* If a mandatory value is not set, a default value will be used
|
||||
* instead:<br>
|
||||
* <br>
|
||||
* <table border="1">
|
||||
* <tr>
|
||||
* <td>{@code date}</td>
|
||||
* <td>{@code new Date()}</td>
|
||||
* <tr>
|
||||
* <tr>
|
||||
* <td>{@code text}</td>
|
||||
* <td>{@code ""}</td>
|
||||
* <tr>
|
||||
* </table>
|
||||
*
|
||||
* @param group the {@link Group} that is used to fill the map of member
|
||||
* statuses
|
||||
* @return a new instance of {@link GroupMessage}
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public GroupMessage buildGroupMessage(Group group) {
|
||||
var memberStatuses = new HashMap<Long, Message.MessageStatus>();
|
||||
group.getContacts().forEach(user -> memberStatuses.put(user.getID(), MessageStatus.WAITING));
|
||||
return buildGroupMessage(group, memberStatuses);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an instance of {@link GroupMessage} with the previously supplied
|
||||
* values. If a mandatory value is not set, a default value will be used
|
||||
* instead:<br>
|
||||
* <br>
|
||||
* <table border="1">
|
||||
* <tr>
|
||||
* <td>{@code date}</td>
|
||||
* <td>{@code new Date()}</td>
|
||||
* <tr>
|
||||
* <tr>
|
||||
* <td>{@code text}</td>
|
||||
* <td>{@code ""}</td>
|
||||
* <tr>
|
||||
* </table>
|
||||
*
|
||||
* @param group the {@link Group} that is used to fill the map of
|
||||
* member statuses
|
||||
* @param memberStatuses the map of all current statuses
|
||||
* @return a new instance of {@link GroupMessage}
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public GroupMessage buildGroupMessage(Group group, Map<Long, MessageStatus> memberStatuses) {
|
||||
if (group == null || memberStatuses == null) throw new NullPointerException();
|
||||
supplyDefaults();
|
||||
return new GroupMessage(id, senderID, recipientID, creationDate, receivedDate, readDate, text, attachment, status, forwarded, memberStatuses);
|
||||
}
|
||||
|
||||
private void supplyDefaults() {
|
||||
if (creationDate == null) creationDate = LocalDateTime.now();
|
||||
if (text == null) text = "";
|
||||
if (status == null) status = MessageStatus.WAITING;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param creationDate the creation date of the {@link Message} to create
|
||||
* @return this {@link MessageBuilder}
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public MessageBuilder setCreationDate(LocalDateTime creationDate) {
|
||||
this.creationDate = creationDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param receivedDate the received date of the {@link Message} to create
|
||||
* @return this {@link MessageBuilder}
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public MessageBuilder setReceivedDate(LocalDateTime receivedDate) {
|
||||
this.receivedDate = receivedDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param readDate the read date of the {@link Message} to create
|
||||
* @return this {@link MessageBuilder}
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public MessageBuilder setReadDate(LocalDateTime readDate) {
|
||||
this.readDate = readDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param text the text of the {@link Message} to create
|
||||
* @return this {@link MessageBuilder}
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public MessageBuilder setText(String text) {
|
||||
this.text = text;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param attachment the {@link Attachment} of the {@link Message} to
|
||||
* create
|
||||
* @return this {@link MessageBuilder}
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public MessageBuilder setAttachment(Attachment attachment) {
|
||||
this.attachment = attachment;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param status the {@link MessageStatus} of the {@link Message} to create
|
||||
* @return this {@link MessageBuilder}
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public MessageBuilder setStatus(Message.MessageStatus status) {
|
||||
this.status = status;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param forwarded sets whether this message is a forwarded message or not
|
||||
* @return this {@link MessageBuilder}
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public MessageBuilder setForwarded(boolean forwarded) {
|
||||
this.forwarded = forwarded;
|
||||
return this;
|
||||
}
|
||||
}
|
137
src/main/java/envoy/data/User.java
Normal file
137
src/main/java/envoy/data/User.java
Normal file
@ -0,0 +1,137 @@
|
||||
package envoy.data;
|
||||
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Represents a unique user with a unique, numeric ID, a name and a current
|
||||
* {@link UserStatus}.<br>
|
||||
* <br>
|
||||
* Project: <strong>envoy-common</strong><br>
|
||||
* File: <strong>User.java</strong><br>
|
||||
* Created: <strong>28.12.2019</strong><br>
|
||||
*
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public final class User extends Contact {
|
||||
|
||||
private UserStatus status;
|
||||
|
||||
/**
|
||||
* Used to serialize contact list to a maximum depth of one.
|
||||
*/
|
||||
private transient boolean serializeContacts = true;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* This enumeration defines all possible statuses a user can have.
|
||||
*
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public static enum UserStatus {
|
||||
|
||||
/**
|
||||
* select this, if a user is online and can be interacted with
|
||||
*/
|
||||
ONLINE,
|
||||
|
||||
/**
|
||||
* select this, if a user is online but unavailable at the moment (sudden
|
||||
* interruption)
|
||||
*/
|
||||
AWAY,
|
||||
|
||||
/**
|
||||
* select this, if a user is online but unavailable at the moment (polite way)
|
||||
*/
|
||||
BUSY,
|
||||
|
||||
/**
|
||||
* select this, if a user is offline
|
||||
*/
|
||||
OFFLINE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes a {@link User}. <br>
|
||||
* The {@link UserStatus} is set to {@link UserStatus#ONLINE}.
|
||||
* No contacts are initialized.
|
||||
*
|
||||
* @param id unique ID
|
||||
* @param name user name
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public User(long id, String name) {
|
||||
super(id, name, new HashSet<>());
|
||||
status = UserStatus.ONLINE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes a {@link User}. <br>
|
||||
* The {@link UserStatus} is set to {@link UserStatus#ONLINE}.
|
||||
*
|
||||
* @param id unique ID
|
||||
* @param name user name
|
||||
* @param contacts the contacts of this user
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public User(long id, String name, Set<Contact> contacts) {
|
||||
super(id, name, contacts);
|
||||
status = UserStatus.ONLINE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes a {@link User}.
|
||||
*
|
||||
* @param id unique ID
|
||||
* @param name user name
|
||||
* @param status the status of this user
|
||||
* @param contacts the contacts of this user
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public User(long id, String name, UserStatus status, Set<Contact> contacts) {
|
||||
super(id, name, contacts);
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() { return String.format("User[id=%d,name=%s,status=%s,contacts=%s]", getID(), getName(), status, getContacts()); }
|
||||
|
||||
/**
|
||||
* @return the current status of this user
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public UserStatus getStatus() { return status; }
|
||||
|
||||
/**
|
||||
* @param status the next status of this user
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public void setStatus(UserStatus status) { this.status = status; }
|
||||
|
||||
private void readObject(ObjectInputStream inputStream) throws Exception {
|
||||
inputStream.defaultReadObject();
|
||||
var contacts = Contact.class.getDeclaredField("contacts");
|
||||
contacts.setAccessible(true);
|
||||
contacts.set(this, inputStream.readObject());
|
||||
}
|
||||
|
||||
private void writeObject(ObjectOutputStream outputStream) throws Exception {
|
||||
outputStream.defaultWriteObject();
|
||||
if (serializeContacts) {
|
||||
getContacts().stream().filter(User.class::isInstance).map(User.class::cast).forEach(user -> user.serializeContacts = false);
|
||||
outputStream.writeObject(getContacts());
|
||||
} else outputStream.writeObject(new HashSet<>());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param serializeContacts whether the contacts of this {@link User} should be
|
||||
* serialized
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public void serializeContacts(boolean serializeContacts) { this.serializeContacts = serializeContacts; }
|
||||
}
|
10
src/main/java/envoy/data/package-info.java
Normal file
10
src/main/java/envoy/data/package-info.java
Normal file
@ -0,0 +1,10 @@
|
||||
/**
|
||||
* This package contains all data objects that are used both by Envoy Client and
|
||||
* by Envoy Server Standalone.
|
||||
*
|
||||
* @author Leon Hofmeister
|
||||
* @author Maximilian Käfer
|
||||
* @author Kai S.K. Engelbart
|
||||
* @since Envoy common v0.1-beta
|
||||
*/
|
||||
package envoy.data;
|
28
src/main/java/envoy/event/ElementOperation.java
Normal file
28
src/main/java/envoy/event/ElementOperation.java
Normal file
@ -0,0 +1,28 @@
|
||||
package envoy.event;
|
||||
|
||||
/**
|
||||
* This enum declares all modification possibilities for a given container.<br>
|
||||
* These can be: {@link ElementOperation#ADD} or
|
||||
* {@link ElementOperation#REMOVE}.<br>
|
||||
* <br>
|
||||
* Project: <strong>envoy-common</strong><br>
|
||||
* File: <strong>ElementOperation.java</strong><br>
|
||||
* Created: <strong>25 Mar 2020</strong><br>
|
||||
*
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public enum ElementOperation {
|
||||
|
||||
/**
|
||||
* Select this element, if the given element should be added to the given
|
||||
* container.
|
||||
*/
|
||||
ADD,
|
||||
|
||||
/**
|
||||
* Select this element, if the given element should be removed from the given
|
||||
* container.
|
||||
*/
|
||||
REMOVE
|
||||
}
|
49
src/main/java/envoy/event/Event.java
Normal file
49
src/main/java/envoy/event/Event.java
Normal file
@ -0,0 +1,49 @@
|
||||
package envoy.event;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Project: <strong>envoy-common</strong><br>
|
||||
* File: <strong>Event.java</strong><br>
|
||||
* Created: <strong>04.12.2019</strong><br>
|
||||
*
|
||||
* @author Kai S. K. Engelbart
|
||||
* @param <T> the type of the Event
|
||||
* @since Envoy v0.2-alpha
|
||||
*/
|
||||
public abstract class Event<T> implements Serializable {
|
||||
|
||||
protected final T value;
|
||||
|
||||
private static final long serialVersionUID = 0L;
|
||||
|
||||
protected Event(T value) { this.value = value; }
|
||||
|
||||
/**
|
||||
* @return the data associated with this event
|
||||
*/
|
||||
public T get() { return value; }
|
||||
|
||||
@Override
|
||||
public String toString() { return String.format("%s[value=%s]", this.getClass().getSimpleName(), value); }
|
||||
|
||||
/**
|
||||
* Serves as a super class for events that do not carry a value.<br>
|
||||
* <br>
|
||||
* Project: <strong>envoy-common</strong><br>
|
||||
* File: <strong>Event.java</strong><br>
|
||||
* Created: <strong>11 Feb 2020</strong><br>
|
||||
*
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public static abstract class Valueless extends Event<Void> {
|
||||
|
||||
private static final long serialVersionUID = 0L;
|
||||
|
||||
protected Valueless() { super(null); }
|
||||
|
||||
@Override
|
||||
public String toString() { return this.getClass().getSimpleName(); }
|
||||
}
|
||||
}
|
83
src/main/java/envoy/event/EventBus.java
Normal file
83
src/main/java/envoy/event/EventBus.java
Normal file
@ -0,0 +1,83 @@
|
||||
package envoy.event;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* This class handles events by allowing event handlers to register themselves
|
||||
* and then be notified about certain events dispatched by the event bus.<br>
|
||||
* <br>
|
||||
* The event bus is a singleton and can be used across the entire application to
|
||||
* guarantee the propagation of events.<br>
|
||||
* <br>
|
||||
* Project: <strong>envoy-common</strong><br>
|
||||
* File: <strong>EventBus.java</strong><br>
|
||||
* Created: <strong>04.12.2019</strong><br>
|
||||
*
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy v0.2-alpha
|
||||
*/
|
||||
public class EventBus {
|
||||
|
||||
/**
|
||||
* Contains all event handler instances registered at this event bus as values
|
||||
* mapped to by their supported event classes.
|
||||
*/
|
||||
private Map<Class<? extends Event<?>>, List<Consumer<Event<?>>>> handlers = new HashMap<>();
|
||||
|
||||
/**
|
||||
* The singleton instance of this event bus that is used across the
|
||||
* entire application.
|
||||
*/
|
||||
private static EventBus eventBus = new EventBus();
|
||||
|
||||
/**
|
||||
* This constructor is not accessible from outside this class because a
|
||||
* singleton instance of it is provided by the {@link EventBus#getInstance()}
|
||||
* method.
|
||||
*/
|
||||
private EventBus() {}
|
||||
|
||||
/**
|
||||
* @return the singleton instance of the event bus
|
||||
* @since Envoy v0.2-alpha
|
||||
*/
|
||||
public static EventBus getInstance() { return eventBus; }
|
||||
|
||||
/**
|
||||
* Registers an event handler to be notified when an
|
||||
* event of a certain type is dispatched.
|
||||
*
|
||||
* @param <T> the type of event values to notify the handler about
|
||||
* @param eventClass the class which the event handler is subscribing to
|
||||
* @param handler the event handler to register
|
||||
* @since Envoy v0.2-alpha
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends Event<?>> void register(Class<T> eventClass, Consumer<T> handler) {
|
||||
if (!handlers.containsKey(eventClass)) handlers.put(eventClass, new ArrayList<>());
|
||||
handlers.get(eventClass).add((Consumer<Event<?>>) handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatches an event to every event handler subscribed to it.
|
||||
*
|
||||
* @param event the {@link Event} to dispatch
|
||||
* @since Envoy v0.2-alpha
|
||||
*/
|
||||
public void dispatch(Event<?> event) {
|
||||
handlers.keySet()
|
||||
.stream()
|
||||
.filter(event.getClass()::equals)
|
||||
.map(handlers::get)
|
||||
.flatMap(List::stream)
|
||||
.forEach(h -> h.accept(event));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a map of all event handler instances currently registered at this
|
||||
* event bus with the event classes they are subscribed to as keys
|
||||
* @since Envoy v0.2-alpha
|
||||
*/
|
||||
public Map<Class<? extends Event<?>>, List<Consumer<Event<?>>>> getHandlers() { return handlers; }
|
||||
}
|
42
src/main/java/envoy/event/GroupCreation.java
Normal file
42
src/main/java/envoy/event/GroupCreation.java
Normal file
@ -0,0 +1,42 @@
|
||||
package envoy.event;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import envoy.data.User;
|
||||
|
||||
/**
|
||||
* This event creates a group with the given name.<br>
|
||||
* <br>
|
||||
* Project: <strong>envoy-common</strong><br>
|
||||
* File: <strong>GroupCreation.java</strong><br>
|
||||
* Created: <strong>25 Mar 2020</strong><br>
|
||||
*
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public class GroupCreation extends Event<String> {
|
||||
|
||||
private final Set<Long> initialMemberIDs;
|
||||
|
||||
private static final long serialVersionUID = 0L;
|
||||
|
||||
/**
|
||||
* @param value the name of this group at creation time
|
||||
* @param initialMemberIDs the IDs of all {@link User}s that should be group
|
||||
* members from the beginning on (excluding the creator
|
||||
* of this group)
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public GroupCreation(String value, Set<Long> initialMemberIDs) {
|
||||
super(value);
|
||||
this.initialMemberIDs = (initialMemberIDs != null) ? initialMemberIDs : new HashSet<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the IDs of all {@link User}s that are members from the beginning
|
||||
* (excluding the creator of this group)
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public Set<Long> getInitialMemberIDs() { return initialMemberIDs; }
|
||||
}
|
45
src/main/java/envoy/event/GroupMessageStatusChange.java
Normal file
45
src/main/java/envoy/event/GroupMessageStatusChange.java
Normal file
@ -0,0 +1,45 @@
|
||||
package envoy.event;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import envoy.data.GroupMessage;
|
||||
import envoy.data.Message.MessageStatus;
|
||||
|
||||
/**
|
||||
* Project: <strong>envoy-common</strong><br>
|
||||
* File: <strong>GroupMessageStatusChange.java</strong><br>
|
||||
* Created: <strong>18.04.2020</strong><br>
|
||||
*
|
||||
* @author Maximilian Käfer
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public class GroupMessageStatusChange extends MessageStatusChange {
|
||||
|
||||
private final long memberID;
|
||||
|
||||
private static final long serialVersionUID = 0L;
|
||||
|
||||
/**
|
||||
* Initializes a {@link GroupMessageStatusChange}.
|
||||
*
|
||||
* @param id the ID of the {@link GroupMessage} this event is related to
|
||||
* @param status the status of this specific members {@link GroupMessage}
|
||||
* @param date the date at which the MessageStatus change occurred for
|
||||
* this specific member
|
||||
* @param memberID the ID of the group member that caused the status change
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public GroupMessageStatusChange(long id, MessageStatus status, LocalDateTime date, long memberID) {
|
||||
super(id, status, date);
|
||||
this.memberID = memberID;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the memberID which the user who sends this event has
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public long getMemberID() { return memberID; }
|
||||
|
||||
@Override
|
||||
public String toString() { return String.format("GroupMessageStatusChange[meta=%s,memberID=%d]", super.toString(), memberID); }
|
||||
}
|
65
src/main/java/envoy/event/GroupResize.java
Normal file
65
src/main/java/envoy/event/GroupResize.java
Normal file
@ -0,0 +1,65 @@
|
||||
package envoy.event;
|
||||
|
||||
import envoy.data.Contact;
|
||||
import envoy.data.Group;
|
||||
import envoy.data.User;
|
||||
|
||||
/**
|
||||
* This event is used to communicate changes in the group size between client
|
||||
* and server.<br>
|
||||
* Possible actions are adding or removing certain {@link User}s to or from a
|
||||
* certain {@link Group}.
|
||||
* <br>
|
||||
* Project: <strong>envoy-common</strong><br>
|
||||
* File: <strong>GroupResize.java</strong><br>
|
||||
* Created: <strong>25 Mar 2020</strong><br>
|
||||
*
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public class GroupResize extends Event<User> {
|
||||
|
||||
private final long groupID;
|
||||
private final ElementOperation operation;
|
||||
|
||||
private static final long serialVersionUID = 0L;
|
||||
|
||||
/**
|
||||
* Initializes a {@link GroupResize} through a Contact where the name has
|
||||
* already been set.
|
||||
*
|
||||
* @param user the {@link User} who wants to join or leave a group
|
||||
* @param group the {@link Group} he wants to join or leave
|
||||
* @param operation describes what to do with the given user:<br>
|
||||
* add him to this group or remove him from it
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public GroupResize(User user, Group group, ElementOperation operation) {
|
||||
super(user);
|
||||
if (group.getContacts().contains(user)) {
|
||||
if (operation.equals(ElementOperation.ADD)) throw new IllegalArgumentException(
|
||||
"Cannot add " + user + " to group " + group.getID() + " because he is already a member of this group");
|
||||
} else if (operation.equals(ElementOperation.REMOVE))
|
||||
throw new IllegalArgumentException("Cannot remove " + user + " from group " + group.getID() + " because he is no part of this group");
|
||||
groupID = group.getID();
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ID of the {@link Contact} this event is related to
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public long getGroupID() { return groupID; }
|
||||
|
||||
/**
|
||||
* @return the operationType
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public ElementOperation getOperation() { return operation; }
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String toString() { return String.format("GroupResize[userid=%d,groupid=%d,operation=%s]", get(), groupID, operation); }
|
||||
}
|
63
src/main/java/envoy/event/HandshakeRejection.java
Normal file
63
src/main/java/envoy/event/HandshakeRejection.java
Normal file
@ -0,0 +1,63 @@
|
||||
package envoy.event;
|
||||
|
||||
/**
|
||||
* Signifies to the client that the handshake failed for the attached
|
||||
* reason.
|
||||
* <p>
|
||||
* Project: <strong>envoy-common</strong><br>
|
||||
* File: <strong>HandshakeRejection.java</strong><br>
|
||||
* Created: <strong>28 Jan 2020</strong><br>
|
||||
*
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Common v0.3-alpha
|
||||
*/
|
||||
public class HandshakeRejection extends Event<String> {
|
||||
|
||||
/**
|
||||
* Select this value if a given password hash or user name was incorrect.
|
||||
*
|
||||
* @since Envoy Common v0.3-alpha
|
||||
*/
|
||||
public static final String WRONG_PASSWORD_OR_USER = "Incorrect user name or password.";
|
||||
|
||||
/**
|
||||
* Select this value if a given user name for a registration is already taken.
|
||||
*
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public static final String USERNAME_TAKEN = "Incorrect user name or password.";
|
||||
|
||||
/**
|
||||
* Select this value if the version of the client is incompatible with the
|
||||
* server.
|
||||
*
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public static final String WRONG_VERSION = "Incompatible client version";
|
||||
|
||||
/**
|
||||
* Select this value if the handshake could not be completed for some different
|
||||
* reason.
|
||||
*
|
||||
* @since Envoy Common v0.3-alpha
|
||||
*/
|
||||
public static final String INTERNAL_ERROR = "An internal error occured.";
|
||||
|
||||
private static final long serialVersionUID = 0L;
|
||||
|
||||
/**
|
||||
* Creates an instance of {@link HandshakeRejection} with the generic
|
||||
* {@link HandshakeRejection#INTERNAL_ERROR} reason.
|
||||
*
|
||||
* @since Envoy Common v0.3-alpha
|
||||
*/
|
||||
public HandshakeRejection() { super(INTERNAL_ERROR); }
|
||||
|
||||
/**
|
||||
* Creates an instance of {@link HandshakeRejection}.
|
||||
*
|
||||
* @param reason the reason why the handshake was rejected
|
||||
* @since Envoy Common v0.3-alpha
|
||||
*/
|
||||
public HandshakeRejection(String reason) { super(reason); }
|
||||
}
|
17
src/main/java/envoy/event/IDGeneratorRequest.java
Normal file
17
src/main/java/envoy/event/IDGeneratorRequest.java
Normal file
@ -0,0 +1,17 @@
|
||||
package envoy.event;
|
||||
|
||||
/**
|
||||
* Signifies to the server that the client needs a new
|
||||
* {@link envoy.data.IDGenerator} instance.<br>
|
||||
* <br>
|
||||
* Project: <strong>envoy-common</strong><br>
|
||||
* File: <strong>IDGeneratorRequest.java</strong><br>
|
||||
* Created: <strong>28 Jan 2020</strong><br>
|
||||
*
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Common v0.3-alpha
|
||||
*/
|
||||
public class IDGeneratorRequest extends Event.Valueless {
|
||||
|
||||
private static final long serialVersionUID = 1431107413883364583L;
|
||||
}
|
59
src/main/java/envoy/event/MessageStatusChange.java
Normal file
59
src/main/java/envoy/event/MessageStatusChange.java
Normal file
@ -0,0 +1,59 @@
|
||||
package envoy.event;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import envoy.data.Message;
|
||||
|
||||
/**
|
||||
* Project: <strong>envoy-common</strong><br>
|
||||
* File: <strong>MessageStatusChange.java</strong><br>
|
||||
* Created: <strong>6 Jan 2020</strong><br>
|
||||
*
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public class MessageStatusChange extends Event<Message.MessageStatus> {
|
||||
|
||||
private final long id;
|
||||
private final LocalDateTime date;
|
||||
|
||||
private static final long serialVersionUID = 0L;
|
||||
|
||||
/**
|
||||
* Initializes a {@link MessageStatusChange}.
|
||||
*
|
||||
* @param id the ID of the {@link Message} this event is related to
|
||||
* @param status the status of the {@link Message} this event is related
|
||||
* to
|
||||
* @param date the date at which the MessageStatus change occurred
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public MessageStatusChange(long id, Message.MessageStatus status, LocalDateTime date) {
|
||||
super(status);
|
||||
this.id = id;
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes a {@link MessageStatusChange} through a message.
|
||||
*
|
||||
* @param message the message from which to build the event
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public MessageStatusChange(Message message) { this(message.getID(), message.getStatus(), LocalDateTime.now()); }
|
||||
|
||||
/**
|
||||
* @return the ID of the {@link Message} this event is related to
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public long getID() { return id; }
|
||||
|
||||
/**
|
||||
* @return the date at which the status change occurred
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public LocalDateTime getDate() { return date; }
|
||||
|
||||
@Override
|
||||
public String toString() { return String.format("MessageStatusChange[id=%d,status=%s,date=%s]", id, value, date); }
|
||||
}
|
52
src/main/java/envoy/event/NameChange.java
Normal file
52
src/main/java/envoy/event/NameChange.java
Normal file
@ -0,0 +1,52 @@
|
||||
package envoy.event;
|
||||
|
||||
import envoy.data.Contact;
|
||||
|
||||
/**
|
||||
* This event informs<br>
|
||||
* a) the server of the name change of a user or a group.
|
||||
* b) another user of this users name change.
|
||||
*
|
||||
* Project: <strong>envoy-common</strong><br>
|
||||
* File: <strong>NameChange.java</strong><br>
|
||||
* Created: <strong>25 Mar 2020</strong><br>
|
||||
*
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public class NameChange extends Event<String> {
|
||||
|
||||
private final long id;
|
||||
|
||||
private static final long serialVersionUID = 0L;
|
||||
|
||||
/**
|
||||
* Creates a new {@link NameChange} for a user or a group.
|
||||
*
|
||||
* @param contactID the id of the {@link Contact} who wishes to change his name
|
||||
* @param newName the new name of this contact
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public NameChange(long contactID, String newName) {
|
||||
super(newName);
|
||||
id = contactID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes a {@link NameChange} through a Contact where the name has
|
||||
* already been set.
|
||||
*
|
||||
* @param contact the contact whose name was updated
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public NameChange(Contact contact) { this(contact.getID(), contact.getName()); }
|
||||
|
||||
/**
|
||||
* @return the ID of the {@link Contact} this event is related to
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public long getID() { return id; }
|
||||
|
||||
@Override
|
||||
public String toString() { return String.format("NameChange[id=%d,name=%s]", id, value); }
|
||||
}
|
49
src/main/java/envoy/event/UserStatusChange.java
Normal file
49
src/main/java/envoy/event/UserStatusChange.java
Normal file
@ -0,0 +1,49 @@
|
||||
package envoy.event;
|
||||
|
||||
import envoy.data.User;
|
||||
import envoy.data.User.UserStatus;
|
||||
|
||||
/**
|
||||
* Project: <strong>envoy-common</strong><br>
|
||||
* File: <strong>UserStatusChange.java</strong><br>
|
||||
* Created: <strong>1 Feb 2020</strong><br>
|
||||
*
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public class UserStatusChange extends Event<UserStatus> {
|
||||
|
||||
private final long id;
|
||||
|
||||
private static final long serialVersionUID = 0L;
|
||||
|
||||
/**
|
||||
* Initializes a {@link UserStatusChange}.
|
||||
*
|
||||
* @param id the ID of the {@link User} this event is related to
|
||||
* @param status the status of the {@link User} this event is related
|
||||
* to
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public UserStatusChange(long id, User.UserStatus status) {
|
||||
super(status);
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes a {@link UserStatusChange} through a User.
|
||||
*
|
||||
* @param user the User from which to build the event
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public UserStatusChange(User user) { this(user.getID(), user.getStatus()); }
|
||||
|
||||
/**
|
||||
* @return the ID of the {@link User} this event is related to
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public long getID() { return id; }
|
||||
|
||||
@Override
|
||||
public String toString() { return String.format("UserStatusChange[id=%d,status=%s]", id, value); }
|
||||
}
|
40
src/main/java/envoy/event/contact/ContactOperation.java
Normal file
40
src/main/java/envoy/event/contact/ContactOperation.java
Normal file
@ -0,0 +1,40 @@
|
||||
package envoy.event.contact;
|
||||
|
||||
import envoy.data.Contact;
|
||||
import envoy.event.ElementOperation;
|
||||
import envoy.event.Event;
|
||||
|
||||
/**
|
||||
* Signifies the modification of a contact list.<br>
|
||||
* <br>
|
||||
* Project: <strong>envoy-common</strong><br>
|
||||
* File: <strong>ContactOperation.java</strong><br>
|
||||
* Created: <strong>05.02.2020</strong><br>
|
||||
*
|
||||
* @author Maximilian Käfer
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public class ContactOperation extends Event<Contact> {
|
||||
|
||||
private final ElementOperation operationType;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Initializes a {@link ContactOperation}.
|
||||
*
|
||||
* @param contact the user on which the operation is performed
|
||||
* @param operationType the type of operation to perform
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public ContactOperation(Contact contact, ElementOperation operationType) {
|
||||
super(contact);
|
||||
this.operationType = operationType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the type of operation to perform
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public ElementOperation getOperationType() { return operationType; }
|
||||
}
|
26
src/main/java/envoy/event/contact/ContactSearchRequest.java
Normal file
26
src/main/java/envoy/event/contact/ContactSearchRequest.java
Normal file
@ -0,0 +1,26 @@
|
||||
package envoy.event.contact;
|
||||
|
||||
import envoy.event.Event;
|
||||
|
||||
/**
|
||||
* Requests a contact search from the server.<br>
|
||||
* <br>
|
||||
* Project: <strong>envoy-common</strong><br>
|
||||
* File: <strong>ContactSearchRequest.java</strong><br>
|
||||
* Created: <strong>05.02.2020</strong><br>
|
||||
*
|
||||
* @author Maximilian Käfer
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public class ContactSearchRequest extends Event<String> {
|
||||
|
||||
private static final long serialVersionUID = 0L;
|
||||
|
||||
/**
|
||||
* Initializes a {@link ContactSearchRequest}.
|
||||
*
|
||||
* @param searchPhrase the search phrase to use in the contact search
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public ContactSearchRequest(String searchPhrase) { super(searchPhrase); }
|
||||
}
|
29
src/main/java/envoy/event/contact/ContactSearchResult.java
Normal file
29
src/main/java/envoy/event/contact/ContactSearchResult.java
Normal file
@ -0,0 +1,29 @@
|
||||
package envoy.event.contact;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import envoy.data.Contact;
|
||||
import envoy.event.Event;
|
||||
|
||||
/**
|
||||
* Contains a list of {@link Contact}s for which a search was performed.<br>
|
||||
* <br>
|
||||
* Project: <strong>envoy-common</strong><br>
|
||||
* File: <strong>ContactSearchResult.java</strong><br>
|
||||
* Created: <strong>11 Feb 2020</strong><br>
|
||||
*
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public class ContactSearchResult extends Event<List<Contact>> {
|
||||
|
||||
private static final long serialVersionUID = 0L;
|
||||
|
||||
/**
|
||||
* Creates an instance of {@link ContactSearchResult}.
|
||||
*
|
||||
* @param users the users found during the search
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public ContactSearchResult(List<Contact> users) { super(users); }
|
||||
}
|
13
src/main/java/envoy/event/contact/package-info.java
Normal file
13
src/main/java/envoy/event/contact/package-info.java
Normal file
@ -0,0 +1,13 @@
|
||||
/**
|
||||
* This package contains all contact-related events.<br>
|
||||
* <br>
|
||||
* Project: <strong>envoy-common</strong><br>
|
||||
* File: <strong>package-info.java</strong><br>
|
||||
* Created: <strong>28 Mar 2020</strong><br>
|
||||
*
|
||||
* @author Leon Hofmeister
|
||||
* @author Maximilian Käfer
|
||||
* @author Kai S.K. Engelbart
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
package envoy.event.contact;
|
10
src/main/java/envoy/event/package-info.java
Normal file
10
src/main/java/envoy/event/package-info.java
Normal file
@ -0,0 +1,10 @@
|
||||
/**
|
||||
* This package contains all events that can be sent or received by Envoy Client
|
||||
* or Envoy Server Standalone.
|
||||
*
|
||||
* @author Leon Hofmeister
|
||||
* @author Maximilian Käfer
|
||||
* @author Kai S.K. Engelbart
|
||||
* @since Envoy common v0.1-beta
|
||||
*/
|
||||
package envoy.event;
|
35
src/main/java/envoy/exception/EnvoyException.java
Normal file
35
src/main/java/envoy/exception/EnvoyException.java
Normal file
@ -0,0 +1,35 @@
|
||||
package envoy.exception;
|
||||
|
||||
/**
|
||||
* Project: <strong>envoy-common</strong><br>
|
||||
* File: <strong>EnvoyException.java</strong><br>
|
||||
* Created: <strong>27 Oct 2019</strong><br>
|
||||
*
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy v0.1-alpha
|
||||
*/
|
||||
public class EnvoyException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 2096147309395387479L;
|
||||
|
||||
/**
|
||||
* @param message the message to display once this Exception is thrown
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public EnvoyException(String message) { super(message); }
|
||||
|
||||
/**
|
||||
* @param message the message to display once this Exception is thrown
|
||||
* @param cause the {@link Throwable} which resulted in the throw of an
|
||||
* EnvoyException
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public EnvoyException(String message, Throwable cause) { super(message, cause); }
|
||||
|
||||
/**
|
||||
* @param cause the {@link Throwable} which resulted in the throw of an
|
||||
* EnvoyException
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public EnvoyException(Throwable cause) { super(cause); }
|
||||
}
|
9
src/main/java/envoy/exception/package-info.java
Normal file
9
src/main/java/envoy/exception/package-info.java
Normal file
@ -0,0 +1,9 @@
|
||||
/**
|
||||
* This package contains all Envoy-specific exceptions.
|
||||
*
|
||||
* @author Leon Hofmeister
|
||||
* @author Maximilian Käfer
|
||||
* @author Kai S.K. Engelbart
|
||||
* @since Envoy common v0.1-beta
|
||||
*/
|
||||
package envoy.exception;
|
40
src/main/java/envoy/util/Bounds.java
Normal file
40
src/main/java/envoy/util/Bounds.java
Normal file
@ -0,0 +1,40 @@
|
||||
package envoy.util;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Implements contact name validation.
|
||||
* <p>
|
||||
* Project: <strong>envoy-common</strong><br>
|
||||
* File: <strong>Bounds.java</strong><br>
|
||||
* Created: <strong>25.06.2020</strong><br>
|
||||
*
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public class Bounds {
|
||||
|
||||
private Bounds() {}
|
||||
|
||||
/**
|
||||
* The regular expression against which contact names should be validated.
|
||||
*
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public static final Pattern CONTACT_NAME_PATTERN = Pattern.compile("^\\w[a-zA-Z0-9-]{2,15}$");
|
||||
|
||||
/**
|
||||
* @param contactName the contact name to validate
|
||||
* @return {@code true} if the given contact name is valid
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public static boolean isValidContactName(String contactName) { return CONTACT_NAME_PATTERN.matcher(contactName).matches(); }
|
||||
|
||||
/**
|
||||
* @return the maximum size allowed for a user/ group name.
|
||||
* @apiNote has to be updated manually if {@link Bounds#CONTACT_NAME_PATTERN}
|
||||
* gets updated.
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public static int maximumUsernameSize() { return 16; }
|
||||
}
|
126
src/main/java/envoy/util/EnvoyLog.java
Normal file
126
src/main/java/envoy/util/EnvoyLog.java
Normal file
@ -0,0 +1,126 @@
|
||||
package envoy.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.logging.*;
|
||||
|
||||
import envoy.data.Config;
|
||||
|
||||
/**
|
||||
* Configures the {@link java.util.logging} API to output the log into the
|
||||
* console and a log file.
|
||||
* <p>
|
||||
* Call the {@link EnvoyLog#attach(String)} method to configure a part of the
|
||||
* logger hierarchy.
|
||||
* <p>
|
||||
* Project: <strong>envoy-client</strong><br>
|
||||
* File: <strong>EnvoyLogger.java</strong><br>
|
||||
* Created: <strong>14 Dec 2019</strong><br>
|
||||
*
|
||||
* @author Leon Hofmeister
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public class EnvoyLog {
|
||||
|
||||
private static FileHandler fileHandler;
|
||||
private static StreamHandler consoleHandler;
|
||||
private static boolean initialized;
|
||||
|
||||
private EnvoyLog() {}
|
||||
|
||||
/**
|
||||
* Initializes logging. Call this method before calling the
|
||||
* {@link EnvoyLog#attach(String)} method.
|
||||
*
|
||||
* @param config the config providing the console and log file barriers
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public static void initialize(Config config) {
|
||||
if (initialized) throw new IllegalStateException("EnvoyLog is already initialized");
|
||||
|
||||
// Remove default console handler
|
||||
LogManager.getLogManager().reset();
|
||||
|
||||
// Configure log file
|
||||
final File logFile = new File((File) config.get("homeDirectory").get(),
|
||||
"log/envoy_user_" + DateTimeFormatter.ofPattern("yyyy-MM-dd--hh-mm-mm").format(LocalDateTime.now()) + ".log");
|
||||
logFile.getParentFile().mkdirs();
|
||||
|
||||
// Configure formatting
|
||||
// Sample log entry: [2020-06-13 16:50:26] [INFORMATION] [envoy.client.ui.Startup] Closing connection...
|
||||
System.setProperty("java.util.logging.SimpleFormatter.format", "[%1$tF %1$tT] [%4$-7s] [%3$s] %5$s %6$s%n");
|
||||
final SimpleFormatter formatter = new SimpleFormatter();
|
||||
|
||||
try {
|
||||
fileHandler = new FileHandler(logFile.getAbsolutePath());
|
||||
fileHandler.setLevel((Level) config.get("fileLevelBarrier").get());
|
||||
fileHandler.setFormatter(formatter);
|
||||
} catch (SecurityException | IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
consoleHandler = new StreamHandler(System.out, formatter) {
|
||||
|
||||
@Override
|
||||
public synchronized void publish(LogRecord record) {
|
||||
super.publish(record);
|
||||
flush();
|
||||
}
|
||||
};
|
||||
consoleHandler.setLevel((Level) config.get("consoleLevelBarrier").get());
|
||||
consoleHandler.setFormatter(formatter);
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures all loggers that are contained within the hierarchy of a specific
|
||||
* path to use the console and file handlers.
|
||||
*
|
||||
* @param path the path to the loggers to configure
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public static void attach(String path) {
|
||||
if (!initialized) throw new IllegalStateException("EnvoyLog is not initialized");
|
||||
|
||||
// Get root logger
|
||||
final Logger logger = Logger.getLogger(path);
|
||||
|
||||
// Add handlers
|
||||
if (fileHandler != null) logger.addHandler(fileHandler);
|
||||
logger.addHandler(consoleHandler);
|
||||
|
||||
// Delegate logger level filtering to the handlers
|
||||
logger.setLevel(Level.ALL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a logger for a specified class, which output will be displayed inside
|
||||
* the console and written to the log file.
|
||||
*
|
||||
* @param logClass the class in which the logger is used
|
||||
* @return the created logger
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public static Logger getLogger(Class<?> logClass) { return Logger.getLogger(logClass.getCanonicalName()); }
|
||||
|
||||
/**
|
||||
* Defines the logger level required for a record to be written to the log file.
|
||||
*
|
||||
* @param fileLevelBarrier the log file level
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public static void setFileLevelBarrier(Level fileLevelBarrier) { if (fileHandler != null) fileHandler.setLevel(fileLevelBarrier); }
|
||||
|
||||
/**
|
||||
* Defines the logger level required for a record to be written to the console.
|
||||
*
|
||||
* @param consoleLevelBarrier the console logger level
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public static void setConsoleLevelBarrier(Level consoleLevelBarrier) {
|
||||
if (consoleHandler != null) consoleHandler.setLevel(consoleLevelBarrier);
|
||||
}
|
||||
}
|
153
src/main/java/envoy/util/SerializationUtils.java
Normal file
153
src/main/java/envoy/util/SerializationUtils.java
Normal file
@ -0,0 +1,153 @@
|
||||
package envoy.util;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* Defines utility methods related to serialization.
|
||||
* <p>
|
||||
* Project: <strong>envoy-client</strong><br>
|
||||
* File: <strong>SerializationUtils.java</strong><br>
|
||||
* Created: <strong>23.12.2019</strong><br>
|
||||
*
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public class SerializationUtils {
|
||||
|
||||
private SerializationUtils() {}
|
||||
|
||||
/**
|
||||
* Converts an integer into a byte array.
|
||||
*
|
||||
* @param n the integer to convert
|
||||
* @return a byte array of length 4
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public static byte[] intToBytes(int n) { return new byte[] { (byte) (n >>> 24), (byte) (n >>> 16), (byte) (n >>> 8), (byte) n }; }
|
||||
|
||||
/**
|
||||
* Converts four bytes in byte array to an integer
|
||||
*
|
||||
* @param bytes the bytes to convert from
|
||||
* @param offset the offset at which four bytes are read
|
||||
* @return the converted integer
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public static int bytesToInt(byte[] bytes, int offset) {
|
||||
return ((bytes[offset] & 0xFF) << 24) | ((bytes[offset + 1] & 0xFF) << 16) | ((bytes[offset + 2] & 0xFF) << 8)
|
||||
| ((bytes[offset + 3] & 0xFF) << 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserializes an arbitrary {@link Serializable} object from a file.
|
||||
*
|
||||
* @param <T> the type of the serialized object
|
||||
* @param file the file to deserialize from
|
||||
* @param serializedClass the class of the object to deserialize
|
||||
* @return the deserialized object
|
||||
* @throws IOException if something failed while deserializing the
|
||||
* object
|
||||
* @throws ClassNotFoundException if the deserialized object can not be linked
|
||||
* to a class
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public static <T extends Serializable> T read(File file, Class<T> serializedClass) throws IOException, ClassNotFoundException {
|
||||
if (file == null) throw new NullPointerException("File is null");
|
||||
return read(new FileInputStream(file), serializedClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserializes an arbitrary {@link Serializable} object from a byte array.
|
||||
*
|
||||
* @param <T> the type of the serialized object
|
||||
* @param bytes the array in which the serialized object is stored
|
||||
* @param serializedClass the class of the serialized object
|
||||
* @return the deserialized object
|
||||
* @throws IOException if something failed while deserializing the
|
||||
* object
|
||||
* @throws ClassNotFoundException if the deserialized object can not be linked
|
||||
* to a class
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public static <T extends Serializable> T read(byte[] bytes, Class<T> serializedClass) throws IOException, ClassNotFoundException {
|
||||
return read(new ByteArrayInputStream(bytes), serializedClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserializes an arbitrary {@link Serializable} object from a stream.
|
||||
*
|
||||
* @param <T> the type of the serialized object
|
||||
* @param in the {@link InputStream} of a serialized Object
|
||||
* @param serializedClass the object type to convert the deserialized object
|
||||
* into
|
||||
* @return the deserialized object
|
||||
* @throws IOException if something failed while deserializing the
|
||||
* object
|
||||
* @throws ClassNotFoundException if the deserialized object can not be linked
|
||||
* to a class
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public static <T extends Serializable> T read(InputStream in, Class<T> serializedClass) throws IOException, ClassNotFoundException {
|
||||
try (ObjectInputStream oin = new ObjectInputStream(in)) {
|
||||
return serializedClass.cast(oin.readObject());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes arbitrary objects to a file.
|
||||
*
|
||||
* @param file the file to serialize to
|
||||
* @param objs the objects to serialize
|
||||
* @throws IOException if an error occurred during serialization
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public static void write(File file, Object... objs) throws IOException {
|
||||
if (file == null) throw new NullPointerException("File is null");
|
||||
if (objs == null) throw new NullPointerException("Null array passed to serialize");
|
||||
if (!file.exists()) {
|
||||
file.getParentFile().mkdirs();
|
||||
file.createNewFile();
|
||||
}
|
||||
try (ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(file))) {
|
||||
for (var obj : objs)
|
||||
out.writeObject(obj);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes an arbitrary object to a byte array.
|
||||
*
|
||||
* @param obj the object to serialize
|
||||
* @return a byte array containing the serialized object
|
||||
* @throws IOException if the serialization failed
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public static byte[] writeToByteArray(Object obj) throws IOException {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
try (ObjectOutputStream oout = new ObjectOutputStream(baos)) {
|
||||
oout.writeObject(obj);
|
||||
}
|
||||
return baos.toByteArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes an object and writes it into an output stream preceded by 4 bytes
|
||||
* containing the number of serialized bytes.
|
||||
*
|
||||
* @param obj the object to serialize
|
||||
* @param out the output stream to serialize to
|
||||
* @throws IOException if an error occurred during serialization
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public static void writeBytesWithLength(Object obj, OutputStream out) throws IOException {
|
||||
// Serialize object to byte array
|
||||
byte[] objBytes = writeToByteArray(obj);
|
||||
|
||||
// Get length of byte array in bytes
|
||||
byte[] objLen = intToBytes(objBytes.length);
|
||||
|
||||
// Write length and byte array
|
||||
out.write(objLen);
|
||||
out.write(objBytes);
|
||||
}
|
||||
}
|
11
src/main/java/envoy/util/package-info.java
Normal file
11
src/main/java/envoy/util/package-info.java
Normal file
@ -0,0 +1,11 @@
|
||||
/**
|
||||
* This package contains general useful classes that can be used by both Envoy
|
||||
* Client and Envoy Server Standalone and that could not be assigned to any
|
||||
* other package.
|
||||
*
|
||||
* @author Leon Hofmeister
|
||||
* @author Maximilian Käfer
|
||||
* @author Kai S.K. Engelbart
|
||||
* @since Envoy common v0.1-beta
|
||||
*/
|
||||
package envoy.util;
|
19
src/main/java/module-info.java
Normal file
19
src/main/java/module-info.java
Normal file
@ -0,0 +1,19 @@
|
||||
/**
|
||||
* This module contains all packages that are used by Envoy Client and Envoy
|
||||
* Server Standalone at the same time.
|
||||
*
|
||||
* @author Leon Hofmeister
|
||||
* @author Maximilian Käfer
|
||||
* @author Kai S.K. Engelbart
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
module envoy.common {
|
||||
|
||||
exports envoy.data;
|
||||
exports envoy.util;
|
||||
exports envoy.exception;
|
||||
exports envoy.event;
|
||||
exports envoy.event.contact;
|
||||
|
||||
requires transitive java.logging;
|
||||
}
|
34
src/test/java/envoy/data/UserTest.java
Normal file
34
src/test/java/envoy/data/UserTest.java
Normal file
@ -0,0 +1,34 @@
|
||||
package envoy.data;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import envoy.data.User.UserStatus;
|
||||
import envoy.util.SerializationUtils;
|
||||
|
||||
/**
|
||||
* Project: <strong>envoy-common</strong><br>
|
||||
* File: <strong>UserTest.java</strong><br>
|
||||
* Created: <strong>31 Mar 2020</strong><br>
|
||||
*
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
class UserTest {
|
||||
|
||||
@Test
|
||||
void test() throws IOException, ClassNotFoundException {
|
||||
User user2 = new User(2, "kai");
|
||||
User user3 = new User(3, "ai");
|
||||
User user4 = new User(4, "ki", Set.of(user2, user3));
|
||||
User user5 = new User(5, "ka", Set.of(user2, user3, user4));
|
||||
User user = new User(1, "maxi", UserStatus.AWAY, Set.of(user2, user3, user4, user5));
|
||||
var serializedUser = SerializationUtils.writeToByteArray(user);
|
||||
var deserializedUser = SerializationUtils.read(serializedUser, User.class);
|
||||
assertEquals(user.getContacts(), deserializedUser.getContacts());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user