Просмотр исходного кода

Added format preference file for eclipse with 2 space indentation and 120 char wide lines

jorgen_falk 19 лет назад
Родитель
Сommit
6b309a4839

+ 264
- 0
dddsample/doc/dddsample-format-eclipse.pref Просмотреть файл

@@ -0,0 +1,264 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<profiles version="11">
3
+<profile kind="CodeFormatterProfile" name="DDDSample App code convention" version="11">
4
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert"/>
5
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert" value="insert"/>
6
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_constant" value="end_of_line"/>
7
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon" value="do not insert"/>
8
+<setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/>
9
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/>
10
+<setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="true"/>
11
+<setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="1"/>
12
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/>
13
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch" value="do not insert"/>
14
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="1"/>
15
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return" value="insert"/>
16
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body" value="insert"/>
17
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration" value="insert"/>
18
+<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_body" value="true"/>
19
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/>
20
+<setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false"/>
21
+<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/>
22
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert"/>
23
+<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="2"/>
24
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters" value="do not insert"/>
25
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="1"/>
26
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case" value="insert"/>
27
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments" value="do not insert"/>
28
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk" value="1"/>
29
+<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="2"/>
30
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_binary_operator" value="insert"/>
31
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" value="insert"/>
32
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert"/>
33
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces" value="do not insert"/>
34
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="16"/>
35
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="0"/>
36
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_member_type" value="1"/>
37
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws" value="do not insert"/>
38
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="80"/>
39
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/>
40
+<setting id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description" value="true"/>
41
+<setting id="org.eclipse.jdt.core.formatter.comment.format_html" value="true"/>
42
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression" value="insert"/>
43
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" value="insert"/>
44
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant" value="do not insert"/>
45
+<setting id="org.eclipse.jdt.core.formatter.comment.format_source_code" value="true"/>
46
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/>
47
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
48
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation" value="do not insert"/>
49
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/>
50
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/>
51
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_unary_operator" value="do not insert"/>
52
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/>
53
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration" value="insert"/>
54
+<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="4"/>
55
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert"/>
56
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator" value="do not insert"/>
57
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="16"/>
58
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments" value="insert"/>
59
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/>
60
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration" value="do not insert"/>
61
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration" value="do not insert"/>
62
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments" value="insert"/>
63
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="end_of_line"/>
64
+<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="120"/>
65
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/>
66
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/>
67
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration" value="insert"/>
68
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/>
69
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/>
70
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert"/>
71
+<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="false"/>
72
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration" value="insert"/>
73
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant" value="insert"/>
74
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments" value="do not insert"/>
75
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert"/>
76
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/>
77
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_array_initializer" value="end_of_line"/>
78
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration" value="16"/>
79
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/>
80
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration" value="insert"/>
81
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized" value="do not insert"/>
82
+<setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="false"/>
83
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for" value="insert"/>
84
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation" value="do not insert"/>
85
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="do not insert"/>
86
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="16"/>
87
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/>
88
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/>
89
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields" value="16"/>
90
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="do not insert"/>
91
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments" value="do not insert"/>
92
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block" value="insert"/>
93
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast" value="insert"/>
94
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement" value="do not insert"/>
95
+<setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="false"/>
96
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_binary_operator" value="insert"/>
97
+<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header" value="true"/>
98
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration" value="insert"/>
99
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="do not insert"/>
100
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer" value="16"/>
101
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/>
102
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="end_of_line"/>
103
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant" value="do not insert"/>
104
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration" value="do not insert"/>
105
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments" value="do not insert"/>
106
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
107
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration" value="do not insert"/>
108
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_field" value="0"/>
109
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="16"/>
110
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/>
111
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters" value="do not insert"/>
112
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters" value="insert"/>
113
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/>
114
+<setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="true"/>
115
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression" value="do not insert"/>
116
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation" value="do not insert"/>
117
+<setting id="org.eclipse.jdt.core.formatter.comment.format_block_comments" value="true"/>
118
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="insert"/>
119
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration" value="insert"/>
120
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_binary_expression" value="16"/>
121
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert"/>
122
+<setting id="org.eclipse.jdt.core.formatter.wrap_before_binary_operator" value="true"/>
123
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1"/>
124
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch" value="insert"/>
125
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration" value="16"/>
126
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert"/>
127
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/>
128
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" value="insert"/>
129
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch" value="do not insert"/>
130
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="do not insert"/>
131
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups" value="1"/>
132
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws" value="do not insert"/>
133
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/>
134
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_ellipsis" value="do not insert"/>
135
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration" value="end_of_line"/>
136
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="do not insert"/>
137
+<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment" value="false"/>
138
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="16"/>
139
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/>
140
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_imports" value="1"/>
141
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/>
142
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration" value="insert"/>
143
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference" value="insert"/>
144
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="do not insert"/>
145
+<setting id="org.eclipse.jdt.core.compiler.problem.assertIdentifier" value="error"/>
146
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="16"/>
147
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case" value="end_of_line"/>
148
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration" value="end_of_line"/>
149
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments" value="do not insert"/>
150
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert"/>
151
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="0"/>
152
+<setting id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line" value="false"/>
153
+<setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="false"/>
154
+<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="insert"/>
155
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw" value="insert"/>
156
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert"/>
157
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/>
158
+<setting id="org.eclipse.jdt.core.compiler.source" value="1.5"/>
159
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments" value="insert"/>
160
+<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/>
161
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert"/>
162
+<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="80"/>
163
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator" value="do not insert"/>
164
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="end_of_line"/>
165
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator" value="insert"/>
166
+<setting id="org.eclipse.jdt.core.compiler.compliance" value="1.5"/>
167
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/>
168
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments" value="do not insert"/>
169
+<setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/>
170
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference" value="do not insert"/>
171
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/>
172
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/>
173
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters" value="do not insert"/>
174
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert"/>
175
+<setting id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/>
176
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert"/>
177
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_switch" value="end_of_line"/>
178
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="16"/>
179
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/>
180
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert"/>
181
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration" value="do not insert"/>
182
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized" value="insert"/>
183
+<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body" value="0"/>
184
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/>
185
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
186
+<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="false"/>
187
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration" value="do not insert"/>
188
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation" value="do not insert"/>
189
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert"/>
190
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/>
191
+<setting id="org.eclipse.jdt.core.compiler.problem.enumIdentifier" value="error"/>
192
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation" value="do not insert"/>
193
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant" value="do not insert"/>
194
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference" value="do not insert"/>
195
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference" value="do not insert"/>
196
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/>
197
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert"/>
198
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized" value="do not insert"/>
199
+<setting id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line" value="false"/>
200
+<setting id="org.eclipse.jdt.core.compiler.codegen.targetPlatform" value="1.5"/>
201
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="do not insert"/>
202
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/>
203
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="insert"/>
204
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if" value="16"/>
205
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard" value="do not insert"/>
206
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert" value="insert"/>
207
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/>
208
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/>
209
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression" value="16"/>
210
+<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block" value="true"/>
211
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/>
212
+<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true"/>
213
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters" value="insert"/>
214
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments" value="do not insert"/>
215
+<setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line" value="false"/>
216
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/>
217
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations" value="do not insert"/>
218
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration" value="end_of_line"/>
219
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation" value="16"/>
220
+<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header" value="true"/>
221
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/>
222
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator" value="insert"/>
223
+<setting id="org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column" value="false"/>
224
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/>
225
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/>
226
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/>
227
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression" value="do not insert"/>
228
+<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/>
229
+<setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/>
230
+<setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags" value="true"/>
231
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="0"/>
232
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference" value="do not insert"/>
233
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert"/>
234
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws" value="insert"/>
235
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="16"/>
236
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="16"/>
237
+<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space"/>
238
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package" value="0"/>
239
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/>
240
+<setting id="org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases" value="true"/>
241
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits" value="do not insert"/>
242
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="do not insert"/>
243
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces" value="insert"/>
244
+<setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="true"/>
245
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/>
246
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_method" value="1"/>
247
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations" value="insert"/>
248
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits" value="insert"/>
249
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration" value="insert"/>
250
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation" value="insert"/>
251
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/>
252
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="insert"/>
253
+<setting id="org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column" value="false"/>
254
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/>
255
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert"/>
256
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant" value="do not insert"/>
257
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert"/>
258
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator" value="do not insert"/>
259
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block" value="end_of_line"/>
260
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="insert"/>
261
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression" value="do not insert"/>
262
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter" value="insert"/>
263
+</profile>
264
+</profiles>

