001package com.pi4j.io.gpio; 002 003/* 004 * #%L 005 * ********************************************************************** 006 * ORGANIZATION : Pi4J 007 * PROJECT : Pi4J :: Java Library (Core) 008 * FILENAME : PinEdge.java 009 * 010 * This file is part of the Pi4J project. More information about 011 * this project can be found here: http://www.pi4j.com/ 012 * ********************************************************************** 013 * %% 014 * Copyright (C) 2012 - 2013 Pi4J 015 * %% 016 * Licensed under the Apache License, Version 2.0 (the "License"); 017 * you may not use this file except in compliance with the License. 018 * You may obtain a copy of the License at 019 * 020 * http://www.apache.org/licenses/LICENSE-2.0 021 * 022 * Unless required by applicable law or agreed to in writing, software 023 * distributed under the License is distributed on an "AS IS" BASIS, 024 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 025 * See the License for the specific language governing permissions and 026 * limitations under the License. 027 * #L% 028 */ 029 030/** 031 * Pin edge definition. 032 * 033 * @author Robert Savage (<a 034 * href="http://www.savagehomeautomation.com">http://www.savagehomeautomation.com</a>) 035 */ 036public enum PinEdge { 037 038 NONE(0, "none"), 039 BOTH(1, "both"), 040 RISING(2, "rising"), 041 FALLING(3, "falling"); 042 043 private final int value; 044 private final String name; 045 046 private PinEdge(int value, String name) { 047 this.value = value; 048 this.name = name; 049 } 050 051 public int getValue() { 052 return value; 053 } 054 055 public String getName() { 056 return name; 057 } 058 059 @Override 060 public String toString() { 061 return name; 062 } 063 064 public static PinEdge getEdge(int edge) { 065 for (PinEdge item : PinEdge.values()) { 066 if (item.getValue() == edge) { 067 return item; 068 } 069 } 070 return null; 071 } 072} 073