From 73f47a4c8568f9c3148e9f4015cf9e1b9b298c88 Mon Sep 17 00:00:00 2001 From: Eric Bottard Date: Wed, 1 Jul 2015 10:31:45 +0200 Subject: [PATCH] SHL-177: Remove unused code --- .../shell/core/CliOptionContext.java | 55 ----------------- .../shell/core/CliSimpleParserContext.java | 43 ------------- .../shell/core/SimpleParser.java | 6 -- .../shell/core/CliOptionContextTest.java | 60 ------------------- 4 files changed, 164 deletions(-) delete mode 100644 src/main/java/org/springframework/shell/core/CliOptionContext.java delete mode 100644 src/main/java/org/springframework/shell/core/CliSimpleParserContext.java delete mode 100644 src/test/java/org/springframework/shell/core/CliOptionContextTest.java diff --git a/src/main/java/org/springframework/shell/core/CliOptionContext.java b/src/main/java/org/springframework/shell/core/CliOptionContext.java deleted file mode 100644 index 550fe2c7..00000000 --- a/src/main/java/org/springframework/shell/core/CliOptionContext.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2011-2012 the original author or authors. - * - * Licensed 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.springframework.shell.core; - -/** - * Utility methods relating to shell option contexts - */ -public final class CliOptionContext { - - // Class fields - private static ThreadLocal optionContextHolder = new ThreadLocal(); - - /** - * Returns the option context for the current thread. - * - * @return null if none has been set - */ - public static String getOptionContext() { - return optionContextHolder.get(); - } - - /** - * Stores the given option context for the current thread. - * - * @param optionContext the option context to store - */ - public static void setOptionContext(final String optionContext) { - optionContextHolder.set(optionContext); - } - - /** - * Resets the option context for the current thread. - */ - public static void resetOptionContext() { - optionContextHolder.remove(); - } - - /** - * Constructor is private to prevent instantiation - */ - private CliOptionContext() {} -} diff --git a/src/main/java/org/springframework/shell/core/CliSimpleParserContext.java b/src/main/java/org/springframework/shell/core/CliSimpleParserContext.java deleted file mode 100644 index 8ec68586..00000000 --- a/src/main/java/org/springframework/shell/core/CliSimpleParserContext.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2011-2012 the original author or authors. - * - * Licensed 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.springframework.shell.core; - - -/** - * Utility methods relating to shell simple parser contexts. - */ -public final class CliSimpleParserContext { - - // Class fields - private static ThreadLocal simpleParserContextHolder = new ThreadLocal(); - - public static Parser getSimpleParserContext() { - return simpleParserContextHolder.get(); - } - - public static void setSimpleParserContext(final SimpleParser simpleParserContext) { - simpleParserContextHolder.set(simpleParserContext); - } - - public static void resetSimpleParserContext() { - simpleParserContextHolder.remove(); - } - - /** - * Constructor is private to prevent instantiation - */ - private CliSimpleParserContext() {} -} diff --git a/src/main/java/org/springframework/shell/core/SimpleParser.java b/src/main/java/org/springframework/shell/core/SimpleParser.java index bdb5b76c..daeee7d0 100644 --- a/src/main/java/org/springframework/shell/core/SimpleParser.java +++ b/src/main/java/org/springframework/shell/core/SimpleParser.java @@ -251,8 +251,6 @@ public class SimpleParser implements Parser { // Now we're ready to perform a conversion try { - CliOptionContext.setOptionContext(cliOption.optionContext()); - CliSimpleParserContext.setSimpleParserContext(this); Object result; Converter c = null; for (Converter candidate : converters) { @@ -287,10 +285,6 @@ public class SimpleParser implements Parser { } return null; } - finally { - CliOptionContext.resetOptionContext(); - CliSimpleParserContext.resetSimpleParserContext(); - } } // Check for options specified by the user but are unavailable for the command diff --git a/src/test/java/org/springframework/shell/core/CliOptionContextTest.java b/src/test/java/org/springframework/shell/core/CliOptionContextTest.java deleted file mode 100644 index e056f914..00000000 --- a/src/test/java/org/springframework/shell/core/CliOptionContextTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2011-2012 the original author or authors. - * - * Licensed 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.springframework.shell.core; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; - -import org.junit.Test; -import org.springframework.shell.core.CliOptionContext; - -/** - * Unit test of {@link CliOptionContext} - * - * @author Andrew Swan - * @since 1.2.0 - */ -public class CliOptionContextTest { - - // Constants - private static final String OPTION_CONTEXT = "anything"; - - @Test - public void testGetOptionContextWhenNoneSet() { - assertNull(CliOptionContext.getOptionContext()); - } - - @Test - public void testSetAndGetOptionContext() { - // Set up - CliOptionContext.setOptionContext(OPTION_CONTEXT); - - // Invoke and check - assertEquals(OPTION_CONTEXT, CliOptionContext.getOptionContext()); - } - - @Test - public void testResetOptionContext() { - // Set up - CliOptionContext.setOptionContext(OPTION_CONTEXT); - - // Invoke - CliOptionContext.resetOptionContext(); - - // Check - assertNull(CliOptionContext.getOptionContext()); - } -}