Code cleanup.
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/compiler/CodeGenerationPreference.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/compiler/CodeGenerationPreference.java
index 40699ad..cf1cb60 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/compiler/CodeGenerationPreference.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/compiler/CodeGenerationPreference.java
@@ -8,27 +8,11 @@
*/
package com.google.eclipse.protobuf.ui.preferences.compiler;
-import org.eclipse.jface.preference.IPreferenceStore;
-
/**
* @author alruiz@google.com (Alex Ruiz)
*/
-public class CodeGenerationPreference {
- private final IPreferenceStore store;
- private final String enabledPreferenceName;
- private final String outputDirectoryPreferenceName;
+public interface CodeGenerationPreference {
+ boolean isEnabled();
- CodeGenerationPreference(IPreferenceStore store, String enabledPreferenceName, String outputDirectoryPreferenceName) {
- this.store = store;
- this.enabledPreferenceName = enabledPreferenceName;
- this.outputDirectoryPreferenceName = outputDirectoryPreferenceName;
- }
-
- public boolean isEnabled() {
- return store.getBoolean(enabledPreferenceName);
- }
-
- public String outputDirectory() {
- return store.getString(outputDirectoryPreferenceName);
- }
+ String outputDirectory();
}
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/compiler/CompilerPreferences.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/compiler/CompilerPreferences.java
index c00f3a3..d87f142 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/compiler/CompilerPreferences.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/compiler/CompilerPreferences.java
@@ -28,15 +28,15 @@
}
private final IPreferenceStore store;
- private final CodeGenerationPreference java;
- private final CodeGenerationPreference cpp;
- private final CodeGenerationPreference python;
+ private final CodeGenerationPreference javaCodeGenerationPreference;
+ private final CodeGenerationPreference cppCodeGenerationPreference;
+ private final CodeGenerationPreference pythonCodeGenerationPreference;
private CompilerPreferences(IPreferenceStore store) {
this.store = store;
- java = new CodeGenerationPreference(store, JAVA_CODE_GENERATION_ENABLED, JAVA_OUTPUT_DIRECTORY);
- cpp = new CodeGenerationPreference(store, CPP_CODE_GENERATION_ENABLED, CPP_OUTPUT_DIRECTORY);
- python = new CodeGenerationPreference(store, PYTHON_CODE_GENERATION_ENABLED, PYTHON_OUTPUT_DIRECTORY);
+ javaCodeGenerationPreference = new JavaCodeGenerationPreference(store);
+ cppCodeGenerationPreference = new CppCodeGenerationPreference(store);
+ pythonCodeGenerationPreference = new PythonCodeGenerationPreference(store);
}
public boolean shouldCompileProtoFiles() {
@@ -56,15 +56,15 @@
}
public CodeGenerationPreference javaCodeGeneration() {
- return java;
+ return javaCodeGenerationPreference;
}
public CodeGenerationPreference cppCodeGeneration() {
- return cpp;
+ return cppCodeGenerationPreference;
}
public CodeGenerationPreference pythonCodeGeneration() {
- return python;
+ return pythonCodeGenerationPreference;
}
public boolean refreshResources() {
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/compiler/CppCodeGenerationPreference.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/compiler/CppCodeGenerationPreference.java
new file mode 100644
index 0000000..0a08d26
--- /dev/null
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/compiler/CppCodeGenerationPreference.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2012 Google Inc.
+ *
+ * All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse
+ * Public License v1.0 which accompanies this distribution, and is available at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.google.eclipse.protobuf.ui.preferences.compiler;
+
+import static com.google.eclipse.protobuf.ui.preferences.compiler.PreferenceNames.*;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+
+/**
+ * @author alruiz@google.com (Alex Ruiz)
+ */
+class CppCodeGenerationPreference implements CodeGenerationPreference {
+ private final IPreferenceStore store;
+
+ CppCodeGenerationPreference(IPreferenceStore store) {
+ this.store = store;
+ }
+
+ @Override public boolean isEnabled() {
+ return store.getBoolean(JAVA_CODE_GENERATION_ENABLED);
+ }
+
+ @Override public String outputDirectory() {
+ return store.getString(JAVA_OUTPUT_DIRECTORY);
+ }
+}
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/compiler/JavaCodeGenerationPreference.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/compiler/JavaCodeGenerationPreference.java
new file mode 100644
index 0000000..93fe698
--- /dev/null
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/compiler/JavaCodeGenerationPreference.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2012 Google Inc.
+ *
+ * All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse
+ * Public License v1.0 which accompanies this distribution, and is available at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.google.eclipse.protobuf.ui.preferences.compiler;
+
+import static com.google.eclipse.protobuf.ui.preferences.compiler.PreferenceNames.*;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+
+/**
+ * @author alruiz@google.com (Alex Ruiz)
+ */
+class JavaCodeGenerationPreference implements CodeGenerationPreference {
+ private final IPreferenceStore store;
+
+ JavaCodeGenerationPreference(IPreferenceStore store) {
+ this.store = store;
+ }
+
+ @Override public boolean isEnabled() {
+ return store.getBoolean(CPP_CODE_GENERATION_ENABLED);
+ }
+
+ @Override public String outputDirectory() {
+ return store.getString(CPP_OUTPUT_DIRECTORY);
+ }
+}
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/compiler/PythonCodeGenerationPreference.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/compiler/PythonCodeGenerationPreference.java
new file mode 100644
index 0000000..c256ad8
--- /dev/null
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/compiler/PythonCodeGenerationPreference.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2012 Google Inc.
+ *
+ * All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse
+ * Public License v1.0 which accompanies this distribution, and is available at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.google.eclipse.protobuf.ui.preferences.compiler;
+
+import static com.google.eclipse.protobuf.ui.preferences.compiler.PreferenceNames.*;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+
+/**
+ * @author alruiz@google.com (Alex Ruiz)
+ */
+class PythonCodeGenerationPreference implements CodeGenerationPreference {
+ private final IPreferenceStore store;
+
+ PythonCodeGenerationPreference(IPreferenceStore store) {
+ this.store = store;
+ }
+
+ @Override public boolean isEnabled() {
+ return store.getBoolean(PYTHON_CODE_GENERATION_ENABLED);
+ }
+
+ @Override public String outputDirectory() {
+ return store.getString(PYTHON_OUTPUT_DIRECTORY);
+ }
+}