From d64de9b3c17b9c9d688fd43ee90e192b4ef00456 Mon Sep 17 00:00:00 2001
From: Christian Wulf <chw@informatik.uni-kiel.de>
Date: Tue, 14 Oct 2014 09:03:19 +0200
Subject: [PATCH] removed TokenCounter because teetime already provides the
 Counter stage; updated formatter and clean up settings

---
 .settings/org.eclipse.jdt.core.prefs          |  4 ++
 .settings/org.eclipse.jdt.ui.prefs            | 22 ++++++----
 src/main/java/teetime/stage/TokenCounter.java | 18 ---------
 .../tokenizer/TokenizerConfiguration.java     | 40 +++++++++----------
 .../examples/tokenizer/TokenizerTest.java     | 15 ++++---
 teetime-eclipse-cleanup.xml                   |  2 +-
 teetime-eclipse-formatter.xml                 |  2 +-
 7 files changed, 46 insertions(+), 57 deletions(-)
 delete mode 100644 src/main/java/teetime/stage/TokenCounter.java

diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
index dd0d799c..9db11560 100644
--- a/.settings/org.eclipse.jdt.core.prefs
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -54,6 +54,7 @@ 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
@@ -99,6 +100,7 @@ org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do
 org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert
 org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not 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=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
@@ -146,6 +148,7 @@ org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=inser
 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_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
@@ -223,6 +226,7 @@ org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do n
 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_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
diff --git a/.settings/org.eclipse.jdt.ui.prefs b/.settings/org.eclipse.jdt.ui.prefs
index fa6b3349..5d68cd69 100644
--- a/.settings/org.eclipse.jdt.ui.prefs
+++ b/.settings/org.eclipse.jdt.ui.prefs
@@ -5,16 +5,18 @@ cleanup.add_missing_deprecated_annotations=true
 cleanup.add_missing_methods=false
 cleanup.add_missing_nls_tags=false
 cleanup.add_missing_override_annotations=true
-cleanup.add_missing_override_annotations_interface_methods=false
+cleanup.add_missing_override_annotations_interface_methods=true
 cleanup.add_serial_version_id=true
 cleanup.always_use_blocks=true
 cleanup.always_use_parentheses_in_expressions=true
-cleanup.always_use_this_for_non_static_field_access=true
-cleanup.always_use_this_for_non_static_method_access=true
+cleanup.always_use_this_for_non_static_field_access=false
+cleanup.always_use_this_for_non_static_method_access=false
+cleanup.convert_functional_interfaces=true
 cleanup.convert_to_enhanced_for_loop=true
 cleanup.correct_indentation=true
 cleanup.format_source_code=true
 cleanup.format_source_code_changes_only=false
+cleanup.insert_inferred_type_arguments=false
 cleanup.make_local_variable_final=true
 cleanup.make_parameters_final=true
 cleanup.make_private_fields_final=true
@@ -29,6 +31,7 @@ cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=tru
 cleanup.qualify_static_member_accesses_with_declaring_class=true
 cleanup.qualify_static_method_accesses_with_declaring_class=true
 cleanup.remove_private_constructors=true
+cleanup.remove_redundant_type_arguments=true
 cleanup.remove_trailing_whitespaces=true
 cleanup.remove_trailing_whitespaces_all=true
 cleanup.remove_trailing_whitespaces_ignore_empty=false
@@ -42,18 +45,21 @@ cleanup.remove_unused_private_methods=true
 cleanup.remove_unused_private_types=true
 cleanup.sort_members=false
 cleanup.sort_members_all=false
+cleanup.use_anonymous_class_creation=false
 cleanup.use_blocks=true
 cleanup.use_blocks_only_for_return_and_throw=false
+cleanup.use_lambda=true
 cleanup.use_parentheses_in_expressions=true
-cleanup.use_this_for_non_static_field_access=false
-cleanup.use_this_for_non_static_field_access_only_if_necessary=false
+cleanup.use_this_for_non_static_field_access=true
+cleanup.use_this_for_non_static_field_access_only_if_necessary=true
 cleanup.use_this_for_non_static_method_access=true
