shindig-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mherma...@apache.org
Subject svn commit: r1065850 - in /shindig/trunk/java/gadgets/src: main/java/org/apache/shindig/gadgets/JsCompileMode.java test/java/org/apache/shindig/gadgets/JsCompileModeTest.java
Date Mon, 31 Jan 2011 23:21:53 GMT
Author: mhermanto
Date: Mon Jan 31 23:21:53 2011
New Revision: 1065850

URL: http://svn.apache.org/viewvc?rev=1065850&view=rev
Log:
Enum for different types of JS compilation.
http://codereview.appspot.com/4092044/

Added:
    shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/JsCompileMode.java
    shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/JsCompileModeTest.java

Added: shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/JsCompileMode.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/JsCompileMode.java?rev=1065850&view=auto
==============================================================================
--- shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/JsCompileMode.java
(added)
+++ shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/JsCompileMode.java
Mon Jan 31 23:21:53 2011
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.shindig.gadgets;
+
+public enum JsCompileMode {
+  DEBUG("0"),
+  BUILD_TIME_COMPILE("1"),
+  RUN_TIME_COMPILE("2");
+
+  private final String paramValue;
+
+  private JsCompileMode(String paramValue) {
+    this.paramValue = paramValue;
+  }
+
+  public String getParamValue() {
+    return paramValue;
+  }
+
+  public static JsCompileMode valueOfParam(String param) {
+    for (JsCompileMode mode : JsCompileMode.values()) {
+      String modeParam = mode.getParamValue();
+      if (modeParam.equals(param)) {
+        return mode;
+      }
+    }
+    return JsCompileMode.DEBUG;
+  }
+
+}
\ No newline at end of file

Added: shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/JsCompileModeTest.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/JsCompileModeTest.java?rev=1065850&view=auto
==============================================================================
--- shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/JsCompileModeTest.java
(added)
+++ shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/JsCompileModeTest.java
Mon Jan 31 23:21:53 2011
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.shindig.gadgets;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class JsCompileModeTest {
+  @Test
+  public void testValueOfParam() {
+    assertEquals(JsCompileMode.DEBUG, JsCompileMode.valueOfParam(null));
+    assertEquals(JsCompileMode.DEBUG, JsCompileMode.valueOfParam("0"));
+    assertEquals(JsCompileMode.BUILD_TIME_COMPILE, JsCompileMode.valueOfParam("1"));
+    assertEquals(JsCompileMode.RUN_TIME_COMPILE, JsCompileMode.valueOfParam("2"));
+  }
+}



Mime
View raw message