SHL-177: Remove unused code
This commit is contained in:
committed by
Eric Bottard
parent
3bbd89506e
commit
73f47a4c85
@@ -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<String> optionContextHolder = new ThreadLocal<String>();
|
||||
|
||||
/**
|
||||
* Returns the option context for the current thread.
|
||||
*
|
||||
* @return <code>null</code> 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() {}
|
||||
}
|
||||
@@ -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<SimpleParser> simpleParserContextHolder = new ThreadLocal<SimpleParser>();
|
||||
|
||||
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() {}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user