+ 38
- 40
dddsample/src/main/java/se/citerus/dddsample/domain/Cargo.java Просмотреть файл

@@ -1,47 +1,45 @@
1 1
 package se.citerus.dddsample.domain;
2 2
 
3
-
4 3
 /**
5
- * A Cargo an entity identifed by TrackingId and is capable of getting its DeliveryHistory plus a number
6
- * of convenience operation for finding current destination etc.
4
+ * A Cargo an entity identifed by TrackingId and is capable of getting its
5
+ * DeliveryHistory plus a number of convenience operation for finding current
6
+ * destination etc.
7 7
  * 
8
- * @author jorgenfalk
9
- *
10 8
  */
11 9
 public class Cargo {
12
-	private final TrackingId trackingId;
13
-	private final Location from;
14
-	private final Location to;
15
-	private DeliveryHistory history;
16
-
17
-	public Cargo(TrackingId trackingId, Location origin, Location finalDestination) {
18
-		this.trackingId = trackingId;
19
-		this.from = origin;
20
-		this.to = finalDestination;
21
-		
22
-		this.history = new DeliveryHistory();
23
-	}
24
-
25
-	public DeliveryHistory deliveryHistory() {
26
-		return history;
27
-	}
28
-
29
-	public void handle(HandlingEvent event) {
30
-		history.add(event);
31
-	}
32
-
33
-	public boolean atFinalDestiation() {
34
-		return currentLocation().equals(to);
35
-	}
36
-
37
-	public Location currentLocation() {
38
-		HandlingEvent lastEvent = history.last();
39
-		CarrierMovement cm = lastEvent.getCarrierMovement();
40
-		
41
-		return (lastEvent.type()==HandlingEvent.Type.ON) ? cm.from() : cm.to();
42
-	}
43
-
44
-	public TrackingId trackingId() {
45
-		return trackingId;
46
-	}
10
+  private final TrackingId trackingId;
11
+  private final Location from;
12
+  private final Location to;
13
+  private DeliveryHistory history;
14
+
15
+  public Cargo(TrackingId trackingId, Location origin, Location finalDestination) {
16
+    this.trackingId = trackingId;
17
+    this.from = origin;
18
+    this.to = finalDestination;
19
+
20
+    this.history = new DeliveryHistory();
21
+  }
22
+
23
+  public DeliveryHistory deliveryHistory() {
24
+    return history;
25
+  }
26
+
27
+  public void handle(HandlingEvent event) {
28
+    history.add(event);
29
+  }
30
+
31
+  public boolean atFinalDestiation() {
32
+    return currentLocation().equals(to);
33
+  }
34
+
35
+  public Location currentLocation() {
36
+    HandlingEvent lastEvent = history.last();
37
+    CarrierMovement cm = lastEvent.getCarrierMovement();
38
+
39
+    return (lastEvent.type() == HandlingEvent.Type.ON) ? cm.from() : cm.to();
40
+  }
41
+
42
+  public TrackingId trackingId() {
43
+    return trackingId;
44
+  }
47 45
 }

