Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@m-tilab
Created January 25, 2023 17:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save m-tilab/241b72646cc83e3dda20b2f08f4e769c to your computer and use it in GitHub Desktop.
Save m-tilab/241b72646cc83e3dda20b2f08f4e769c to your computer and use it in GitHub Desktop.
public class SearchService {
//Method Overloading example. SortOrder is defaulted in this method
public String search(String type, String sortBy) {
return getQuerySummary(type, sortBy, SortOrder.DESC);
}
/* Method Overloading example. SortBy is defaulted in this method. Note that the type has to be
different here to overload the method */
public String search(String type, SortOrder sortOrder) {
return getQuerySummary(type, "price", sortOrder);
}
private String getQuerySummary(String type, String sortBy, SortOrder sortOrder) {
return "Requesting shoes of type \"" + type + "\" sorted by \"" + sortBy + "\" in \""
+ sortOrder.getValue() + "ending\" order...";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment