-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from Cellebyte/master
[#27 printer-state] Added support for printer-state in CupsPrinter
- Loading branch information
Showing
3 changed files
with
79 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package org.cups4j; | ||
|
||
public enum PrinterStateEnum { | ||
IDLE(3, "idle"), PRINTING(4, "printing"), STOPPED(5, "stopped"); | ||
|
||
private Integer value; | ||
private String stateName; | ||
|
||
PrinterStateEnum(Integer value, String stateName) { | ||
this.value = value; | ||
this.stateName = stateName; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return this.stateName; | ||
} | ||
|
||
public Integer getValue() { | ||
return value; | ||
} | ||
public String getStateName() { | ||
return stateName; | ||
} | ||
|
||
public static PrinterStateEnum fromInteger(Integer value) { | ||
if (value != null) { | ||
for (PrinterStateEnum printerState : PrinterStateEnum.values()) { | ||
if (value == printerState.getValue()) { | ||
return printerState; | ||
} | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
public static PrinterStateEnum fromStringInteger(String value) { | ||
if (value != null) { | ||
for (PrinterStateEnum printerState : PrinterStateEnum.values()) { | ||
if (value.equalsIgnoreCase(printerState.getValue().toString())) { | ||
return printerState; | ||
} | ||
} | ||
} | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters