Is it possible to Store Enum value in String?
- by Narasimham K
Actally my java progrem like...
public class Schedule{
public static enum RepeatType {
DAILY, WEEKLY, MONTHLY;
}
public static enum WeekdayType {
MONDAY(Calendar.MONDAY), TUESDAY(Calendar.TUESDAY), WEDNESDAY(
Calendar.WEDNESDAY), THURSDAY(Calendar.THURSDAY), FRIDAY(
Calendar.FRIDAY), SATURDAY(Calendar.SATURDAY), SUNDAY(
Calendar.SUNDAY);
private int day;
private WeekdayType(int day) {
this.day = day;
}
public static List<Date> generateSchedule(RepeatType repeatType,List<WeekdayType> repeatDays) {
-----------------------------
----------------------------//hear some logic i wrote
}//Method
}
And i'm calling the method into my Business class like following...
@RemotingInclude
public void createEvent(TimetableVO timetableVO) {
if ("repeatDays".equals(timetableVO.getSearchKey())) {
List<Date> repeatDaysList=Schedule.generateSchedule(timetableVO.getRepeatType(),timetableVO.getRepeatDays());
}
}
And Finally TimetableVO is
@Entity
@Table(name="EC_TIMETABLE")
public class TimetableVO extends AbstractVO{
-----
private RepeatType repeatType;
private List<WeekdayType> repeatDays;//But in this case the method generateSchedule(-,-) was not calling.
-----
}
So my Question is Which one is Better Statement in the Following...
private List<WeekdayType> repeatDays;
(or)
private String repeatDays;//if we give like this `How to Convert Enum type to String` because generateSchedule() method taking enum type value....