@@ -17,8 +17,6 @@ package org.springframework.shell.samples.helloworld.commands;
|
||||
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.shell.core.CommandMarker;
|
||||
import org.springframework.shell.core.annotation.CliCommand;
|
||||
import org.springframework.shell.plugin.support.DefaultBannerProvider;
|
||||
import org.springframework.shell.support.util.OsUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -121,11 +121,11 @@ public class Bootstrap {
|
||||
annctx.getBeanFactory().registerSingleton("commandLine", commandLine);
|
||||
}
|
||||
|
||||
protected void createAndRegisterBeanDefinition(GenericApplicationContext annctx, Class clazz) {
|
||||
protected void createAndRegisterBeanDefinition(GenericApplicationContext annctx, Class<?> clazz) {
|
||||
createAndRegisterBeanDefinition(annctx, clazz, null);
|
||||
}
|
||||
|
||||
protected void createAndRegisterBeanDefinition(GenericApplicationContext annctx, Class clazz, String name) {
|
||||
protected void createAndRegisterBeanDefinition(GenericApplicationContext annctx, Class<?> clazz, String name) {
|
||||
RootBeanDefinition rbd = new RootBeanDefinition();
|
||||
rbd.setBeanClass(clazz);
|
||||
DefaultListableBeanFactory bf = (DefaultListableBeanFactory)annctx.getBeanFactory();
|
||||
|
||||
@@ -29,16 +29,24 @@ import org.springframework.shell.core.MethodTarget;
|
||||
* @since 1.0
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
public class EnumConverter implements Converter<Enum> {
|
||||
public class EnumConverter implements Converter<Enum<?>> {
|
||||
|
||||
public Enum convertFromText(final String value, final Class<?> requiredType, final String optionContext) {
|
||||
Class<Enum> enumClass = (Class<Enum>) requiredType;
|
||||
return Enum.valueOf(enumClass, value);
|
||||
@SuppressWarnings("unchecked")
|
||||
public Enum<?> convertFromText(final String value, final Class<?> requiredType, final String optionContext) {
|
||||
if(!Enum.class.isAssignableFrom(requiredType)) {
|
||||
return null;
|
||||
}
|
||||
Class<Enum> enumClass = (Class<Enum>) requiredType;
|
||||
return Enum.valueOf(enumClass, value);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean getAllPossibleValues(final List<Completion> completions, final Class<?> requiredType, final String existingData, final String optionContext, final MethodTarget target) {
|
||||
if(!Enum.class.isAssignableFrom(requiredType)) {
|
||||
return false;
|
||||
}
|
||||
Class<Enum> enumClass = (Class<Enum>) requiredType;
|
||||
for (Enum enumValue : enumClass.getEnumConstants()) {
|
||||
for (Enum<?> enumValue : enumClass.getEnumConstants()) {
|
||||
String candidate = enumValue.name();
|
||||
if ("".equals(existingData) || candidate.startsWith(existingData) || existingData.startsWith(candidate) || candidate.toUpperCase().startsWith(existingData.toUpperCase()) || existingData.toUpperCase().startsWith(candidate.toUpperCase())) {
|
||||
completions.add(new Completion(candidate));
|
||||
|
||||
@@ -38,7 +38,7 @@ public class JLineCompletorAdapter implements Completor {
|
||||
this.parser = parser;
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
@SuppressWarnings({"rawtypes","unchecked"})
|
||||
public int complete(final String buffer, final int cursor, final List candidates) {
|
||||
int result;
|
||||
try {
|
||||
|
||||
@@ -94,6 +94,7 @@ public class JLineShellComponent extends JLineShell implements SmartLifecycle, A
|
||||
return running;
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void afterPropertiesSet() {
|
||||
|
||||
Map<String, CommandMarker> commands = BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, CommandMarker.class);
|
||||
@@ -102,7 +103,7 @@ public class JLineShellComponent extends JLineShell implements SmartLifecycle, A
|
||||
}
|
||||
|
||||
Map<String, Converter> converters = BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, Converter.class);
|
||||
for (Converter converter : converters.values()) {
|
||||
for (Converter<?> converter : converters.values()) {
|
||||
getSimpleParser().add(converter);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user