PlacemarkDescriptorRegistry { public Set<PlacemarkDescriptor> getPlacemarkDescriptors() { return serviceRegistry.getServices(); } 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 testOrderOfValidPlacemarkDescriptors() 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); SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder(); builder.setName("n"); SimpleFeatureType featureType = builder.buildFeatureType(); List<PlacemarkDescriptor> descriptors = registry.getPlacemarkDescriptors(featureType); assertEquals(4, descriptors.size()); PlacemarkDescriptor descriptor = descriptors.get(0); assertSame(DecodeQualification.INTENDED, descriptor.getCompatibilityFor(null)); assertSame(first, descriptor); descriptor = descriptors.get(1); assertSame(DecodeQualification.INTENDED, descriptor.getCompatibilityFor(null)); assertSame(second, descriptor); descriptor = descriptors.get(2); assertSame(DecodeQualification.SUITABLE, descriptor.getCompatibilityFor(null)); assertTrue(descriptor == third || descriptor == fourth); descriptor = descriptors.get(3); assertSame(DecodeQualification.SUITABLE, descriptor.getCompatibilityFor(null)); assertTrue(descriptor == third || descriptor == fourth); }