Custom filter for images (getCaption) in table

I created CustomFilter for filtering rows in table by caption from images…

It seems to works ok, but exist possibility to do it in prettier way… (especially passesFilter method)?

        class CustomFilter implements Container.Filter
    {
        protected String propertyId;
        protected String type;

        public CustomFilter (String propertyId, String type)
        {
            this.propertyId = propertyId;
            this.type = type;
        }

        @Override
        public boolean passesFilter(Object itemId, Item item) throws UnsupportedOperationException
        {
            Property<?> property = table.getContainerProperty(itemId, propertyId);
            if (property != null) {
                
                return ((Image)property.getValue()).getCaption().equals(type);
            }  
            return false;
        }

        @Override
        public boolean appliesToProperty(Object propertyId)
        {
            return propertyId != null && propertyId.equals(this.propertyId);
        }
    }

How do you populate the image captions? Would it be possible to add the image caption as a property to the container and then use Vaadin’s Compare.Equal filter, thus there wouldn’t be a need for a custom filter. You can hide the extra property from the table by calling setVisibleColumns for the table.