@Test public void shouldCreateSerializerWithGivenConfig() throws Exception { Serializer actual = SimpleXmlFactory.createSerializer(config, getClass()); verify(config).getBooleanFalse(); verify(config).getBooleanTrue(); verify(config).getDateFormat(); verify(config).get(getClass().getName() + SimpleXmlFactory.SERIALIZER); StringWriter sw = new StringWriter(); V v1 = new V(true, false, Values.DATE); actual.write(v1, sw); V read = actual.read(V.class, new StringReader(sw.toString())); assertEquals("<root bool=\"myTrue\" bool2=\"myFalse\" date=\"13/03/1983 00:35:10\"/>", sw.toString()); assertEquals(v1, read); }
static Serializer createSerializer(CRestConfig crestConfig, Class<?> source){ String prefix = source.getName(); Serializer serializer = crestConfig.get(prefix + SERIALIZER); if(serializer != null) { return serializer; } Map<Class, Transform> registry = new HashMap<Class, Transform>(); registry.put(Date.class, new DateMatcher(crestConfig.getDateFormat())); registry.put(Boolean.class, new BooleanMatcher(crestConfig.getBooleanTrue(), crestConfig.getBooleanFalse())); registry.put(boolean.class, registry.get(Boolean.class)); return new Persister(new MatcherRegistry(registry)); }
SimpleXmlFactory { static Serializer createSerializer(CRestConfig crestConfig, Class<?> source){ String prefix = source.getName(); Serializer serializer = crestConfig.get(prefix + SERIALIZER); if(serializer != null) { return serializer; } Map<Class, Transform> registry = new HashMap<Class, Transform>(); registry.put(Date.class, new DateMatcher(crestConfig.getDateFormat())); registry.put(Boolean.class, new BooleanMatcher(crestConfig.getBooleanTrue(), crestConfig.getBooleanFalse())); registry.put(boolean.class, registry.get(Boolean.class)); return new Persister(new MatcherRegistry(registry)); } }
SimpleXmlFactory { static Serializer createSerializer(CRestConfig crestConfig, Class<?> source){ String prefix = source.getName(); Serializer serializer = crestConfig.get(prefix + SERIALIZER); if(serializer != null) { return serializer; } Map<Class, Transform> registry = new HashMap<Class, Transform>(); registry.put(Date.class, new DateMatcher(crestConfig.getDateFormat())); registry.put(Boolean.class, new BooleanMatcher(crestConfig.getBooleanTrue(), crestConfig.getBooleanFalse())); registry.put(boolean.class, registry.get(Boolean.class)); return new Persister(new MatcherRegistry(registry)); } private  SimpleXmlFactory(); }
SimpleXmlFactory { static Serializer createSerializer(CRestConfig crestConfig, Class<?> source){ String prefix = source.getName(); Serializer serializer = crestConfig.get(prefix + SERIALIZER); if(serializer != null) { return serializer; } Map<Class, Transform> registry = new HashMap<Class, Transform>(); registry.put(Date.class, new DateMatcher(crestConfig.getDateFormat())); registry.put(Boolean.class, new BooleanMatcher(crestConfig.getBooleanTrue(), crestConfig.getBooleanFalse())); registry.put(boolean.class, registry.get(Boolean.class)); return new Persister(new MatcherRegistry(registry)); } private  SimpleXmlFactory();  }
SimpleXmlFactory { static Serializer createSerializer(CRestConfig crestConfig, Class<?> source){ String prefix = source.getName(); Serializer serializer = crestConfig.get(prefix + SERIALIZER); if(serializer != null) { return serializer; } Map<Class, Transform> registry = new HashMap<Class, Transform>(); registry.put(Date.class, new DateMatcher(crestConfig.getDateFormat())); registry.put(Boolean.class, new BooleanMatcher(crestConfig.getBooleanTrue(), crestConfig.getBooleanFalse())); registry.put(boolean.class, registry.get(Boolean.class)); return new Persister(new MatcherRegistry(registry)); } private  SimpleXmlFactory();   }