Question
/** * Returns the value to which the specified flag is mapped as a {@link Path}, or {@code null} if * unable to retrieve this
/**
* Returns the value to which the specified flag is mapped as a {@link Path}, or {@code null} if
* unable to retrieve this mapping (including being unable to convert the value to a {@link Path}
* or no value exists).
*
* This method should not throw any exceptions!
*
* @param flag the flag whose associated value is to be returned
* @return the value to which the specified flag is mapped, or {@code null} if unable to retrieve
* this mapping
*
* @see Path#of(String, String...)
*/
public Path getPath(String flag) {
// TODO Fill in getPath method without looping
throw new UnsupportedOperationException("Not yet implemented.");
}
/**
* Returns the value the specified flag is mapped as a {@link Path}, or the default value if
* unable to retrieve this mapping (including being unable to convert the value to a {@link Path}
* or if no value exists).
*
* This method should not throw any exceptions!
*
* @param flag the flag whose associated value will be returned
* @param defaultValue the default value to return if there is no valid mapping
* @return the value the specified flag is mapped as a {@link Path}, or the default value if there
* is no valid mapping
*/
public Path getPath(String flag, Path defaultValue) {
// DO NOT MODIFY; THIS METHOD IS PROVIDED
Path value = getPath(flag);
return value == null ? defaultValue : value;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started