src/main/java/org/intellimate/izou/sdk/frameworks/music/player/template/Player.java
private void handleCommands(EventModel eventModel) {
        Consumer<Runnable> checkOrCall = runnable -> {
            List<ResourceModel> resourceModels = eventModel.getListResourceContainer()
                    .provideResource(SelectorResource.RESOURCE_ID);
            if (resourceModels.isEmpty()) {
                runnable.run();
            } else {
                resourceModels.stream()
                        .map(resourceModel -> resourceModel.getResource() instanceof Identification ?
                                ((Identification) resourceModel.getResource()) : null)
                        .filter(Objects::nonNull)
                        .filter(this::isOwner)
                        .findAny()
                        .ifPresent(id -> runnable.run());
            }
        };
        if (eventModel.containsDescriptor(MuteEvent.ID)) {
            checkOrCall.accept(this::mute);
        }
        if (eventModel.containsDescriptor(UnMuteEvent.ID)) {
            checkOrCall.accept(this::unMute);
        }
        if (eventModel.containsDescriptor(StopEvent.ID)) {
            checkOrCall.accept(this::stopMusicPlayback);
        }
        if (StopMusic.verify(eventModel, this)) {
            stopMusicPlayback();
        }
        if (PlayerCommand.verify(eventModel, this)) {
            getCommandHandler().handleCommandResources(eventModel);
        }
    }
private void handleCommands(EventModel eventModel) {
        Consumer<Runnable> checkOrCall = runnable -> {
            List<ResourceModel> resourceModels = eventModel.getListResourceContainer()
                    .provideResource(SelectorResource.RESOURCE_ID);
            if (resourceModels.isEmpty()) {
                runnable.run();
            } else {
                resourceModels.stream()
                        .map(resourceModel -> resourceModel.getResource() instanceof Identification ?
                                ((Identification) resourceModel.getResource()) : null)
                        .filter(Objects::nonNull)
                        .filter(this::isOwner)
                        .findAny()
                        .ifPresent(id -> runnable.run());
            }
        };
        if (eventModel.containsDescriptor(MuteEvent.ID)) {
            checkOrCall.accept(this::mute);
        }
        if (eventModel.containsDescriptor(UnMuteEvent.ID)) {
            checkOrCall.accept(this::unMute);
        }
        if (eventModel.containsDescriptor(StopEvent.ID)) {
            checkOrCall.accept(this::stopMusicPlayback);
        }
        if (StopMusic.verify(eventModel, this)) {
            stopMusicPlayback();
        }
        if (PlayerCommand.verify(eventModel, this)) {
            getCommandHandler().handleCommandResources(eventModel);
        }
    }
private void handleCommands ( EventModel eventModel ) { Consumer < Runnable > checkOrCall = runnable -> { List < ResourceModel > resourceModels = eventModel . getListResourceContainer ( ) . provideResource ( SelectorResource . RESOURCE_ID ) ; if ( resourceModels . isEmpty ( ) ) { runnable . run ( ) ; } else { resourceModels . stream ( ) . map ( resourceModel -> resourceModel . getResource ( ) instanceof Identification ? ( ( Identification ) resourceModel . getResource ( ) ) : null ) . filter ( Objects :: nonNull ) . filter ( this :: isOwner ) . findAny ( ) . ifPresent ( id -> runnable . run ( ) ) ; } } ; if ( eventModel . containsDescriptor ( MuteEvent . ID ) ) { checkOrCall . accept ( this :: mute ) ; } if ( eventModel . containsDescriptor ( UnMuteEvent . ID ) ) { checkOrCall . accept ( this :: unMute ) ; } if ( eventModel . containsDescriptor ( StopEvent . ID ) ) { checkOrCall . accept ( this :: stopMusicPlayback ) ; } if ( StopMusic . verify ( eventModel , this ) ) { stopMusicPlayback ( ) ; } if ( PlayerCommand . verify ( eventModel , this ) ) { getCommandHandler ( ) . handleCommandResources ( eventModel ) ; } }
handles the commands encoded as Resources/EventIds
@param eventModel the eventModel to check
handles the commands encoded as Resources / EventIds