PlacemarkDescriptorRegistry { public PlacemarkDescriptor getPlacemarkDescriptor(Class<? extends PlacemarkDescriptor> clazz) { return getPlacemarkDescriptor(clazz.getName()); } PlacemarkDescriptorRegistry(ServiceRegistry<PlacemarkDescriptor> serviceRegistry); private  PlacemarkDescriptorRegistry(); static PlacemarkDescriptorRegistry getInstance(); static void setInstance(PlacemarkDescriptorRegistry instance); PlacemarkDescriptor getPlacemarkDescriptor(Class<? extends PlacemarkDescriptor> clazz); PlacemarkDescriptor getPlacemarkDescriptor(String className); Set<PlacemarkDescriptor> getPlacemarkDescriptors(); List<PlacemarkDescriptor> getPlacemarkDescriptors(final SimpleFeatureType featureType); PlacemarkDescriptor getPlacemarkDescriptor(SimpleFeatureType featureType); final static String PROPERTY_NAME_PLACEMARK_DESCRIPTOR; }
@Test public void testGetBestPlacemarkDescriptor_Intended() throws Exception { DefaultServiceRegistry<PlacemarkDescriptor> serviceRegistry = new DefaultServiceRegistry<PlacemarkDescriptor>(PlacemarkDescriptor.class); PlacemarkDescriptor first = new IntendedPlacemarkDescriptorWithPlacemarkDescriptorProperty(); PlacemarkDescriptor second = new IntendedPlacemarkDescriptorWithoutProperty(); PlacemarkDescriptor third = new SuitablePlacemarkDescriptor_1(); PlacemarkDescriptor fourth = new SuitablePlacemarkDescriptor_2(); serviceRegistry.addService(fourth); serviceRegistry.addService(second); serviceRegistry.addService(first); serviceRegistry.addService(third); PlacemarkDescriptorRegistry registry = new PlacemarkDescriptorRegistry(serviceRegistry); PlacemarkDescriptor bestPlacemarkDescriptor = registry.getPlacemarkDescriptor((SimpleFeatureType) null); assertSame(first, bestPlacemarkDescriptor); }
@Test public void testGetBestPlacemarkDescriptor_Suitable() throws Exception { DefaultServiceRegistry<PlacemarkDescriptor> serviceRegistry = new DefaultServiceRegistry<PlacemarkDescriptor>(PlacemarkDescriptor.class); PlacemarkDescriptor first = new SuitablePlacemarkDescriptor_1(); PlacemarkDescriptor second = new SuitablePlacemarkDescriptor_2(); serviceRegistry.addService(first); serviceRegistry.addService(second); PlacemarkDescriptorRegistry registry = new PlacemarkDescriptorRegistry(serviceRegistry); PlacemarkDescriptor bestPlacemarkDescriptor = registry.getPlacemarkDescriptor((SimpleFeatureType) null); assertTrue(bestPlacemarkDescriptor == first || bestPlacemarkDescriptor == second); }