37 lines
548 B
Java
Executable File
37 lines
548 B
Java
Executable File
package org.hwo.io.NewSerialPort;
|
|
|
|
public enum Parity {
|
|
NONE(0),EVEN(1),ODD(2);
|
|
private final int value;
|
|
|
|
private Parity(int v){
|
|
this.value = v;
|
|
}
|
|
|
|
public static Parity fromLetter(String letter){
|
|
if (letter.equals("N"))
|
|
return NONE;
|
|
if (letter.equals("E"))
|
|
return EVEN;
|
|
if (letter.equals("O"))
|
|
return ODD;
|
|
return null;
|
|
}
|
|
|
|
public int getValue(){
|
|
return this.value;
|
|
}
|
|
|
|
public String getLetter(){
|
|
switch (this.value){
|
|
case 0:
|
|
return "N";
|
|
case 1:
|
|
return "E";
|
|
case 2:
|
|
return "O";
|
|
}
|
|
return "";
|
|
}
|
|
}
|