Problems with Property classes when extended via anonymous class

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Problems with Property classes when extended via anonymous class

Draško
Hi there,

The following code

    java.net.URI albumArtUri = albumContainer.getFirstPropertyValue(DIDLObject.Property.UPNP.ALBUM_ART_URI.class);

sets albumArtUri to null, even thought albumContainer.getProperties() contains one object with description "albumArtURI".

After some debugging it came out that
 property.getClass().isAssignableFrom(DIDLObject.Property.UPNP.ALBUM_ART_URI.class) gives false,
 while DIDLObject.Property.UPNP.ALBUM_ART_URI.class.isInstance(property) gives true.

Is there anything speaking against modifying the method DIDLObject#getFirstProperty from

    public <V> Property<V> getFirstProperty(java.lang.Class<? extends Property<V>> propertyClass) {
        for (Property property : getProperties()) {
            if (property.getClass().isAssignableFrom(propertyClass)) return property;
        }
        return null;
    }

to

    public <V> Property<V> getFirstProperty(java.lang.Class<? extends Property<V>> propertyClass) {
        for (Property property : getProperties()) {
            if (propertyClass.isInstance(property)) return property;
        }
        return null;
    }


If not, I would submit a pull request.

Thanks,
Draško
Reply | Threaded
Open this post in threaded view
|

Re: Problems with Property classes when extended via anonymous class

Christian Bauer
Administrator
Sure, with a regression test would be great.