Most of time while devleoping Apex Code, we face many business requirements for which we develop our own logic and methods. Most of us written many useful methods so far in their development. So, my idea is simple. I welcome all of you to contribute your common useful apex methods with me and complete my "SFApexUtilFunctions" class. I have started this class with some of my reused methods. If we all contribute our useful methods then i am sure we will have a good library written which will be useful for all of us.
The format for contributing your methods will be like given as per below with the proper comments on method top describing method and author. You can post in blog itself or mail me. I will inform the newly added methods to all and update the actual class also. One can download the latest version of class from this url:
http://www.aslambari.com/SFApexUtilFunctions.cls
The format for contributing your methods will be like given as per below with the proper comments on method top describing method and author. You can post in blog itself or mail me. I will inform the newly added methods to all and update the actual class also. One can download the latest version of class from this url:
http://www.aslambari.com/SFApexUtilFunctions.cls
/**
@ Name SFApexUtilFunctions
@ Author Aslam Bari
@ Created Date 31 March, 2011
@ Description A utility methods class for helping developers community
*/
public class SFApexUtilFunctions{
/**
@ Name join
@ Author Aslam Bari
@ Created Date 31 March, 2011
@ Desctiption Join one list of String to a full string
@ Param List<String>: list of string data
@ Param separator: the string by which the list is joined
*/
public static string join(List<String> lstArg, String separator){
String fullString = '';
for(String item: lstArg){
fullString += item + separator;
}
if(fullString.length() > 0)
fullString = fullString.substring(0, fullString.length() - 1);
return fullString;
}
/**
@ Name getUrlContents
@ Author Aslam Bari
@ Created Date 31 March, 2011
@ Desctiption Fetch the contents of remote url
@ Param url: remote url with all parameters attached to url for GET call
*/
public static string getUrlContents(String url){
HttpRequest request = new HttpRequest();
request.setEndPoint(url);
request.setMethod('GET');
Http call = new Http();
HttpResponse response = call.send(request);
return response.getBody();
}
}
So start now and lets contribute :)
Thanks
Aslam Bari