public static Optional < TrackInfo > importFromHashMap ( HashMap < String , Object > hashMap ) { try { String name = ( String ) hashMap . get ( nameDescriptor ) ; String album = ( String ) hashMap . get ( albumDescriptor ) ; String artist = ( String ) hashMap . get ( artistDescriptor ) ; byte [ ] albumCover = ( byte [ ] ) hashMap . get ( albumCoverDescriptor ) ; String albumCoverFormat = ( String ) hashMap . get ( albumCoverFormatDescriptor ) ; String data = ( String ) hashMap . get ( dataDescriptor ) ; String year = ( String ) hashMap . get ( yearDescriptor ) ; String genre = ( String ) hashMap . get ( genreDescriptor ) ; long duration = ( Long ) hashMap . get ( durationDescriptor ) ; String bmp = ( String ) hashMap . get ( bmpDescriptor ) ; return Optional . of ( new TrackInfo ( name , artist , album , albumCover , albumCoverFormat , data , year , genre , bmp , duration ) ) ; } catch ( ClassCastException e ) { return Optional . empty ( ) ; } }
returns the optional TrackInfo if the HashMap contains no malformed data