Skip to content

Commit

Permalink
Change put method of table map
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian Mendez committed Jun 10, 2017
1 parent 8cb1403 commit 15f601a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,19 @@ public interface TableMap {
* identifier
* @param table
* table
* @return an optional containing the previous value associated to the given
* key, or an empty optional if there was no association before
*/
void put(String id, Table table);
Optional<Table> put(String id, Table table);

/**
* Returns the table associated to the given identifier.
* Returns an optional containing the value associated to the given key, or
* an empty optional if there is no association.
*
* @param id
* identifier
* @return the table associated to the given identifier
* @return an optional containing the value associated to the given key, or
* an empty optional if there is no association
*/
Optional<Table> getTable(String id);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,38 +32,18 @@ public TableMapImpl(TableMap otherTableMap) {
otherTableMap.getTableIds().forEach(tableId -> put(tableId, otherTableMap.getTable(tableId).get()));
}

/**
* Returns the identifiers of the stored tables.
*
* @return the identifiers of the stored tables
*/
@Override
public List<String> getTableIds() {
List<String> ret = new ArrayList<>();
ret.addAll(this.map.keySet());
return ret;
}

/**
* Stores a table with the given identifier.
*
* @param id
* identifier
* @param table
* table
*/
@Override
public void put(String id, Table table) {
this.map.putOpt(id, table);
public Optional<Table> put(String id, Table table) {
return this.map.putOpt(id, table);
}

/**
* Returns the table associated to the given identifier.
*
* @param id
* identifier
* @return the table associated to the given identifier
*/
@Override
public Optional<Table> getTable(String id) {
return this.map.getOpt(id);
Expand Down

0 comments on commit 15f601a

Please sign in to comment.