JsonHandler extends HandlerBase { protected JsonObjectBuilder showSetProperty(Property property) { JsonObjectBuilder propBuilder = Json.createObjectBuilder(); Set<?> propSet = (Set<?>) property.getValue(); JsonArrayBuilder lPropBuilder = Json.createArrayBuilder(); PropertyType type = property.getType(); Iterator<?> iter = propSet.iterator(); while (iter.hasNext()) { Object val = iter.next(); switch (type) { case BOOLEAN: lPropBuilder.add(((Boolean) val).booleanValue()); break; case BYTE: lPropBuilder.add(valueToString(val)); break; case CHARACTER: lPropBuilder.add(valueToString(val)); break; case DATE: lPropBuilder.add(valueToString(val)); break; case DOUBLE: lPropBuilder.add(((Double) val).doubleValue()); break; case FLOAT: lPropBuilder.add(((Float) val).floatValue()); break; case INTEGER: lPropBuilder.add(((Integer) val).intValue()); break; case LONG: lPropBuilder.add(((Long) val).longValue()); break; case OBJECT: lPropBuilder.add(valueToString(val)); break; case SHORT: lPropBuilder.add(((Short) val).shortValue()); break; case STRING: lPropBuilder.add(valueToString(val)); break; case RATIONAL: lPropBuilder.add(showRational((Rational) val)); break; case PROPERTY: lPropBuilder.add(showProperty((Property) val)); break; case NISOIMAGEMETADATA: lPropBuilder.add(showNisoImageMetadata((NisoImageMetadata) property.getValue())); break; case AESAUDIOMETADATA: lPropBuilder.add(showAESAudioMetadata((AESAudioMetadata) property.getValue())); break; case TEXTMDMETADATA: lPropBuilder.add(showTextMDMetadata((TextMDMetadata) property.getValue())); break; default: break; } } propBuilder.add(property.getName(), lPropBuilder); return propBuilder; } JsonHandler();  JsonHandler(String name, String release, int[] date, String note, String rights); @Override void show(); @Override void show(App app); @Override void show(OutputHandler handler); @Override void show(Module module); @Override void show(RepInfo info); @Override void showFooter(); @Override void showHeader();  }
@Test public void testShowSetProperty() throws IOException { final Set<Rational> testSet = new LinkedHashSet<>( Arrays.asList(new Rational[]{new Rational(300, 1), new Rational(4, 2)})); Property prop = new Property("test", PropertyType.RATIONAL, PropertyArity.SET, testSet); JsonObjectBuilder b = this.handler.showSetProperty(prop); buildJson(b); handler.close(); String result = outString.toString(); LOGGER.info(FIND + result); final String expected = "{\"test\":[[300,1],[4,2]]}"; assertEquals(expected, result); }