001package org.intellimate.izou.sdk.frameworks.permanentSoundOutput.events; 002 003import org.intellimate.izou.identification.Identification; 004import org.intellimate.izou.sdk.events.CommonEvents; 005import org.intellimate.izou.sdk.events.Event; 006import org.intellimate.izou.sdk.frameworks.common.resources.SelectorResource; 007import org.intellimate.izou.system.sound.SoundIDs; 008 009import java.util.ArrayList; 010import java.util.Arrays; 011import java.util.Optional; 012 013/** 014 * signals that every sound-output should unmute 015 * @author LeanderK 016 * @version 1.0 017 */ 018public class UnMuteEvent extends Event { 019 public static final String ID = SoundIDs.UnMuteEvent.descriptor; 020 /** 021 * Creates a new Event Object 022 * 023 * @param source the source of the Event, most likely a this reference. 024 * @throws IllegalArgumentException if one of the Arguments is null or empty 025 */ 026 protected UnMuteEvent(Identification source) 027 throws IllegalArgumentException { 028 super(CommonEvents.Type.RESPONSE_TYPE, source, new ArrayList<>(Arrays.asList(ID, 029 CommonEvents.Descriptors.STOP_DESCRIPTOR))); 030 } 031 032 /** 033 * creates a new StopEvent 034 * @param source the caller 035 * @param target the target who should start playing 036 * @return the optional StartMusicRequest 037 */ 038 public static Optional<UnMuteEvent> createUnMuteEvent(Identification source, Identification target) { 039 if (target == null || target.equals(source)) 040 return Optional.empty(); 041 try { 042 UnMuteEvent unmuteRequest = new UnMuteEvent(source); 043 unmuteRequest.addResource(new SelectorResource(source, target)); 044 return Optional.of(unmuteRequest); 045 } catch (IllegalArgumentException e) { 046 return Optional.empty(); 047 } 048 } 049}