public static Optional < PlaybackState > getPlaybackStateFromResource ( ResourceModel x ) { if ( ! x . getResourceID ( ) . equals ( ID ) ) return Optional . empty ( ) ; Object resource = x . getResource ( ) ; if ( resource instanceof String ) { String state = ( String ) resource ; try { return Optional . of ( PlaybackState . valueOf ( state ) ) ; } catch ( IllegalArgumentException e ) { return Optional . empty ( ) ; } } else { return Optional . empty ( ) ; } }
returns the PlaybackState from the resource