import com.pi4j.component.switches.MomentarySwitch;
import com.pi4j.component.switches.SwitchListener;
import com.pi4j.component.switches.SwitchStateChangeEvent;
import com.pi4j.component.switches.impl.GpioMomentarySwitchComponent;
import com.pi4j.io.gpio.GpioController;
import com.pi4j.io.gpio.GpioFactory;
import com.pi4j.io.gpio.GpioPinDigitalInput;
import com.pi4j.io.gpio.PinPullResistance;
import com.pi4j.io.gpio.PinState;
import com.pi4j.io.gpio.RaspiBcmPin;
import com.pi4j.io.gpio.RaspiPin;
import com.pi4j.io.gpio.event.GpioPinDigitalStateChangeEvent;
import com.pi4j.io.gpio.event.GpioPinListenerDigital;

/**
 * Here two pins are provisioned as input pins. One as the trigger that 
 * will launch a thread that will read and print another pins state.
 * 
 * @author Joseph Paul Cohen
 */
public class GPIOReadExample {

	public static void main(String[] args) throws Exception {
		
	final GpioController gpio = GpioFactory.getInstance();
	
	final GpioPinDigitalInput trigger = gpio.provisionDigitalInputPin(RaspiPin.GPIO_08, PinPullResistance.PULL_DOWN);
	final GpioPinDigitalInput input =   gpio.provisionDigitalInputPin(RaspiPin.GPIO_09, PinPullResistance.PULL_DOWN);
	
	MomentarySwitch ms = new GpioMomentarySwitchComponent(trigger);
	
	ms.addListener(new SwitchListener() {
		
		@Override
		public void onStateChange(SwitchStateChangeEvent event) {
			
			System.out.println(trigger.getPin() + " MomentarySwitch triggered!");
			
		}
	});
	
	
	trigger.addListener(new GpioPinListenerDigital(){
	
		@Override
		public void handleGpioPinDigitalStateChangeEvent(GpioPinDigitalStateChangeEvent event) {
			
			System.out.println(trigger.getPin() + " triggered!");
			
			PinState state = input.getState();
			
			if (state == PinState.HIGH)
				System.out.println(input.getPin() + " is high");
			else
				System.out.println(input.getPin() + " is low");
		}
		
	});
	
	while (true){
	    Thread.sleep(500);
	}
	}
}

@@ -1183,283 +1183,8 @@
 ;%0A%09%0A
-%09MomentarySwitch ms = new GpioMomentarySwitchComponent(trigger);%0A%09%0A%09ms.addListener(new SwitchListener() %7B%0A%09%09%0A%09%09@Override%0A%09%09public void onStateChange(SwitchStateChangeEvent event) %7B%0A%09%09%09%0A%09%09%09System.out.println(trigger.getPin() + %22 MomentarySwitch triggered!%22);%0A%09%09%09%0A%09%09%7D%0A%09%7D);%0A%09%0A%09%0A
 %09tri

clean code