+ 0
- 1
dddsample/src/main/java/se/citerus/dddsample/domain/CargoRepository.java Просмотреть файл

@@ -1,6 +1,5 @@
1 1
 package se.citerus.dddsample.domain;
2 2
 
3
-
4 3
 public interface CargoRepository {
5 4
   Cargo find(TrackingId trackingId);
6 5
 }

+ 12
- 13
dddsample/src/main/java/se/citerus/dddsample/domain/CarrierMovement.java Просмотреть файл

@@ -1,21 +1,20 @@
1 1
 package se.citerus.dddsample.domain;
2 2
 
3 3
 public class CarrierMovement {
4
-	private final Location from;
5
-	private final Location to;
4
+  private final Location from;
5
+  private final Location to;
6 6
 
7
-	public CarrierMovement(Location from, Location to) {
8
-		this.from = from;
9
-		this.to = to;
10
-	}
7
+  public CarrierMovement(Location from, Location to) {
8
+    this.from = from;
9
+    this.to = to;
10
+  }
11 11
 
12
-	public Location from() {
13
-		return from;
14
-	}
12
+  public Location from() {
13
+    return from;
14
+  }
15 15
 
16
-	public Location to() {
17
-		return to;
18
-	}
16
+  public Location to() {
17
+    return to;
18
+  }
19 19
 
20
-	
21 20
 }

+ 13
- 17
dddsample/src/main/java/se/citerus/dddsample/domain/DeliveryHistory.java Просмотреть файл

@@ -4,26 +4,22 @@ import java.util.SortedSet;
4 4
 import java.util.TreeSet;
5 5
 
6 6
 public class DeliveryHistory {
7
-	
8
-	private TreeSet<HandlingEvent> events;
9
-	
10
-	
11
-	public DeliveryHistory() {
12
-		this.events = new TreeSet<HandlingEvent>();
13
-	}
14 7
 
8
+  private TreeSet<HandlingEvent> events;
15 9
 
16
-	public SortedSet<HandlingEvent> events() {
17
-		return events; 
18
-	}
10
+  public DeliveryHistory() {
11
+    this.events = new TreeSet<HandlingEvent>();
12
+  }
19 13
 
14
+  public SortedSet<HandlingEvent> events() {
15
+    return events;
16
+  }
20 17
 
21
-	public void add(HandlingEvent event) {
22
-		events.add(event);
23
-	}
18
+  public void add(HandlingEvent event) {
19
+    events.add(event);
20
+  }
24 21
 
25
-
26
-	public HandlingEvent last() {
27
-		return events.last();
28
-	}
22
+  public HandlingEvent last() {
23
+    return events.last();
24
+  }
29 25
 }

+ 44
- 44
dddsample/src/main/java/se/citerus/dddsample/domain/HandlingEvent.java Просмотреть файл

@@ -8,50 +8,50 @@ import org.apache.commons.lang.builder.HashCodeBuilder;
8 8
 /**
9 9
  * HandlingEvent links the type of handling with a CarrierMovement.
10 10
  * 
11
- * Since HandlingEvents can be added in any order to a Cargo (or DeliveryHistory), they need to implement Comparable to be able to be sorted in correct order.
11
+ * Since HandlingEvents can be added in any order to a Cargo (or
12
+ * DeliveryHistory), they need to implement Comparable to be able to be sorted
13
+ * in correct order.
12 14
  * 
13
- * @author jorgenfalk
14 15
  */
