@Test public void shouldUseGivenCRestConfigJaxb() throws Exception { Jaxb predefined = mock(Jaxb.class); when(mockCRestConfig.get(getClass().getName() + JaxbFactory.JAXB)).thenReturn(predefined); Jaxb actual = JaxbFactory.create(mockCRestConfig, getClass()); assertSame(predefined,actual); }
static Jaxb create(CRestConfig crestConfig, Class<?> source) throws JAXBException { String prefix = source.getName(); Jaxb jaxb = crestConfig.get(prefix + JAXB); if(jaxb != null) { return jaxb; } String modelPackage = crestConfig.get(prefix + MODEL_PACKAGE); if(modelPackage != null) { return create(crestConfig, source, modelPackage); } Class<?> modelFactory = crestConfig.get(prefix + MODEL_FACTORY_CLASS); if(modelFactory != null) { return create(crestConfig, source, modelFactory); } return new TypeCachingJaxb(crestConfig, source); }
JaxbFactory { static Jaxb create(CRestConfig crestConfig, Class<?> source) throws JAXBException { String prefix = source.getName(); Jaxb jaxb = crestConfig.get(prefix + JAXB); if(jaxb != null) { return jaxb; } String modelPackage = crestConfig.get(prefix + MODEL_PACKAGE); if(modelPackage != null) { return create(crestConfig, source, modelPackage); } Class<?> modelFactory = crestConfig.get(prefix + MODEL_FACTORY_CLASS); if(modelFactory != null) { return create(crestConfig, source, modelFactory); } return new TypeCachingJaxb(crestConfig, source); } }
JaxbFactory { static Jaxb create(CRestConfig crestConfig, Class<?> source) throws JAXBException { String prefix = source.getName(); Jaxb jaxb = crestConfig.get(prefix + JAXB); if(jaxb != null) { return jaxb; } String modelPackage = crestConfig.get(prefix + MODEL_PACKAGE); if(modelPackage != null) { return create(crestConfig, source, modelPackage); } Class<?> modelFactory = crestConfig.get(prefix + MODEL_FACTORY_CLASS); if(modelFactory != null) { return create(crestConfig, source, modelFactory); } return new TypeCachingJaxb(crestConfig, source); } private  JaxbFactory(); }
JaxbFactory { static Jaxb create(CRestConfig crestConfig, Class<?> source) throws JAXBException { String prefix = source.getName(); Jaxb jaxb = crestConfig.get(prefix + JAXB); if(jaxb != null) { return jaxb; } String modelPackage = crestConfig.get(prefix + MODEL_PACKAGE); if(modelPackage != null) { return create(crestConfig, source, modelPackage); } Class<?> modelFactory = crestConfig.get(prefix + MODEL_FACTORY_CLASS); if(modelFactory != null) { return create(crestConfig, source, modelFactory); } return new TypeCachingJaxb(crestConfig, source); } private  JaxbFactory();  }
JaxbFactory { static Jaxb create(CRestConfig crestConfig, Class<?> source) throws JAXBException { String prefix = source.getName(); Jaxb jaxb = crestConfig.get(prefix + JAXB); if(jaxb != null) { return jaxb; } String modelPackage = crestConfig.get(prefix + MODEL_PACKAGE); if(modelPackage != null) { return create(crestConfig, source, modelPackage); } Class<?> modelFactory = crestConfig.get(prefix + MODEL_FACTORY_CLASS); if(modelFactory != null) { return create(crestConfig, source, modelFactory); } return new TypeCachingJaxb(crestConfig, source); } private  JaxbFactory();   }