@Test public void extractTypeIndicator() { testExtraction(spec -> spec.ofType(SomeEnum.class), "string", "enum type option"); testExtraction(spec -> spec.ofType(String.class), "string", "string type option"); testExtraction(spec -> spec.ofType(Integer.class), "int", "Integer type option"); testExtraction(spec -> spec.ofType(Long.class), "long", "Long type option"); testExtraction(spec -> spec.ofType(Byte.class), "byte", "Byte type option"); testExtraction(spec -> spec.withValuesConvertedBy(new CharacterValueConverter()), "char", "Character type option"); testExtraction(spec -> spec.ofType(File.class), "pathname", "File type option"); testExtraction(spec -> spec.withValuesConvertedBy(new PathValueConverter()), "pathname", "Path type option"); testExtraction(spec -> spec.ofType(Constructible.class), "string", "custom class with string constructor option"); }
@Override protected String extractTypeIndicator(OptionDescriptor descriptor) { String indicator = descriptor.argumentTypeIndicator(); if (indicator != null) { Class<?> indicatorAsClass = null; try { indicatorAsClass = Class.forName(indicator); } catch (ClassNotFoundException ignore) { } if (indicatorAsClass != null) { indicatorAsClass = Primitives.unwrap(indicatorAsClass); if (Primitives.allPrimitiveTypes().contains(indicatorAsClass)) { return indicatorAsClass.getName(); } if (PATHNAME_CLASSES.contains(indicatorAsClass)) { return "pathname"; } } } return "string"; }
CustomHelpFormatter extends BuiltinHelpFormatter { @Override protected String extractTypeIndicator(OptionDescriptor descriptor) { String indicator = descriptor.argumentTypeIndicator(); if (indicator != null) { Class<?> indicatorAsClass = null; try { indicatorAsClass = Class.forName(indicator); } catch (ClassNotFoundException ignore) { } if (indicatorAsClass != null) { indicatorAsClass = Primitives.unwrap(indicatorAsClass); if (Primitives.allPrimitiveTypes().contains(indicatorAsClass)) { return indicatorAsClass.getName(); } if (PATHNAME_CLASSES.contains(indicatorAsClass)) { return "pathname"; } } } return "string"; } }
CustomHelpFormatter extends BuiltinHelpFormatter { @Override protected String extractTypeIndicator(OptionDescriptor descriptor) { String indicator = descriptor.argumentTypeIndicator(); if (indicator != null) { Class<?> indicatorAsClass = null; try { indicatorAsClass = Class.forName(indicator); } catch (ClassNotFoundException ignore) { } if (indicatorAsClass != null) { indicatorAsClass = Primitives.unwrap(indicatorAsClass); if (Primitives.allPrimitiveTypes().contains(indicatorAsClass)) { return indicatorAsClass.getName(); } if (PATHNAME_CLASSES.contains(indicatorAsClass)) { return "pathname"; } } } return "string"; } CustomHelpFormatter(); }
CustomHelpFormatter extends BuiltinHelpFormatter { @Override protected String extractTypeIndicator(OptionDescriptor descriptor) { String indicator = descriptor.argumentTypeIndicator(); if (indicator != null) { Class<?> indicatorAsClass = null; try { indicatorAsClass = Class.forName(indicator); } catch (ClassNotFoundException ignore) { } if (indicatorAsClass != null) { indicatorAsClass = Primitives.unwrap(indicatorAsClass); if (Primitives.allPrimitiveTypes().contains(indicatorAsClass)) { return indicatorAsClass.getName(); } if (PATHNAME_CLASSES.contains(indicatorAsClass)) { return "pathname"; } } } return "string"; } CustomHelpFormatter();  }
CustomHelpFormatter extends BuiltinHelpFormatter { @Override protected String extractTypeIndicator(OptionDescriptor descriptor) { String indicator = descriptor.argumentTypeIndicator(); if (indicator != null) { Class<?> indicatorAsClass = null; try { indicatorAsClass = Class.forName(indicator); } catch (ClassNotFoundException ignore) { } if (indicatorAsClass != null) { indicatorAsClass = Primitives.unwrap(indicatorAsClass); if (Primitives.allPrimitiveTypes().contains(indicatorAsClass)) { return indicatorAsClass.getName(); } if (PATHNAME_CLASSES.contains(indicatorAsClass)) { return "pathname"; } } } return "string"; } CustomHelpFormatter();   }