15
-public class HandlingEvent implements Comparable<HandlingEvent>{
16
-
17
-	private final Type type;
18
-	private final CarrierMovement carrierMovement;
19
-	private final Date time;
20
-
21
-	public enum Type {
22
-		ON, OFF;
23
-	}
24
-	
25
-	
26
-	public HandlingEvent(Date time, Type type, CarrierMovement carrierMovement) {
27
-		this.time = time;
28
-		this.type = type;
29
-		this.carrierMovement = carrierMovement;
30
-	}
31
-
32
-	public Type type() {
33
-		return type;
34
-	}
35
-
36
-	public CarrierMovement getCarrierMovement() {
37
-		return carrierMovement;
38
-	}
39
-
40
-	public Date time() {
41
-		return time;
42
-	}
43
-	
44
-	@Override
45
-	public boolean equals(Object obj) {
46
-		return EqualsBuilder.reflectionEquals(this, obj);
47
-	}
48
-
49
-	@Override
50
-	public int hashCode() {
51
-		return HashCodeBuilder.reflectionHashCode(this);
52
-	}
53
-
54
-	public int compareTo(HandlingEvent o) {
55
-		return time.compareTo(o.time());
56
-	}	
16
+public class HandlingEvent implements Comparable<HandlingEvent> {
17
+
18
+  private final Type type;
19
+  private final CarrierMovement carrierMovement;
20
+  private final Date time;
21
+
22
+  public enum Type {
23
+    ON, OFF;
24
+  }
25
+
26
+  public HandlingEvent(Date time, Type type, CarrierMovement carrierMovement) {
27
+    this.time = time;
28
+    this.type = type;
29
+    this.carrierMovement = carrierMovement;
30
+  }
31
+
32
+  public Type type() {
33
+    return type;
34
+  }
35
+
36
+  public CarrierMovement getCarrierMovement() {
37
+    return carrierMovement;
38
+  }
39
+
40
+  public Date time() {
41
+    return time;
42
+  }
43
+
44
+  @Override
45
+  public boolean equals(Object obj) {
46
+    return EqualsBuilder.reflectionEquals(this, obj);
47
+  }
48
+
49
+  @Override
50
+  public int hashCode() {
51
+    return HashCodeBuilder.reflectionHashCode(this);
52
+  }
53
+
54
+  public int compareTo(HandlingEvent o) {
55
+    return time.compareTo(o.time());
56
+  }
57 57
 }

+ 16
- 17
dddsample/src/main/java/se/citerus/dddsample/domain/Location.java Просмотреть файл

@@ -4,25 +4,24 @@ import org.apache.commons.lang.builder.EqualsBuilder;
4 4
 import org.apache.commons.lang.builder.HashCodeBuilder;
5 5
 
6 6
 public class Location {
7
-	private final String unlocode;
7
+  private final String unlocode;
8 8
 
9
-	public Location(String unlocode) {
10
-		this.unlocode = unlocode;
11
-	}
9
+  public Location(String unlocode) {
10
+    this.unlocode = unlocode;
11
+  }
12 12
 
13
-	public String unlocode() {
14
-		return unlocode;
15
-	}
13
+  public String unlocode() {
14
+    return unlocode;
15
+  }
16 16
 
17
-	@Override
18
-	public boolean equals(Object obj) {
19
-		return EqualsBuilder.reflectionEquals(this, obj);
20
-	}
17
+  @Override
18
+  public boolean equals(Object obj) {
19
+    return EqualsBuilder.reflectionEquals(this, obj);
20
+  }
21
+
22
+  @Override
23
+  public int hashCode() {
24
+    return HashCodeBuilder.reflectionHashCode(this);
25
+  }
21 26
 
22
-	@Override
23
-	public int hashCode() {
24
-		return HashCodeBuilder.reflectionHashCode(this);
25
-	}
26
-	
27
-	
28 27
 }

+ 22
- 18
dddsample/src/main/java/se/citerus/dddsample/domain/TrackingId.java Просмотреть файл

@@ -5,28 +5,32 @@ import java.io.Serializable;
5 5
 import org.apache.commons.lang.builder.EqualsBuilder;
6 6
 import org.apache.commons.lang.builder.HashCodeBuilder;
7 7
 
8
+/**
9
+ * TrackingId is a simple ID wrapper which implements Serializable for easier
10
+ * integration with persistens frameworks.
11
+ * 
12
+ */
8 13
 public class TrackingId implements Serializable {
9
-	private static final long serialVersionUID = 1L;
10 14
 
11
-	private final String id;
15
+  private static final long serialVersionUID = 6273117599327914522L;
16
+  private final String id;
12 17
 
13
-	public TrackingId(String id) {
14
-		this.id = id;
15
-	}
18
+  public TrackingId(String id) {
19
+    this.id = id;
20
+  }
16 21
 
17
-	public String getId() {
18
-		return id;
19
-	}
22
+  public String getId() {
23
+    return id;
24
+  }
20 25
 
21
-	@Override
22
-	public boolean equals(Object obj) {
23
-		return EqualsBuilder.reflectionEquals(this, obj);
24
-	}
26
+  @Override
27
+  public boolean equals(Object obj) {
28
+    return EqualsBuilder.reflectionEquals(this, obj);
29
+  }
30
+
31
+  @Override
32
+  public int hashCode() {
33
+    return HashCodeBuilder.reflectionHashCode(this);
34
+  }
25 35
 
26
-	@Override
27
-	public int hashCode() {
28
-		return HashCodeBuilder.reflectionHashCode(this);
29
-	}
30
-	
31
-	
32 36
 }

+ 8
- 8
dddsample/src/main/java/se/citerus/dddsample/repository/CargoRepositoryHibernate.java Просмотреть файл

@@ -8,13 +8,13 @@ import se.citerus.dddsample.domain.CargoRepository;
8 8
 import se.citerus.dddsample.domain.TrackingId;
9 9
 
10 10
 public class CargoRepositoryHibernate implements CargoRepository {
11
-	private HibernateTemplate hibernateTemplate;
11
+  private HibernateTemplate hibernateTemplate;
12 12
 
13
-	public void setSessionFactory(SessionFactory sessionFactory) {
14
-		this.hibernateTemplate = new HibernateTemplate(sessionFactory);
15
-	} 
16
-	
17
-	public Cargo find(TrackingId trackingId) {
18
-		return (Cargo) hibernateTemplate.load(Cargo.class, trackingId);
19
-	}
13
+  public void setSessionFactory(SessionFactory sessionFactory) {
14
+    this.hibernateTemplate = new HibernateTemplate(sessionFactory);
15
+  }
16
+
17
+  public Cargo find(TrackingId trackingId) {
18
+    return (Cargo) hibernateTemplate.load(Cargo.class, trackingId);
19
+  }
20 20
 }

+ 49
- 41
dddsample/src/main/java/se/citerus/dddsample/repository/CargoRepositoryInMem.java Просмотреть файл

@@ -14,46 +14,54 @@ import se.citerus.dddsample.domain.HandlingEvent;
14 14
 import se.citerus.dddsample.domain.Location;
15 15
 import se.citerus.dddsample.domain.TrackingId;
16 16
 
17
+/**
18
+ * CargoRepositoryInMem implement the CargoRepository interface but is a test
19
+ * class not intended for usage in real application.
20
+ * 
21
+ * It setup a simple local hash with a number of Cargo's with TrackingId as key
22
+ * defined at compile time.
23
+ * 
24
+ */
17 25
 public class CargoRepositoryInMem implements CargoRepository {
18
-	private Map<String, Cargo> cargoDb;
19
-
20
-	public CargoRepositoryInMem() throws Exception {
21
-		cargoDb = new HashMap<String, Cargo>();
22
-		setup();
23
-	}
24
-
25
-	public Cargo find(TrackingId trackingId) {
26
-		return cargoDb.get(trackingId.getId());
27
-	}
28
-
29
-
30
-	private void setup() throws Exception {
31
-		String trackIdXYZ = "XYZ";
32
-		final Cargo cargoXYZ = new Cargo(new TrackingId(trackIdXYZ), new Location(
33
-				"SESTO"), new Location("AUMEL"));
34
-
35
-		final CarrierMovement stockholmToHamburg = new CarrierMovement(new Location("SESTO"), new Location("DEHAM"));
36
-
37
-		cargoXYZ.handle(new HandlingEvent(getDate("2007-12-01"),HandlingEvent.Type.ON, stockholmToHamburg));
38
-		cargoXYZ.handle(new HandlingEvent(getDate("2007-12-02"),HandlingEvent.Type.OFF, stockholmToHamburg));
39
-
40
-		final CarrierMovement hamburgToHongKong = new CarrierMovement(new Location("DEHAM"), new Location("CNHKG"));
41
-
42
-		cargoXYZ.handle(new HandlingEvent(getDate("2007-12-03"),HandlingEvent.Type.ON, hamburgToHongKong));
43
-		cargoXYZ.handle(new HandlingEvent(getDate("2007-12-05"),HandlingEvent.Type.OFF, hamburgToHongKong));
44
-
45
-		cargoDb.put(trackIdXYZ, cargoXYZ);
46
-	}
47
-	
48
-	  /**
49
-	   * Parse an ISO 8601 (YYYY-MM-DD) String to Date
50
-	   *
51
-	   * @param isoFormat String to parse.
52
-	   * @return Created date instance.
53
-	   * @throws ParseException Thrown if parsing fails.
54
-	   */
55
-	  private Date getDate(String isoFormat) throws ParseException {
56
-	    final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
57
-	    return dateFormat.parse(isoFormat);
58
-	  }
26
+  private Map<String, Cargo> cargoDb;
27
+
28
+  public CargoRepositoryInMem() throws Exception {
29
+    cargoDb = new HashMap<String, Cargo>();
30
+    setup();
31
+  }
32
+
33
+  public Cargo find(TrackingId trackingId) {
34
+    return cargoDb.get(trackingId.getId());
35
+  }
36
+
37
+  private void setup() throws Exception {
38
+    String trackIdXYZ = "XYZ";
39
+    final Cargo cargoXYZ = new Cargo(new TrackingId(trackIdXYZ), new Location("SESTO"), new Location("AUMEL"));
40
+
41
+    final CarrierMovement stockholmToHamburg = new CarrierMovement(new Location("SESTO"), new Location("DEHAM"));
42
+
43
+    cargoXYZ.handle(new HandlingEvent(getDate("2007-12-01"), HandlingEvent.Type.ON, stockholmToHamburg));
44
+    cargoXYZ.handle(new HandlingEvent(getDate("2007-12-02"), HandlingEvent.Type.OFF, stockholmToHamburg));
45
+
46
+    final CarrierMovement hamburgToHongKong = new CarrierMovement(new Location("DEHAM"), new Location("CNHKG"));
47
+
48
+    cargoXYZ.handle(new HandlingEvent(getDate("2007-12-03"), HandlingEvent.Type.ON, hamburgToHongKong));
49
+    cargoXYZ.handle(new HandlingEvent(getDate("2007-12-05"), HandlingEvent.Type.OFF, hamburgToHongKong));
50
+
51
+    cargoDb.put(trackIdXYZ, cargoXYZ);
52
+  }
53
+
54
+  /**
55
+   * Parse an ISO 8601 (YYYY-MM-DD) String to Date
56
+   * 
57
+   * @param isoFormat
58
+   *            String to parse.
59
+   * @return Created date instance.
60
+   * @throws ParseException
61
+   *             Thrown if parsing fails.
62
+   */
63
+  private Date getDate(String isoFormat) throws ParseException {
64
+    final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
65
+    return dateFormat.parse(isoFormat);
66
+  }
59 67
 }

+ 16
- 18
dddsample/src/test/java/se/citerus/dddsample/domain/CargoRepositoryTest.java Просмотреть файл

@@ -7,28 +7,26 @@ import junit.framework.TestCase;
7 7
 
8 8
 public class CargoRepositoryTest extends TestCase {
9 9
 
10
-	private static final String CTX = "applicationContext.xml";
10
+  private static final String CTX = "applicationContext.xml";
11 11
 
12
-	public void testFindByCargoId() {
12
+  public void testFindByCargoId() {
13 13
 
14
-		CargoRepository repository = getCargoRepository();
15
-		final TrackingId trackingId = new TrackingId("XYZ");
16
-		Cargo cargo = repository.find(trackingId);
14
+    CargoRepository repository = getCargoRepository();
15
+    final TrackingId trackingId = new TrackingId("XYZ");
16
+    Cargo cargo = repository.find(trackingId);
17 17
 
18
-		assertEquals(trackingId, cargo.trackingId());
18
+    assertEquals(trackingId, cargo.trackingId());
19 19
 
20
-	}
20
+  }
21 21
 
22
-	private CargoRepository getCargoRepository() {
23
-		return (CargoRepository)getBean("cargoRepository");
24
-	}
22
+  private CargoRepository getCargoRepository() {
23
+    return (CargoRepository) getBean("cargoRepository");
24
+  }
25
+
26
+  private Object getBean(String bean) {
27
+    ApplicationContext context = new ClassPathXmlApplicationContext(new String[] { CTX });
28
+
29
+    return context.getBean(bean);
30
+  }
25 31
 
26
-	private Object getBean(String bean) {
27
-		ApplicationContext context = new ClassPathXmlApplicationContext( 
28
-				new String[] {CTX});
29
-		
30
-		return context.getBean(bean);
31
-	}
32
-	
33
-	
34 32
 }

+ 98
- 104
dddsample/src/test/java/se/citerus/dddsample/domain/CargoTest.java Просмотреть файл

@@ -7,111 +7,105 @@ import java.text.ParseException;
7 7
 import java.text.SimpleDateFormat;
8 8
 import java.util.Date;
9 9
 
10
+public class CargoTest extends TestCase {
11
+  public void testCurrentLocationUnloaded() throws Exception {
12
+    Cargo cargo = populateCargoOffHongKong();
10 13
 
11
-public class CargoTest extends TestCase{
12
-	public void testCurrentLocationUnloaded() throws Exception {
13
-		Cargo cargo = populateCargoOffHongKong();
14
-		
15
-		assertEquals(new Location("CNHGK"), cargo.currentLocation());
16
-	}
17
-	
18
-	public void testCurrentLocationloaded() throws Exception {
19
-		Cargo cargo = populateCargoOnHamburg();
20
-		
21
-		assertEquals(new Location("DEHAM"), cargo.currentLocation());
22
-	}
23
-	
24
-	public void testAtFinalLocation() throws Exception {
25
-		Cargo cargo = populateCargoOffMelbourne();
26
-		
27
-		assertTrue(cargo.atFinalDestiation());
28
-	}
29
-	
30
-	public void testNotAtFinalLocationWhenNotUnloaded() throws Exception {
31
-		Cargo cargo = populateCargoOnHongKong();
32
-		
33
-		assertFalse(cargo.atFinalDestiation());
34
-	}
35
-	
36
-	// TODO: Generate test data some better way
37
-	private Cargo populateCargoOffHongKong() throws Exception {
38
-		final Cargo cargo = new Cargo(new TrackingId("XYZ"), new Location("SESTO"), new Location("AUMEL"));
39
-
40
-		final CarrierMovement stockholmToHamburg = new CarrierMovement(new Location("SESTO"), new Location("DEHAM"));
41
-
42
-	    cargo.handle(new HandlingEvent(getDate("2007-12-01"), HandlingEvent.Type.ON, stockholmToHamburg));
43
-	    cargo.handle(new HandlingEvent(getDate("2007-12-02"), HandlingEvent.Type.OFF, stockholmToHamburg));
44
-
45
-	    final CarrierMovement hamburgToHongKong =
46
-	       new CarrierMovement(new Location("DEHAM"), new Location("CNHGK"));
47
-
48
-	    cargo.handle(new HandlingEvent(getDate("2007-12-03"), HandlingEvent.Type.ON, hamburgToHongKong));
49
-	    cargo.handle(new HandlingEvent(getDate("2007-12-04"), HandlingEvent.Type.OFF, hamburgToHongKong));
50
-	    
51
-		return cargo;
52
-	}
53
-	
54
-	private Cargo populateCargoOnHamburg() throws Exception {
55
-		final Cargo cargo = new Cargo(new TrackingId("XYZ"), new Location("SESTO"), new Location("AUMEL"));
56
-
57
-		final CarrierMovement stockholmToHamburg = new CarrierMovement(new Location("SESTO"), new Location("DEHAM"));
58
-
59
-	    cargo.handle(new HandlingEvent(getDate("2007-12-01"), HandlingEvent.Type.ON, stockholmToHamburg));
60
-	    cargo.handle(new HandlingEvent(getDate("2007-12-02"), HandlingEvent.Type.OFF, stockholmToHamburg));
61
-
62
-	    final CarrierMovement hamburgToHongKong =
63
-	       new CarrierMovement(new Location("DEHAM"), new Location("CNHGK"));
64
-
65
-	    cargo.handle(new HandlingEvent(getDate("2007-12-03"), HandlingEvent.Type.ON, hamburgToHongKong));
66
-
67
-		return cargo;
68
-	}
69
-	private Cargo populateCargoOffMelbourne() throws Exception {
70
-		final Cargo cargo = new Cargo(new TrackingId("XYZ"), new Location("SESTO"), new Location("AUMEL"));
71
-
72
-		final CarrierMovement stockholmToHamburg = new CarrierMovement(new Location("SESTO"), new Location("DEHAM"));
73
-
74
-	    cargo.handle(new HandlingEvent(getDate("2007-12-01"), HandlingEvent.Type.ON, stockholmToHamburg));
75
-	    cargo.handle(new HandlingEvent(getDate("2007-12-02"), HandlingEvent.Type.OFF, stockholmToHamburg));
76
-
77
-	    final CarrierMovement hamburgToHongKong =
78
-	       new CarrierMovement(new Location("DEHAM"), new Location("CNHGK"));
79
-
80
-	    cargo.handle(new HandlingEvent(getDate("2007-12-03"), HandlingEvent.Type.ON, hamburgToHongKong));
81
-	    cargo.handle(new HandlingEvent(getDate("2007-12-04"), HandlingEvent.Type.OFF, hamburgToHongKong));
82
-
83
-	    final CarrierMovement hongKongToMelbourne =
84
-		       new CarrierMovement(new Location("CNHGK"), new Location("AUMEL"));
85
-	    
86
-	    cargo.handle(new HandlingEvent(getDate("2007-12-05"), HandlingEvent.Type.ON, hongKongToMelbourne));
87
-	    cargo.handle(new HandlingEvent(getDate("2007-12-07"), HandlingEvent.Type.OFF, hongKongToMelbourne));
88
-	    
89
-		return cargo;
90
-	}
91
-	
92
-	private Cargo populateCargoOnHongKong() throws Exception {
93
-		final Cargo cargo = new Cargo(new TrackingId("XYZ"), new Location("SESTO"), new Location("AUMEL"));
94
-
95
-		final CarrierMovement stockholmToHamburg = new CarrierMovement(new Location("SESTO"), new Location("DEHAM"));
96
-
97
-	    cargo.handle(new HandlingEvent(getDate("2007-12-01"), HandlingEvent.Type.ON, stockholmToHamburg));
98
-	    cargo.handle(new HandlingEvent(getDate("2007-12-02"), HandlingEvent.Type.OFF, stockholmToHamburg));
99
-
100
-	    final CarrierMovement hamburgToHongKong =
101
-	       new CarrierMovement(new Location("DEHAM"), new Location("CNHGK"));
102
-
103
-	    cargo.handle(new HandlingEvent(getDate("2007-12-03"), HandlingEvent.Type.ON, hamburgToHongKong));
104
-	    cargo.handle(new HandlingEvent(getDate("2007-12-04"), HandlingEvent.Type.OFF, hamburgToHongKong));
105
-
106
-	    final CarrierMovement hongKongToMelbourne =
107
-		       new CarrierMovement(new Location("CNHGK"), new Location("AUMEL"));
108
-	    
109
-	    cargo.handle(new HandlingEvent(getDate("2007-12-05"), HandlingEvent.Type.ON, hongKongToMelbourne));
110
-	    
111
-		return cargo;
112
-	}
113
-	
114
-	/**
14
+    assertEquals(new Location("CNHGK"), cargo.currentLocation());
15
+  }
16
+
17
+  public void testCurrentLocationloaded() throws Exception {
18
+    Cargo cargo = populateCargoOnHamburg();
19
+
20
+    assertEquals(new Location("DEHAM"), cargo.currentLocation());
21
+  }
22
+
23
+  public void testAtFinalLocation() throws Exception {
24
+    Cargo cargo = populateCargoOffMelbourne();
25
+
26
+    assertTrue(cargo.atFinalDestiation());
27
+  }
28
+
29
+  public void testNotAtFinalLocationWhenNotUnloaded() throws Exception {
30
+    Cargo cargo = populateCargoOnHongKong();
31
+
32
+    assertFalse(cargo.atFinalDestiation());
33
+  }
34
+
35
+  // TODO: Generate test data some better way
36
+  private Cargo populateCargoOffHongKong() throws Exception {
37
+    final Cargo cargo = new Cargo(new TrackingId("XYZ"), new Location("SESTO"), new Location("AUMEL"));
38
+
39
+    final CarrierMovement stockholmToHamburg = new CarrierMovement(new Location("SESTO"), new Location("DEHAM"));
40
+
41
+    cargo.handle(new HandlingEvent(getDate("2007-12-01"), HandlingEvent.Type.ON, stockholmToHamburg));
42
+    cargo.handle(new HandlingEvent(getDate("2007-12-02"), HandlingEvent.Type.OFF, stockholmToHamburg));
43
+
44
+    final CarrierMovement hamburgToHongKong = new CarrierMovement(new Location("DEHAM"), new Location("CNHGK"));
45
+
46
+    cargo.handle(new HandlingEvent(getDate("2007-12-03"), HandlingEvent.Type.ON, hamburgToHongKong));
47
+    cargo.handle(new HandlingEvent(getDate("2007-12-04"), HandlingEvent.Type.OFF, hamburgToHongKong));
48
+
49
+    return cargo;
50
+  }
51
+
52
+  private Cargo populateCargoOnHamburg() throws Exception {
53
+    final Cargo cargo = new Cargo(new TrackingId("XYZ"), new Location("SESTO"), new Location("AUMEL"));
54
+
55
+    final CarrierMovement stockholmToHamburg = new CarrierMovement(new Location("SESTO"), new Location("DEHAM"));
56
+
57
+    cargo.handle(new HandlingEvent(getDate("2007-12-01"), HandlingEvent.Type.ON, stockholmToHamburg));
58
+    cargo.handle(new HandlingEvent(getDate("2007-12-02"), HandlingEvent.Type.OFF, stockholmToHamburg));
59
+
60
+    final CarrierMovement hamburgToHongKong = new CarrierMovement(new Location("DEHAM"), new Location("CNHGK"));
61
+
62
+    cargo.handle(new HandlingEvent(getDate("2007-12-03"), HandlingEvent.Type.ON, hamburgToHongKong));
63
+
64
+    return cargo;
65
+  }
66
+
67
+  private Cargo populateCargoOffMelbourne() throws Exception {
68
+    final Cargo cargo = new Cargo(new TrackingId("XYZ"), new Location("SESTO"), new Location("AUMEL"));
69
+
70
+    final CarrierMovement stockholmToHamburg = new CarrierMovement(new Location("SESTO"), new Location("DEHAM"));
71
+
72
+    cargo.handle(new HandlingEvent(getDate("2007-12-01"), HandlingEvent.Type.ON, stockholmToHamburg));
73
+    cargo.handle(new HandlingEvent(getDate("2007-12-02"), HandlingEvent.Type.OFF, stockholmToHamburg));
74
+
75
+    final CarrierMovement hamburgToHongKong = new CarrierMovement(new Location("DEHAM"), new Location("CNHGK"));
76
+
77
+    cargo.handle(new HandlingEvent(getDate("2007-12-03"), HandlingEvent.Type.ON, hamburgToHongKong));
78
+    cargo.handle(new HandlingEvent(getDate("2007-12-04"), HandlingEvent.Type.OFF, hamburgToHongKong));
79
+
80
+    final CarrierMovement hongKongToMelbourne = new CarrierMovement(new Location("CNHGK"), new Location("AUMEL"));
81
+
82
+    cargo.handle(new HandlingEvent(getDate("2007-12-05"), HandlingEvent.Type.ON, hongKongToMelbourne));
83
+    cargo.handle(new HandlingEvent(getDate("2007-12-07"), HandlingEvent.Type.OFF, hongKongToMelbourne));
84
+
85
+    return cargo;
86
+  }
87
+
88
+  private Cargo populateCargoOnHongKong() throws Exception {
89
+    final Cargo cargo = new Cargo(new TrackingId("XYZ"), new Location("SESTO"), new Location("AUMEL"));
90
+
91
+    final CarrierMovement stockholmToHamburg = new CarrierMovement(new Location("SESTO"), new Location("DEHAM"));
92
+
93
+    cargo.handle(new HandlingEvent(getDate("2007-12-01"), HandlingEvent.Type.ON, stockholmToHamburg));
94
+    cargo.handle(new HandlingEvent(getDate("2007-12-02"), HandlingEvent.Type.OFF, stockholmToHamburg));
95
+
96
+    final CarrierMovement hamburgToHongKong = new CarrierMovement(new Location("DEHAM"), new Location("CNHGK"));
97
+
98
+    cargo.handle(new HandlingEvent(getDate("2007-12-03"), HandlingEvent.Type.ON, hamburgToHongKong));
99
+    cargo.handle(new HandlingEvent(getDate("2007-12-04"), HandlingEvent.Type.OFF, hamburgToHongKong));
100
+
101
+    final CarrierMovement hongKongToMelbourne = new CarrierMovement(new Location("CNHGK"), new Location("AUMEL"));
102
+
103
+    cargo.handle(new HandlingEvent(getDate("2007-12-05"), HandlingEvent.Type.ON, hongKongToMelbourne));
104
+
105
+    return cargo;
106
+  }
107
+
108
+  /**
115 109
    * Parse an ISO 8601 (YYYY-MM-DD) String to Date
116 110
    *
117 111
    * @param isoFormat String to parse.

+ 2
- 5
dddsample/src/test/java/se/citerus/dddsample/domain/TrackingScenarioTest.java Просмотреть файл

@@ -29,15 +29,12 @@ public class TrackingScenarioTest extends TestCase {
29 29
   private Cargo populateCargo() throws Exception {
30 30
     final Cargo cargo = new Cargo(new TrackingId("XYZ"), new Location("SESTO"), new Location("AUMEL"));
31 31
 
32
-    final CarrierMovement stockholmToHamburg =
33
-       new CarrierMovement(new Location("SESTO"), new Location("DEHAM"));
34
-
32
+    final CarrierMovement stockholmToHamburg = new CarrierMovement(new Location("SESTO"), new Location("DEHAM"));
35 33
 
36 34
     cargo.handle(new HandlingEvent(getDate("2007-12-01"), HandlingEvent.Type.ON, stockholmToHamburg));
37 35
     cargo.handle(new HandlingEvent(getDate("2007-12-02"), HandlingEvent.Type.OFF, stockholmToHamburg));
38 36
 
39
-    final CarrierMovement hamburgToHongKong =
40
-       new CarrierMovement(new Location("DEHAM"), new Location("CNHKG"));
37
+    final CarrierMovement hamburgToHongKong = new CarrierMovement(new Location("DEHAM"), new Location("CNHKG"));
41 38
 
42 39
     cargo.handle(new HandlingEvent(getDate("2007-12-03"), HandlingEvent.Type.ON, hamburgToHongKong));
43 40
     cargo.handle(new HandlingEvent(getDate("2007-12-05"), HandlingEvent.Type.OFF, hamburgToHongKong));