Skip to content

Commit

Permalink
Add ITablesHandler (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniilSolovyov and sda authored May 7, 2024
1 parent 4b4cc31 commit ea2dc50
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ To provide certain functionality which can be used by unTill(r) POS, driver must
- [ITimeAttendance](docs/time_and_attendance.md) - implement for handling time and attendance operations (clock in, end break)
- [IPosPrinter](docs/pos_printer.md) - implement for handling POS printer operations (print, upload logo)
- [IExportHandler](docs/export_handler.md) - implement for handling exports
- [ITablesHandler](docs/tables_handler.md) - implement for handling table events

Declaration of supported interfaces is made by `init` method which is called at driver initialization stage. Driver must return a map of supported interfaces:
```java
Expand Down
18 changes: 18 additions & 0 deletions docs/tables_handler.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Tables operations handler - ITablesHandler
POS invokes this interface when
- Table is dirty
- Table is clean
Example implementation
```java
public class TablesHandler implements ITablesHandler {

@Override
public void operation(DriverConfiguration cfg, TableChangedRequest req) {
if (req instanceof TableDirtyChangedRequest) {
return handleTableDirtyChangedRequest(cfg, req);
} else {
throw new IllegalArgumentException("Operation not supported");
}
}
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.untill.driver.interfaces.tables;

import com.untill.driver.IDriver;
import com.untill.driver.interfaces.IDriverInterface;
import com.untill.driver.params.DriverConfiguration;

/**
* Tables handler driver interface
*
* @see IDriverInterface
* @see IDriver
*/
public interface ITablesHandler extends IDriverInterface {
/**
* Handles table operations
*
* @param cfg driver instance configuration
* @param req request details
*/
void operation(DriverConfiguration cfg, TableChangedRequest req);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.untill.driver.interfaces.tables;

import com.untill.driver.interfaces.DriverRequest;

public abstract class TableChangedRequest extends DriverRequest {
/**
* Table number
*/
private int tableNumber;
/**
* Table part
*/
private String tablePart;

public int getTableNumber() {
return tableNumber;
}

public void setTableNumber(int tableNumber) {
this.tableNumber = tableNumber;
}

public String getTablePart() {
return tablePart;
}

public void setTablePart(String tablePart) {
this.tablePart = tablePart;
}

@Override
public String toString() {
return "TableChangedRequest{"
+ "tableNumber=" + tableNumber
+ ", tablePart='" + tablePart + '\''
+ "} " + super.toString();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.untill.driver.interfaces.tables;

public class TableDirtyChangedRequest extends TableChangedRequest {
/**
* The flag is <tt>true</tt> if the <tt>Sales area</tt> setting <tt>Close tables manually</tt> is checked and everything is paid otherwise <tt>false</tt>
*/
private boolean dirty;

public boolean isDirty() {
return dirty;
}

public void setDirty(boolean dirty) {
this.dirty = dirty;
}

@Override
public String toString() {
return "TableDirtyChangedRequest{"
+ "dirty=" + dirty
+ "} " + super.toString();
}
}

0 comments on commit ea2dc50

Please sign in to comment.