fmidev / fmi-avi-messageconverter-tac

Conversion module for aviation TAC messages
MIT License
1 stars 4 forks source link

Consider adding a default implementation for accepts() in AbstractTACBulletinSerializer #144

Open kasarit opened 1 year ago

kasarit commented 1 year ago

Consider provididing a default implementation in the superclass instead of duplicating the accepts method in every subclass. E.g.

protected T accepts(final AviationWeatherMessageOrCollection message) throws SerializingException {
    final Class<T> bulletinClass = getBulletinClass();
    if (bulletinClass.isInstance(message)) {
        return bulletinClass.cast(message);
    } else {
        throw new SerializingException("Can only serialize " + bulletinClass.getSimpleName());
    }
}

And then remove each override doing the same thing.

_Originally posted by @petringo in https://github.com/fmidev/fmi-avi-messageconverter-tac/pull/117#discussion_r989679365_