Created
November 11, 2015 15:56
-
-
Save martiner/5e3da1cb211c2be4cc31 to your computer and use it in GitHub Desktop.
jopt simple value converter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import joptsimple.ValueConverter; | |
import java.util.HashMap; | |
import java.util.Map; | |
import static org.springframework.core.GenericTypeResolver.resolveTypeArgument; | |
public class Pokus { | |
public static void main(String... args) { | |
System.out.println(new PokusConverter().valueType()); | |
System.out.println(new SpringConverter().valueType()); | |
} | |
public static class PokusConverter implements ValueConverter<Map<String, Integer>> { | |
private static final Map<String, Integer> TYPE = new HashMap<String, Integer>(); | |
public Map<String, Integer> convert(final String s) { | |
return null; | |
} | |
@SuppressWarnings("unchecked") | |
public Class<? extends Map<String, Integer>> valueType() { | |
return (Class<? extends Map<String, Integer>>) TYPE.getClass(); | |
} | |
public String valuePattern() { | |
return null; | |
} | |
} | |
public static class SpringConverter implements ValueConverter<Map<String, Integer>> { | |
public Map<String, Integer> convert(final String s) { | |
return null; | |
} | |
@SuppressWarnings("unchecked") | |
public Class<? extends Map<String, Integer>> valueType() { | |
return (Class<? extends Map<String, Integer>>) resolveTypeArgument(getClass(), ValueConverter.class); | |
} | |
public String valuePattern() { | |
return null; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment