I want to print the all values in the array but it just prints the last value int the array, how can I get my desired result by improving this code:
public void applyAttendence(ArrayList<String> presents, ArrayList<String> absents) {
ArrayList<String> present = new ArrayList<String>();
HashMap params = new HashMap();
// [232, 232, 12, 223]
String[] stringArray = presents.toArray(new String[0]);
if (presents.size() == 0) {
params.put("present", "");
} else {
// for(String pre:presents) {
params.put("present", stringArray);
System.out.println(" present[]" + presents);
System.out.println("hellow present man: " + params.get("present"));
// }
System.out.println("hellow present man: " + params.get("present"));
}
if (absents.size() == 0) {
params.put("absent", "");
} else {
for (String abs : absents) {
params.put("absent[]", abs);
}
// params.put("present[]", presents + "");
//
params.put("absent[]", absents + "");
}
}
That is because you are overwriting same key with different value every time
for (String abs : absents) {
params.put("absent[]", abs);
}
So your hashmap will only have last value written against the key absent[]
This is may be you have defined array as:
String[] stringArray = presents.toArray(new String[0]);
try initializing as:
String[] stringArray = new String[presents.size()];
stringArray = presents.toArray(stringArray );
Try this simplified solution to show all of the attendance
public void applyAttendence(ArrayList<String> presents, ArrayList<String> absents) {
String sPresent = "";
for (String present : presents) {
sPresent += present + ", ";
}
if (!sPresent.equals(""))
sPresent = sPresent.substring(0, sPresent.length() - 2);
String sAbsent = "";
for (String absent : absents) {
sAbsent += absent + ", ";
}
if (!sAbsent.equals(""))
sAbsent = sAbsent.substring(0, sAbsent.length() - 2);
if (presents.size() > 0) {
System.out.println("present = " + sPresent);
} else {
System.out.println("present = no one");
}
if (absents.size() > 0) {
System.out.println("absent = " + sAbsent);
} else {
System.out.println("absent = no one");
}
}
Related
Someone, please assist to change the method 'getBabyNameFrequencies' in class 'Result' from using HarshMap to a normal String method as is in the main/feeder class 'Solution'
/*
* The function is expected to return a STRING.
* The function accepts the following parameters:
* 1. STRING names
* 2. STRING synonyms
*/
class Solution {
private Map<String, Integer> mp = new HashMap<>();
private Map<String, String> p = new HashMap<>();
public String[] getBabyNameFrequencies(String[] names, String[] synonyms) {
for (String e : names) {
int idx = e.indexOf("(");
String name = e.substring(0, idx);
int w = Integer.parseInt(e.substring(idx + 1, e.length() - 1));
mp.put(name, w);
p.put(name, name);
}
for (String e : synonyms) {
int idx = e.indexOf(",");
String name1 = e.substring(1, idx);
String name2 = e.substring(idx + 1, e.length() - 1);
if (!mp.containsKey(name1)) {
mp.put(name1, 0);
}
if (!mp.containsKey(name2)) {
mp.put(name2, 0);
}
p.put(name1, name1);
p.put(name2, name2);
}
for (String e : synonyms) {
int idx = e.indexOf(",");
String name1 = e.substring(1, idx);
String name2 = e.substring(idx + 1, e.length() - 1);
union(name1, name2);
}
List<String> t = new ArrayList<>();
for (Map.Entry<String, Integer> e : mp.entrySet()) {
String name = e.getKey();
if (Objects.equals(name, find(name))) {
t.add(name + "(" + e.getValue() + ")");
}
}
String[] res = new String[t.size()];
for (int i = 0; i < res.length; ++i) {
res[i] = t.get(i);
}
return res;
}
private String find(String x) {
if (!Objects.equals(p.get(x), x)) {
p.put(x, find(p.get(x)));
}
return p.get(x);
}
private void union(String a, String b) {
String pa = find(a), pb = find(b);
if (Objects.equals(pa, pb)) {
return;
}
if (pa.compareTo(pb) > 0) {
mp.put(pb, mp.getOrDefault(pb, 0) + mp.getOrDefault(pa, 0));
p.put(pa, pb);
} else {
mp.put(pa, mp.getOrDefault(pa, 0) + mp.getOrDefault(pb, 0));
p.put(pb, pa);
}
}
}
The Solution Class/ Feeder Class with the Main method.
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH")));
String names = bufferedReader.readLine();
String synonyms = bufferedReader.readLine();
String result = Result.getBabyNameFrequencies(names, synonyms);
bufferedWriter.write(result);
bufferedWriter.newLine();
bufferedReader.close();
bufferedWriter.close();
}
}
In my code, the method is able to read the .txt file and puts the integers in one side of the array, and the double in another. However, in the output there are duplicates, and i'm trying to put them in ascending order with no duplicates.
public static void readFile(String file) throws FileNotFoundException
{
Scanner s1 = new Scanner(new File(file));
String[][] container = new String[2][2];
int intIndex = 0;
int doubleIndex = 0;
while(s1.hasNextLine())
{
String line = s1.nextLine();
System.out.println(line);
System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
String[] splitLine = line.split(" ");
for (String text : splitLine) {
if (text.matches("\\d*"))
{
System.out.println(text + " is int");
if (container[0].length == intIndex)
{
container[0] = Arrays.copyOf(container[0], intIndex + 2); //add two more slot to int array
container[1] = Arrays.copyOf(container[1], intIndex + 2); //add two more slot to double array
}
container[0][intIndex] = (text); //add to container
intIndex++; //adjust the index
} else if (text.matches("\\d*.\\d*"))
{
System.out.println(text + " is double");
if (container[1].length == doubleIndex)
{
container[0] = Arrays.copyOf(container[0], doubleIndex + 2); //add two more slot to int array
container[1] = Arrays.copyOf(container[1], doubleIndex + 2); //add two more slot to double array
}
container[1][doubleIndex] = (text); //add to container
doubleIndex++; //adjust the index
} else
{
System.out.println(text + " is not int nor double");
}
}
}
System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
Arrays.sort(container[0], Comparator.nullsLast(Comparator.naturalOrder())); //sort array of int
Arrays.sort(container[1], Comparator.nullsLast(Comparator.naturalOrder())); //sort array of double
System.out.println(Arrays.toString(container[0]));
System.out.println(Arrays.toString(container[1]));
System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
}
The .txt file includes this all in one line, "10 5five 10 1.5 2 2.0 20"
I expect the output to be:
[2, 10, 20]
[1.5, 2.0]
However, the actual output i get is:
[10, 10, 2, 20]
[1.5, 2.0, null, null]
public static void readFile(String file) throws FileNotFoundException
{
Scanner s1 = new Scanner(new File(file));
String[][] container = new String[2][2];
int intIndex = 0;
int doubleIndex = 0;
while(s1.hasNextLine())
{
String line = s1.nextLine();
System.out.println(line);
System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
String[] splitLine = line.split(" ");
for (String text : splitLine) {
if (text.matches("\\d*"))
{
System.out.println(text + " is int");
//checking the array for duplicates
if (Arrays.stream(container[0]).anyMatch(text::equals)) {
continue;
}
if (container[0].length == intIndex)
{
container[0] = Arrays.copyOf(container[0], intIndex + 2);
container[1] = Arrays.copyOf(container[1], doubleIndex + 2);
}
container[0][intIndex] = (text);
intIndex++; //adjust the index
} else if (text.matches("\\d*.\\d*"))
{
System.out.println(text + " is double");
//checking the array for duplicates
if (Arrays.stream(container[1]).anyMatch(text::equals)) {
continue;
}
if (container[1].length == doubleIndex)
{
container[0] = Arrays.copyOf(container[0], intIndex + 2);
container[1] = Arrays.copyOf(container[1], doubleIndex + 2);
}
container[1][doubleIndex] = (text);
doubleIndex++;
} else
{
System.out.println(text + " is not int nor double");
}
}
}
System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
//compare numerically rather than alphabetically in sorting
Arrays.sort(container[0], Comparator.nullsLast((e1, e2) ->
Integer.valueOf(e1).compareTo(Integer.valueOf(e2))));
Arrays.sort(container[1], Comparator.nullsLast((e1, e2) ->
Double.valueOf(e1).compareTo(Double.valueOf(e2))));
System.out.println(Arrays.toString(container[0]));
System.out.println(Arrays.toString(container[1]));
System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
}
Let's say we have two strings (ULRs):
https://stackoverflow.com/questions/ask
https://web.whatsapp.com/
I need to write expression such as:
if after 3rd slash (/) is nothing or 3rd slash does not exists do
{
some operation
} else {
another action
}
Please help.
List<String> list = new ArrayList<String>();
while((str = in.readLine()) != null){
list.add(str);
}
String[] stringArr = list.toArray(new String[0]);
//copying and removing https from the list
List<String> list2 = new ArrayList<String>();
Collections.addAll(list2, stringArr);
Iterator<String> iter = list2.iterator();
while(iter.hasNext()){
if(iter.next().contains(https))
// here you should copy https lines to another file.
iter.remove();
}
String[] stringArr2 = list2.toArray(new String[0]);
for (int i = 0; i<stringArr2.length; i++) {
//condition for pure domain names.
//else the action below
System.out.println(getDomainName(stringArr2[i]) + "," + stringArr2[i] + "," + "U" +"," + number_of_doc + "," + today);
}
}
public static String getDomainName(String url) throws URISyntaxException {
URI uri = new URI(url);
String domain = uri.getHost();
return domain.startsWith("www.") ? domain.substring(4) : domain;
}
}
Why you don't split :
String link = "https://stackoverflow.com/questions/ask ";
if (link.split("/").length >= 3 ) {
System.out.println("CORRECT");
}else{
System.out.println("NOT CORRECT");
}
The idea is : Split your String with / if the result is great or equal then 3 then your condition is correct, else not correct.
Edit
Or like #biziclop mention in comment you can use Guava's Splitter for example :
Iterable<String> result =
Splitter.on(CharMatcher.anyOf("/")).
limit(4).
split("https://stackoverflow.com/questions/ask");
if (Lists.newArrayList(result).size() > 3) {
System.out.println(Lists.newArrayList(result).get(3));
}else{
System.out.println("NOTHING");
}
Input
https://stackoverflow.com/questions/ask
https://stackoverflow.com
Output
questions/ask
NOTHING
You can use simple regex:
String url = "https://web.whatsapp.com/";
if(url.matches("\\w+://(\\w+.\\w+)+(.\\w+)*/(.+)"))
System.out.println("Correct URL");
else
System.out.println("Incorrect URL");
How can I split a flat string based on 0102**? string tokenizer is working for only **. Is there any way to split based on 0102**? Please suggest
Here is my complete method
private String handleCibil(InterfaceRequestVO ifmReqDto, String szExtIntType) throws MalformedURLException, org.apache.axis.AxisFault, RemoteException {
/* Declaration and initiliazation */
ConfVO confvo = ifmReqDto.getExtConfVo();
String szResponse = null;
String cibilResponse = null;
String errorResponse = null;
String endpointURL = null;
long timeOut = confvo.getBurMgr().getBurInfo(szExtIntType).getTimeOut();
endpointURL = formWebServiceURL(confvo, szExtIntType);
URL url = new URL(endpointURL);
log.debug("Input xml for cibil "+ifmReqDto.getIfmReqXML());
BasicHttpStub stub= new BasicHttpStub(url,new org.apache.axis.client.Service());
szResponse = stub.executeXMLString(ifmReqDto.getIfmReqXML());
//szResponse=szResponse.replaceAll("&", "&");
log.debug("szResponse "+szResponse);
/* Validate if the obtained response is as expected by IFM */
try {
extDao = new ExtInterfaceXMLTransDAO(ifmReqDto.getSemCallNo(), ifmReqDto.getIdService());
extDao.updateRqstRespXML10g(ifmReqDto.getInterfaceReqNum(), szResponse, GGIConstants.IFM_RESPONSE);
//log.debug("CIBIL_RESPONSE_XPATH " + GGIConstants.CIBIL_RESPONSE_XPATH);
Document xmlDocument = DocumentHelper.parseText(szResponse);
String xPath = GGIConstants.RESPONSE_XPATH;
List<Node> nodes = xmlDocument.selectNodes(xPath);
for (Node node : nodes) {
String keyValue = node.valueOf(GGIConstants.RESPONSE_XPATH_KEY);
// log.debug("keyValue : " + keyValue);
if (keyValue.equalsIgnoreCase(GGIConstants.RESPONSE_XPATH_KEY_VALUE)) {
// log.debug("node value : " + node.getText());
cibilResponse = node.getText();
}
}
log.debug("cibilResponse " + cibilResponse);
String errorResponseXPATH = GGIConstants.CIBIL_ERROR_RESPONSE_XPATH;
List<Node> errorResponseNode = xmlDocument.selectNodes(errorResponseXPATH);
for (Node node : errorResponseNode) {
errorResponse = node.getText();
}
log.debug("errorResponse " + errorResponse);
if(cibilResponse!=null && cibilResponse.length()>0)
{
StringTokenizer cibilResponseResults = new StringTokenizer(cibilResponse,"**");
String tempResponse="";
ArrayList probableMatchList = new ArrayList();
while (cibilResponseResults.hasMoreElements()) {
tempResponse = (String) cibilResponseResults.nextElement();
if(tempResponse.length()>=80)
{
String memberRefNo = tempResponse.substring(69, 80).replaceAll(" ", "");
log.debug("memberRefNo " + memberRefNo);
if (memberRefNo.length() > 0) {
if (Integer.parseInt(memberRefNo) > 0) {
cibilResponse = tempResponse;
cibilResponse = cibilResponse+"**";
}
else
{
probableMatchList.add(tempResponse+"**");
}
}
else
{
probableMatchList.add(tempResponse+"**");
}
}
else
{
cibilResponse = tempResponse+"**";
}
}
log.debug("After finding the Member reference number cibilResponse " + cibilResponse);
log.debug("After finding the Probable reference list " + probableMatchList);
// TKN 008
cibilResponse=StringEscapeUtils.unescapeXml(cibilResponse).replaceAll("[^\\x20-\\x7e]","");
ifmReqDto.setIfmTransformedResult(cibilResponse);
ifmReqDto.setProbableMatchList(probableMatchList);
}
if (errorResponse!=null && errorResponse.length()>0) {
throw new GenericInterfaceException(errorResponse
+ " for the seq_request " + ifmReqDto.getSeqRequest() + " Seq_Interface_req is >> "
+ ifmReqDto.getInterfaceReqNum(),
GGIConstants.SEND_REQUEST_CONSTANT + Strings.padStart(String.valueOf(ifmReqDto.getIdService()), 2, GGIConstants.DEFAULT_NUMBER_STRING)
+ GGIConstants.CIBIL_ERROR_CODE);
}
else if (cibilResponse==null || StringUtils.isEmpty(cibilResponse) ) {
throw new GenericInterfaceException("Cibil TUEF response is empty >> cibil Service "
+ "for the seq_request " + ifmReqDto.getSeqRequest() + "Seq_Interface_req is >> "
+ ifmReqDto.getInterfaceReqNum(),
GGIConstants.SEND_REQUEST_CONSTANT + Strings.padStart(String.valueOf(ifmReqDto.getIdService()), 2, GGIConstants.DEFAULT_NUMBER_STRING)
+ GGIConstants.INTERFACE_ERROR_RESPONSE);
}
/* Setting Instinct response to ifmReqDto object */
} catch (SQLException e) {
log.error("SQLException while connecting to DataBase. Exception message is ", e);
throw new GenericInterfaceException("SQLException >> Instinct Service "
+ "for the seq_request " + ifmReqDto.getSeqRequest() + "Seq_Interface_req is >> "
+ ifmReqDto.getInterfaceReqNum(),
GGIConstants.SEND_REQUEST_CONSTANT + Strings.padStart(String.valueOf(ifmReqDto.getIdService()), 2, GGIConstants.DEFAULT_NUMBER_STRING)
+ GGIConstants.DB_OPERATION_ERROR);
} catch (GenericInterfaceException exp) {
log.error("Exception occured while valid:", exp);
throw exp;
} catch (Exception exp) {
log.error("Exception occured while valid:", exp);
throw new GenericInterfaceException("GeneralException >> Instinct Service "
+ "for the seq_request " + ifmReqDto.getSeqRequest() + "Seq_Interface_req is >> "
+ ifmReqDto.getInterfaceReqNum(),
GGIConstants.SEND_REQUEST_CONSTANT + Strings.padStart(String.valueOf(ifmReqDto.getIdService()), 2, GGIConstants.DEFAULT_NUMBER_STRING)
+ GGIConstants.UNKNOWN_ERROR);
}
return szResponse;
}
I recommend checking out the Java documentation, it provides a really good reference to start with. The .split method uses a regex to split up a string based on a delimiter.
String[] tokens = myString.split("0102\\*\\*");
For now I suspect that you forgot to escape * in split regex.
Try maybe
String[] resutl = yourString.split("0102\\*\\*");
In case you want * to represent any character then use . instead of *
String[] resutl = yourString.split("0102..");
In case you want * to represent any digit use \\d instead
String[] resutl = yourString.split("0102\\d\\d");
String string = "blabla0102**dada";
String[] parts = string.split("0102\\*\\*");
String part1 = parts[0]; // blabla
String part2 = parts[1]; // dada
Here we have a String: "blabla0102**dada", we call it string. Every String object has a method split(), using this we can split a string on anything we desire.
Do you mean literally split by "0102**"? Couldn't you use regex for that?
String[] tokens = "My text 0102** hello!".split("0102\\*\\*");
System.out.println(tokens[0]);
System.out.println(tokens[1]);
Hey guys can somebody show me a way good way of concatenating these strings with commas
Basically Im building a header criteria string showing which forms variables have been selected. I need to put commas in between the values and keep the break tags in place...can somebody see a better way to do it. I didnt want commas if there were just on value
This is what it looks like currently formatted:
protected final String getCriteriaHeader(MetricFilterCriteriaForm form)
{
String filterCriteria = "<br/>";
}
if (form.isSacNone() || form.isSac1() || form.isSac2() || form.isSac3())
{
filterCriteria = filterCriteria + "SAC:";
}
if (form.isSacNone())
{
filterCriteria = filterCriteria + " NONE";
}
if (form.isSac1())
{
filterCriteria = filterCriteria + " 1";
}
if (form.isSac2())
{
filterCriteria = filterCriteria + " 2";
}
if (form.isSac3())
{
filterCriteria = filterCriteria + " 3";
}
if (form.isSac1() || form.isSac2() || form.isSac3())
{
filterCriteria = filterCriteria + "<br/>";
}
if (form.isRegularScheduleType() || form.isLotScheduleType() || form.isBatchScheduleType())
{
filterCriteria = filterCriteria + "Schedule Type:";
}
if (form.isRegularScheduleType())
{
filterCriteria = filterCriteria + " Regular";
}
if (form.isLotScheduleType())
{
filterCriteria = filterCriteria + " Lot";
}
if (form.isBatchScheduleType())
{
filterCriteria = filterCriteria + " Batch";
}
return filterCriteria;
}
There are different ways to concatenate a set of values in a string with a separator.
With StringBuilder
Add the values with the comma, then remove the last comma manually.
StringBuilder sb = new StringBuilder();
if (/*condition1*/) {
sb.add("A,"); // value with comma
}
if (/*condition2*/) {
sb.add("B,");
}
sb.delete(sb.length()-1, sb.length()); // remove last character, which is the comma.
String result = sb.toString(); // get the result string.
With Guava's Joiner
Put it all in a List and use Joiner.
List<String> list = Lists.newArrayList();
if (/*condition1*/) {
list.add("A"); // no comma here
}
if (/*condition2*/) {
list.add("B");
}
String result = Joiner.on(",").join(list); // use Joiner to join elements of the list.
Alternatively to Guava, there is StringUtils.Join from Apache Common Lang. See #Iswanto San's answer.
You can use StringUtils.Join from Apache Common Lang
Example :
protected final String getCriteriaHeader(MetricFilterCriteriaForm form)
{
String filterCriteria = "<br/>";
List<String> sacs = new ArrayList<String>();
List<String> schedules = new ArrayList<String>();
if (form.isSacNone() || form.isSac1() || form.isSac2() || form.isSac3())
{
filterCriteria = filterCriteria + "SAC:";
}
if (form.isSacNone())
{
filterCriteria = filterCriteria + " NONE";
}
if (form.isSac1())
{
sacs.add(" 1");
}
if (form.isSac2())
{
sacs.add(" 2");
}
if (form.isSac3())
{
sacs.add(" 3");
}
filterCriteria += StringUtils.join(saces, ",");
if (form.isSac1() || form.isSac2() || form.isSac3())
{
filterCriteria = filterCriteria + "<br/>";
}
if (form.isRegularScheduleType() || form.isLotScheduleType() || form.isBatchScheduleType())
{
filterCriteria = filterCriteria + "Schedule Type:";
}
if (form.isRegularScheduleType())
{
schedules.add(" Regular");
}
if (form.isLotScheduleType())
{
schedules.add(" Lot");
}
if (form.isBatchScheduleType())
{
schedules.add(" Batch");
}
filterCriteria+=StringUtils.join(schedules, ",");
return filterCriteria;
}
At first avoid creating so much String instances by using StringBuilder. Then nest the conditions to speed things up a bit and to get more structure.
protected final String getCriteriaHeader(MetricFilterCriteriaForm form)
{
StringBuilder filterCriteria = new StringBuilder("<br/>");
if (form.isSacNone() || form.isSac1() || form.isSac2() || form.isSac3())
{
filterCriteria.append("SAC:");
if (form.isSacNone())
filterCriteria.append(" NONE");
if (form.isSac1() || form.isSac2() || form.isSac3())
{
if (form.isSac1())
filterCriteria.append(" 1,");
if (form.isSac2())
filterCriteria.append(" 2,");
if (form.isSac3())
filterCriteria.append(" 3,");
if(','==filterCriteria.charAt(filterCriteria.length-1) )
filterCriteria.deleteCharAt(filterCriteria.length-1)
filterCriteria.append("<br/>");
}
}
if (form.isRegularScheduleType() || form.isLotScheduleType() || form.isBatchScheduleType())
{
filterCriteria.append("Schedule Type:");
if (form.isRegularScheduleType())
filterCriteria.append(" Regular,");
if (form.isLotScheduleType())
filterCriteria.append(" Lot,");
if (form.isBatchScheduleType())
filterCriteria.append(" Batch,");
if(','==filterCriteria.charAt(filterCriteria.length-1) )
filterCriteria.deleteCharAt(filterCriteria.length-1)
}
return filterCriteria.toString();
}
If only one condition can be true,you can also use else if instead of cascades of if.
You could use a StringBuilder to build the string, it's better than simple string concatenation :
StringBuilder sb = new StringBuilder();
if(XX) {
sb.append("XX");
}
return sb.toString();
Hope this helps :)
PS: Note that StringBuilder is faster than StringBuffer, but the latter is Thread-safe.
EDIT
I re-read your question, and it seems I don't answer it well, although I provided useful advice (IMHO). I don't understand exactly what you need.
I would suggest whacking the thing into a List then using a StringBuilder:
protected final String getCriteriaHeader(MetricFilterCriteriaForm form) {
final StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("<br/>");
final List<String> sacList = new LinkedList<String>();
if (form.isSacNone() || form.isSac1() || form.isSac2() || form.isSac3()) {
stringBuilder.append("SAC: ");
}
if (form.isSacNone()) {
sacList.add("NONE");
}
if (form.isSac1()) {
sacList.add("1");
}
if (form.isSac2()) {
sacList.add("2");
}
if (form.isSac3()) {
sacList.add("3");
}
final Iterator<String> sacIter = sacList.iterator();
while (sacIter.hasNext()) {
stringBuilder.append(sacIter.next());
if (sacIter.hasNext()) {
stringBuilder.append(", ");
}
}
if (form.isSac1() || form.isSac2() || form.isSac3()) {
stringBuilder.append("<br/>");
}
final List<String> scheduleTypeList = new LinkedList<String>();
if (form.isRegularScheduleType() || form.isLotScheduleType() || form.isBatchScheduleType()) {
scheduleTypeList.add("Schedule Type: ");
}
if (form.isRegularScheduleType()) {
scheduleTypeList.add("Regular");
}
if (form.isLotScheduleType()) {
scheduleTypeList.add("Lot");
}
if (form.isBatchScheduleType()) {
scheduleTypeList.add("Batch");
}
final Iterator<String> scheduleTypeIter = scheduleTypeList.iterator();
while (scheduleTypeIter.hasNext()) {
stringBuilder.append(scheduleTypeIter.next());
if (scheduleTypeIter.hasNext()) {
stringBuilder.append(", ");
}
}
return stringBuilder.toString();
}