public <T, S extends T> ValueType<T> get(Class<S> clazz) { ValueType<?> bestType = null; int bestDegree = Integer.MAX_VALUE; for (ValueType<?> type : types) { int degree = type.getDistance(clazz); if (degree != -1 && degree < bestDegree) { bestType = type; bestDegree = degree; } } return (ValueType<T>)bestType; } }
public CommandFactory(ClassLoader loader) throws NullPointerException { this(new ValueTypeFactory(loader)); }
public Object parse(String s) throws Exception { return valueType.parse(effectiveType, s); }
public void testFoo() { final URL url = MissingValueTypeTestCase.class.getResource("InvalidValueType"); assertNotNull(url); ClassLoader cl = new ClassLoader(MissingValueTypeTestCase.class.getClassLoader()) { @Override public Enumeration<URL> getResources(String name) throws IOException { if (name.equals("META-INF/services/" + ValueType.class.getName())) { return Collections.enumeration(Collections.singleton(url)); } else { return super.getResources(name); } } }; ValueTypeFactory factory = new ValueTypeFactory(cl); ValueType<Custom> custom = factory.get(Custom.class); assertNotNull(custom); }
} else { effectiveType = declaredType; valueType = factory.get(declaredType); if (valueType == null) { throw new IllegalValueTypeException("Type " + declaredType.getName() + " is not handled at the moment");
public ParameterDescriptor( ParameterType<?> type, Description description, boolean required, boolean password, boolean unquote, Class<? extends Completer> completerType, Annotation annotation) throws IllegalValueTypeException, IllegalParameterException { // if (completerType == EmptyCompleter.class) { completerType = type.getValueType().getCompleter(); } // this.description = description; this.required = required; this.password = password; this.completerType = completerType; this.annotation = annotation; this.unquote = unquote; this.type = type; }
public final V parse(String s) throws Exception { return parse(type, s); }
public CommandFactory(ClassLoader loader) throws NullPointerException { this(new ValueTypeFactory(loader)); }
public <T, S extends T> ValueType<T> get(Class<S> clazz) { ValueType<?> bestType = null; int bestDegree = Integer.MAX_VALUE; for (ValueType<?> type : types) { int degree = type.getDistance(clazz); if (degree != -1 && degree < bestDegree) { bestType = type; bestDegree = degree; } } return (ValueType<T>)bestType; } }
public void testProperties() throws Exception { ValueType<Properties> propertiesVT = factory.get(Properties.class); Properties props = propertiesVT.parse("org.apache.jackrabbit.repository.conf=repository" + "-in-memory.xml;org.apache.jackrabbit.repository.home=/home/ehugonnet/tmp/crash/jcr/target" + "/test-classes/conf/transient"); assertNotNull(props); assertEquals(2, props.size()); assertEquals("repository-in-memory.xml", props.get("org.apache.jackrabbit.repository.conf")); assertEquals("/home/ehugonnet/tmp/crash/jcr/target/test-classes/conf/transient", props.get("org.apache.jackrabbit.repository.home")); }
public final V parse(String s) throws Exception { return parse(type, s); }
public CommandFactory(ClassLoader loader) throws NullPointerException { this(new ValueTypeFactory(loader)); }
public <T, S extends T> ValueType<T> get(Class<S> clazz) { ValueType<?> bestType = null; int bestDegree = Integer.MAX_VALUE; for (ValueType<?> type : types) { int degree = type.getDistance(clazz); if (degree != -1 && degree < bestDegree) { bestType = type; bestDegree = degree; } } return (ValueType<T>)bestType; } }
public Object parse(String s) throws Exception { return valueType.parse(effectiveType, s); }