-cleanup.use_this_for_non_static_method_access_only_if_necessary=false
-cleanup_profile=_TeeTime
+cleanup.use_this_for_non_static_method_access_only_if_necessary=true
+cleanup.use_type_arguments=false
+cleanup_profile=_TeeTime - Clean Up
 cleanup_settings_version=2
 eclipse.preferences.version=1
 editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
-formatter_profile=_Kieker - Profile
+formatter_profile=_TeeTime - Profile
 formatter_settings_version=12
 org.eclipse.jdt.ui.ignorelowercasenames=true
 org.eclipse.jdt.ui.importorder=java;javax;junit;org;com;kieker;kieker.test;
diff --git a/src/main/java/teetime/stage/TokenCounter.java b/src/main/java/teetime/stage/TokenCounter.java
deleted file mode 100644
index dfcc27ac..00000000
--- a/src/main/java/teetime/stage/TokenCounter.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package teetime.stage;
-
-import teetime.framework.ConsumerStage;
-
-public class TokenCounter extends ConsumerStage<String> {
-
-	private long i = 0;
-
-	public long getI() {
-		return i;
-	}
-
-	@Override
-	protected void execute(final String element) {
-		i++;
-	}
-
-}
diff --git a/src/test/java/teetime/examples/tokenizer/TokenizerConfiguration.java b/src/test/java/teetime/examples/tokenizer/TokenizerConfiguration.java
index 2d333cf8..ee9f67c4 100644
--- a/src/test/java/teetime/examples/tokenizer/TokenizerConfiguration.java
+++ b/src/test/java/teetime/examples/tokenizer/TokenizerConfiguration.java
@@ -9,8 +9,8 @@ import teetime.framework.pipe.PipeFactoryRegistry.ThreadCommunication;
 import teetime.stage.ByteArray2String;
 import teetime.stage.CipherByteArray;
 import teetime.stage.CipherByteArray.CipherMode;
+import teetime.stage.Counter;
 import teetime.stage.InitialElementProducer;
-import teetime.stage.TokenCounter;
 import teetime.stage.Tokenizer;
 import teetime.stage.ZipByteArray;
 import teetime.stage.ZipByteArray.ZipMode;
