Question: Java Program to code a Middleware Router. You are asked to design a middleware router that allows you to create new paths and associate them
Java Program to code a Middleware Router.
You are asked to design a middleware router that allows you to create new paths and associate them with different values.
The format of a path is one or more concatenated strings of the form: followed by one or more lowercase English letters
void addRouteString path, String result : Creates a newpathand associates avalue
String callRouteString path: Returns the value associated withpathor returnsif the path doesn't exist.
eg:
Router.addRoutebar "result"
Router.callRoutebar output : "result"
Router.addRoutefoobaraa "result
Router.callRoutefoobaraa output: "result
Follow up :
Handle wildcard char eg For example, if addRoute is ab result and someone calls with callRouteaxyb it should return result
As the wildcard char will match with xy part. Expectation was to use a pattern matching library and somehow handle it in addRoute method
Follow up :
Handle wildcard char eg For example, if addRoute is addRoutefoobarxxxyyy "result and someone calls with callRoutefooyyy it should return result
As the wildcard char will match with xxxyyy part.
Consider the following:
Use the Design principles and design patterns in the code
Write Executable code with Junit Tests and Console Tests.
How can we use this code in concurrent environment?
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
