Created
January 25, 2023 17:13
-
-
Save m-tilab/241b72646cc83e3dda20b2f08f4e769c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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