@@ -18,10 +18,10 @@ import teetime.stage.io.File2ByteArray;
 
 public class TokenizerConfiguration extends AnalysisConfiguration {
 
-	private final PipeFactoryRegistry pipeFactory = PipeFactoryRegistry.INSTANCE;
+	private static final PipeFactoryRegistry pipeFactoryRegistry = PipeFactoryRegistry.INSTANCE;
 	private final File input;
 	private final String password;
-	private final TokenCounter counter;
+	private final Counter<String> counter;
 
 	public TokenizerConfiguration(final String inputFile, final String password) {
 		this.input = new File(inputFile);
@@ -33,28 +33,26 @@ public class TokenizerConfiguration extends AnalysisConfiguration {
 		CipherByteArray decrypt = new CipherByteArray(this.password, CipherMode.DECRYPT);
 		ByteArray2String b2s = new ByteArray2String();
 		Tokenizer tokenizer = new Tokenizer(" ");
-		TokenCounter counter = new TokenCounter();
-
-		this.pipeFactory.getPipeFactory(ThreadCommunication.INTRA, PipeOrdering.ARBITRARY, false)
-				.create(init.getOutputPort(), f2b.getInputPort());
-		this.pipeFactory.getPipeFactory(ThreadCommunication.INTRA, PipeOrdering.ARBITRARY, false)
-				.create(f2b.getOutputPort(), decomp.getInputPort());
-		this.pipeFactory.getPipeFactory(ThreadCommunication.INTRA, PipeOrdering.ARBITRARY, false)
-				.create(decomp.getOutputPort(), decrypt.getInputPort());
-		this.pipeFactory.getPipeFactory(ThreadCommunication.INTRA, PipeOrdering.ARBITRARY, false)
-				.create(decrypt.getOutputPort(), b2s.getInputPort());
-		this.pipeFactory.getPipeFactory(ThreadCommunication.INTRA, PipeOrdering.ARBITRARY, false)
-				.create(b2s.getOutputPort(), tokenizer.getInputPort());
-		this.pipeFactory.getPipeFactory(ThreadCommunication.INTRA, PipeOrdering.ARBITRARY, false)
-				.create(tokenizer.getOutputPort(), counter.getInputPort());
+		counter = new Counter<String>();
+
+		pipeFactoryRegistry.getPipeFactory(ThreadCommunication.INTRA, PipeOrdering.ARBITRARY, false).create(
+				init.getOutputPort(), f2b.getInputPort());
+		pipeFactoryRegistry.getPipeFactory(ThreadCommunication.INTRA, PipeOrdering.ARBITRARY, false).create(
+				f2b.getOutputPort(), decomp.getInputPort());
+		pipeFactoryRegistry.getPipeFactory(ThreadCommunication.INTRA, PipeOrdering.ARBITRARY, false).create(
+				decomp.getOutputPort(), decrypt.getInputPort());
+		pipeFactoryRegistry.getPipeFactory(ThreadCommunication.INTRA, PipeOrdering.ARBITRARY, false).create(
+				decrypt.getOutputPort(), b2s.getInputPort());
+		pipeFactoryRegistry.getPipeFactory(ThreadCommunication.INTRA, PipeOrdering.ARBITRARY, false).create(
+				b2s.getOutputPort(), tokenizer.getInputPort());
+		pipeFactoryRegistry.getPipeFactory(ThreadCommunication.INTRA, PipeOrdering.ARBITRARY, false).create(
+				tokenizer.getOutputPort(), counter.getInputPort());
 
 		this.getFiniteProducerStages().add(init);
-
-		this.counter = counter;
 	}
 
-	public long getTokenCount() {
-		return this.counter.getI();
+	public int getTokenCount() {
+		return this.counter.getNumElementsPassed();
 	}
 
 }
diff --git a/src/test/java/teetime/examples/tokenizer/TokenizerTest.java b/src/test/java/teetime/examples/tokenizer/TokenizerTest.java
index 93cd2761..91fd611d 100644
--- a/src/test/java/teetime/examples/tokenizer/TokenizerTest.java
+++ b/src/test/java/teetime/examples/tokenizer/TokenizerTest.java
@@ -7,18 +7,17 @@ import teetime.framework.Analysis;
 
 public class TokenizerTest {
 
-	// Encrypted lorem ipsum
-	private static String inputFile = "src/test/resources/data/cipherInput.txt";
-	private static String password = "Password";
-
-	private static TokenizerConfiguration configuration = new TokenizerConfiguration(inputFile, password);
-
-	private final static Analysis analysis = new Analysis(configuration);
-
 	@Test
 	public void executeTest() {
+		// Encrypted lorem ipsum
+		String inputFile = "src/test/resources/data/cipherInput.txt";
+		String password = "Password";
+
+		TokenizerConfiguration configuration = new TokenizerConfiguration(inputFile, password);
+		Analysis analysis = new Analysis(configuration);
 		analysis.init();
 		analysis.start();
+
 		Assert.assertEquals(970, configuration.getTokenCount());
 	}
 
diff --git a/teetime-eclipse-cleanup.xml b/teetime-eclipse-cleanup.xml
index 56ccef73..dac74c2b 100644
--- a/teetime-eclipse-cleanup.xml
+++ b/teetime-eclipse-cleanup.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
 <profiles version="2">
-<profile kind="CleanUpProfile" name="Kieker - Clean Up" version="2">
+<profile kind="CleanUpProfile" name="TeeTime - Clean Up" version="2">
 <setting id="cleanup.format_source_code" value="true"/>
 <setting id="cleanup.add_missing_annotations" value="true"/>
 <setting id="cleanup.use_this_for_non_static_method_access_only_if_necessary" value="false"/>
diff --git a/teetime-eclipse-formatter.xml b/teetime-eclipse-formatter.xml
index d7f1d4d3..3ae3882e 100644
--- a/teetime-eclipse-formatter.xml
+++ b/teetime-eclipse-formatter.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
 <profiles version="12">
-<profile kind="CodeFormatterProfile" name="Kieker - Profile" version="12">
+<profile kind="CodeFormatterProfile" name="TeeTime - Profile" version="12">
 <setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/>
 <setting id="org.eclipse.jdt.core.formatter.disabling_tag" value="@formatter:off"/>
 <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/>
-- 
GitLab