Skip to content

Commit

Permalink
Rename JavaXYZ to PojoXYZ for better uniform naming within pojo modul…
Browse files Browse the repository at this point in the history
…e, since java is to general.
  • Loading branch information
Gandulf Kohlweiss authored and derTobsch committed Apr 18, 2024
1 parent ddf70e4 commit 92d094e
Show file tree
Hide file tree
Showing 18 changed files with 80 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ void generateHolidaySource(HolidayCalendar cal, Writer writer) throws IOExceptio
writer.write("import de.focus_shift.jollyday.pojo.*;\n\n");
writer.write("public class Holiday_" + calendarId + " {\n\n");


writer.write(" public static JavaConfiguration configuration;\n\n");
writer.write(" public static PojoConfiguration configuration;\n\n");
StringBuilder sb = new StringBuilder();
sb.append(" static {\n");
sb.append(" configuration = ");
Expand Down Expand Up @@ -95,8 +94,7 @@ void generateConfigurationSource(Writer writer) throws IOException {

writeHeader(writer);


writer.append(" static Map<String,JavaConfiguration> configurations = new HashMap<>();\n");
writer.append(" static Map<String,PojoConfiguration> configurations = new HashMap<>();\n");

writer.append(" static {\n");
for (HolidayCalendar cal : HolidayCalendar.values()) {
Expand Down Expand Up @@ -146,7 +144,7 @@ private void writeHeader(Writer writer) throws IOException {
writer.write("import de.focus_shift.jollyday.core.spi.ConfigurationService;\n");
writer.write("import de.focus_shift.jollyday.pojo.holidays.*;\n\n");

writer.write("public class JavaConfigurationService implements ConfigurationService {\n\n");
writer.write("public class PojoConfigurationService implements ConfigurationService {\n\n");
}

private void writeFooter(Writer writer) throws IOException {
Expand All @@ -157,16 +155,17 @@ private void writeFooter(Writer writer) throws IOException {
sb.append(" public Configuration getConfiguration(ManagerParameter parameter) {\n");
sb.append(" final String cacheKey = parameter.createCacheKey();\n");
sb.append("\n");
sb.append(" JavaConfiguration configuration = configurations.get(cacheKey);\n");
sb.append(" PojoConfiguration configuration = configurations.get(cacheKey);\n");
sb.append(" return configuration;\n");
sb.append(" }\n");
sb.append("}");

writer.write(sb.toString());
}
// public JavaConfiguration(JavaHolidays javaHolidays, List<Configuration> subConfigurations, String hierarchy, String description)

// public PojoConfiguration(PojoHolidays javaHolidays, List<Configuration> subConfigurations, String hierarchy, String description)
private String configuration(Configuration configuration) {
return constructor("JavaConfiguration", holidays(configuration.holidays()), configurations(configuration.subConfigurations()), string(configuration.hierarchy()), string(configuration.description()));
return constructor("PojoConfiguration", holidays(configuration.holidays()), configurations(configuration.subConfigurations()), string(configuration.hierarchy()), string(configuration.description()));
}

private String configurations(Stream<Configuration> configurations) {
Expand All @@ -183,14 +182,14 @@ private String configurations(Stream<Configuration> configurations) {
return result;
}

// public JavaHolidays(List<ChristianHoliday> christianHoliday, List<IslamicHoliday> islamicHoliday, List<EthiopianOrthodoxHoliday> ethiopianOrthodoxHoliday, List<Fixed> fixed, List<FixedWeekdayInMonth> fixedWeekday, List<FixedWeekdayBetweenFixed> fixedWeekdayBetweenFixed, List<FixedWeekdayRelativeToFixed> fixedWeekdayRelativeToFixed, List<RelativeToFixed> relativeToFixed, List<RelativeToWeekdayInMonth> relativeToWeekdayInMonth, List<RelativeToEasterSunday> relativeToEasterSunday)
// public PojoHolidays(List<ChristianHoliday> christianHoliday, List<IslamicHoliday> islamicHoliday, List<EthiopianOrthodoxHoliday> ethiopianOrthodoxHoliday, List<Fixed> fixed, List<FixedWeekdayInMonth> fixedWeekday, List<FixedWeekdayBetweenFixed> fixedWeekdayBetweenFixed, List<FixedWeekdayRelativeToFixed> fixedWeekdayRelativeToFixed, List<RelativeToFixed> relativeToFixed, List<RelativeToWeekdayInMonth> relativeToWeekdayInMonth, List<RelativeToEasterSunday> relativeToEasterSunday)
private String holidays(Holidays holidays) {
if (holidays == null) {
return "null";
}

StringBuilder sb = new StringBuilder();
sb.append(String.format("new JavaHolidays()\n"));
sb.append(String.format("new PojoHolidays()\n"));
for (de.focus_shift.jollyday.core.spi.Fixed fixed : holidays.fixed()) {
sb.append(String.format(" .addFixed(%s)\n", fixed(fixed)));
}
Expand Down Expand Up @@ -234,54 +233,54 @@ private String holidays(Holidays holidays) {
return sb.toString();
}

// public JavaFixed(String descriptionPropertiesKey, HolidayType officiality, Year validFrom, Year validTo, YearCycle cycle, List<MovingCondition> conditions, MonthDay day)
// public PojoFixed(String descriptionPropertiesKey, HolidayType officiality, Year validFrom, Year validTo, YearCycle cycle, List<MovingCondition> conditions, MonthDay day)
private String fixed(Fixed fixed) {
return constructor("JavaFixed", string(fixed.descriptionPropertiesKey()), enums(fixed.officiality()), year(fixed.validFrom()), year(fixed.validTo()), yearCycle(fixed.cycle()), movingConditions(fixed.conditions()), monthDay(fixed.day()));
return constructor("PojoFixed", string(fixed.descriptionPropertiesKey()), enums(fixed.officiality()), year(fixed.validFrom()), year(fixed.validTo()), yearCycle(fixed.cycle()), movingConditions(fixed.conditions()), monthDay(fixed.day()));
}

//public JavaChristianHoliday(String descriptionPropertiesKey, HolidayType officiality, Year validFrom, Year validTo, YearCycle cycle, List<MovingCondition> conditions, ChristianHolidayType type, Chronology chronology)
//public PojoChristianHoliday(String descriptionPropertiesKey, HolidayType officiality, Year validFrom, Year validTo, YearCycle cycle, List<MovingCondition> conditions, ChristianHolidayType type, Chronology chronology)
private String christianHoliday(ChristianHoliday christianHoliday) {
return constructor("JavaChristianHoliday", string(christianHoliday.descriptionPropertiesKey()), enums(christianHoliday.officiality()), year(christianHoliday.validFrom()), year(christianHoliday.validTo()), yearCycle(christianHoliday.cycle()), movingConditions(christianHoliday.conditions()), enums(christianHoliday.type()), chronology(christianHoliday.chronology()));
return constructor("PojoChristianHoliday", string(christianHoliday.descriptionPropertiesKey()), enums(christianHoliday.officiality()), year(christianHoliday.validFrom()), year(christianHoliday.validTo()), yearCycle(christianHoliday.cycle()), movingConditions(christianHoliday.conditions()), enums(christianHoliday.type()), chronology(christianHoliday.chronology()));
}

// public JavaEthiopianOrthodoxHoliday(String descriptionPropertiesKey, HolidayType officiality, Year validFrom, Year validTo, YearCycle cycle, EthiopianOrthodoxHolidayType type)
// public PojoEthiopianOrthodoxHoliday(String descriptionPropertiesKey, HolidayType officiality, Year validFrom, Year validTo, YearCycle cycle, EthiopianOrthodoxHolidayType type)
private String ethiopianOrthodoxHoliday(EthiopianOrthodoxHoliday hol) {
return constructor("JavaEthiopianOrthodoxHoliday", string(hol.descriptionPropertiesKey()), enums(hol.officiality()), year(hol.validFrom()), year(hol.validTo()), yearCycle(hol.cycle()), enums(hol.type()));
return constructor("PojoEthiopianOrthodoxHoliday", string(hol.descriptionPropertiesKey()), enums(hol.officiality()), year(hol.validFrom()), year(hol.validTo()), yearCycle(hol.cycle()), enums(hol.type()));
}

// public JavaIslamicHoliday(String descriptionPropertiesKey, HolidayType officiality, Year validFrom, Year validTo, YearCycle cycle, List<MovingCondition> conditions, IslamicHolidayType type)
// public PojoIslamicHoliday(String descriptionPropertiesKey, HolidayType officiality, Year validFrom, Year validTo, YearCycle cycle, List<MovingCondition> conditions, IslamicHolidayType type)
private String islamicHoliday(IslamicHoliday hol) {
return constructor("JavaIslamicHoliday", string(hol.descriptionPropertiesKey()), enums(hol.officiality()), year(hol.validFrom()), year(hol.validTo()), yearCycle(hol.cycle()), movingConditions(hol.conditions()), enums(hol.type()));
return constructor("PojoIslamicHoliday", string(hol.descriptionPropertiesKey()), enums(hol.officiality()), year(hol.validFrom()), year(hol.validTo()), yearCycle(hol.cycle()), movingConditions(hol.conditions()), enums(hol.type()));
}

// public JavaFixedWeekdayBetweenFixed(String descriptionPropertiesKey, HolidayType officiality, Year validFrom, Year validTo, YearCycle cycle, Fixed from, Fixed to, DayOfWeek weekday)
// public PojoFixedWeekdayBetweenFixed(String descriptionPropertiesKey, HolidayType officiality, Year validFrom, Year validTo, YearCycle cycle, Fixed from, Fixed to, DayOfWeek weekday)
private String fixedWeekdayBetweenFixed(FixedWeekdayBetweenFixed hol) {
return constructor("JavaFixedWeekdayBetweenFixed", string(hol.descriptionPropertiesKey()), enums(hol.officiality()), year(hol.validFrom()), year(hol.validTo()), yearCycle(hol.cycle()), fixed(hol.from()), fixed(hol.to()), dayOfWeek(hol.weekday()));
return constructor("PojoFixedWeekdayBetweenFixed", string(hol.descriptionPropertiesKey()), enums(hol.officiality()), year(hol.validFrom()), year(hol.validTo()), yearCycle(hol.cycle()), fixed(hol.from()), fixed(hol.to()), dayOfWeek(hol.weekday()));
}

// public JavaFixedWeekdayInMonth(String descriptionPropertiesKey, HolidayType officiality, Year validFrom, Year validTo, YearCycle cycle, DayOfWeek weekday, Month month, Occurrance which)
// public PojoFixedWeekdayInMonth(String descriptionPropertiesKey, HolidayType officiality, Year validFrom, Year validTo, YearCycle cycle, DayOfWeek weekday, Month month, Occurrance which)
private String fixedWeekdayInMonth(FixedWeekdayInMonth hol) {
return constructor("JavaFixedWeekdayInMonth", string(hol.descriptionPropertiesKey()), enums(hol.officiality()), year(hol.validFrom()), year(hol.validTo()), yearCycle(hol.cycle()), dayOfWeek(hol.weekday()), month(hol.month()), enums(hol.which()));
return constructor("PojoFixedWeekdayInMonth", string(hol.descriptionPropertiesKey()), enums(hol.officiality()), year(hol.validFrom()), year(hol.validTo()), yearCycle(hol.cycle()), dayOfWeek(hol.weekday()), month(hol.month()), enums(hol.which()));
}

// public JavaFixedWeekdayRelativeToFixed(String descriptionPropertiesKey, HolidayType officiality, Year validFrom, Year validTo, YearCycle cycle, DayOfWeek weekday, Relation when, Fixed day, Occurrance which)
// public PojoFixedWeekdayRelativeToFixed(String descriptionPropertiesKey, HolidayType officiality, Year validFrom, Year validTo, YearCycle cycle, DayOfWeek weekday, Relation when, Fixed day, Occurrance which)
private String fixedWeekdayRelativeToFixed(FixedWeekdayRelativeToFixed hol) {
return constructor("JavaFixedWeekdayRelativeToFixed", string(hol.descriptionPropertiesKey()), enums(hol.officiality()), year(hol.validFrom()), year(hol.validTo()), yearCycle(hol.cycle()), dayOfWeek(hol.weekday()), enums(hol.when()), fixed(hol.day()), enums(hol.which()));
return constructor("PojoFixedWeekdayRelativeToFixed", string(hol.descriptionPropertiesKey()), enums(hol.officiality()), year(hol.validFrom()), year(hol.validTo()), yearCycle(hol.cycle()), dayOfWeek(hol.weekday()), enums(hol.when()), fixed(hol.day()), enums(hol.which()));
}

// public JavaRelativeToEasterSunday(String descriptionPropertiesKey, HolidayType officiality, Year validFrom, Year validTo, YearCycle cycle, Chronology chronology, Days days)
// public PojoRelativeToEasterSunday(String descriptionPropertiesKey, HolidayType officiality, Year validFrom, Year validTo, YearCycle cycle, Chronology chronology, Days days)
private String relativeToEasterSunday(RelativeToEasterSunday hol) {
return constructor("JavaRelativeToEasterSunday", string(hol.descriptionPropertiesKey()), enums(hol.officiality()), year(hol.validFrom()), year(hol.validTo()), yearCycle(hol.cycle()), chronology(hol.chronology()), days(hol.days()));
return constructor("PojoRelativeToEasterSunday", string(hol.descriptionPropertiesKey()), enums(hol.officiality()), year(hol.validFrom()), year(hol.validTo()), yearCycle(hol.cycle()), chronology(hol.chronology()), days(hol.days()));
}

// public JavaRelativeToFixed(String descriptionPropertiesKey, HolidayType officiality, Year validFrom, Year validTo, YearCycle cycle, Fixed date, DayOfWeek weekday, Relation when, Days days) {
// public PojoRelativeToFixed(String descriptionPropertiesKey, HolidayType officiality, Year validFrom, Year validTo, YearCycle cycle, Fixed date, DayOfWeek weekday, Relation when, Days days) {
private String relativeToFixed(RelativeToFixed hol) {
return constructor("JavaRelativeToFixed", string(hol.descriptionPropertiesKey()), enums(hol.officiality()), year(hol.validFrom()), year(hol.validTo()), yearCycle(hol.cycle()), fixed(hol.date()), dayOfWeek(hol.weekday()), enums(hol.when()), days(hol.days()));
return constructor("PojoRelativeToFixed", string(hol.descriptionPropertiesKey()), enums(hol.officiality()), year(hol.validFrom()), year(hol.validTo()), yearCycle(hol.cycle()), fixed(hol.date()), dayOfWeek(hol.weekday()), enums(hol.when()), days(hol.days()));
}

// public JavaRelativeToWeekdayInMonth(String descriptionPropertiesKey, HolidayType officiality, Year validFrom, Year validTo, YearCycle cycle, FixedWeekdayInMonth weekdayInMonth, DayOfWeek weekday, Relation when)
// public PojoRelativeToWeekdayInMonth(String descriptionPropertiesKey, HolidayType officiality, Year validFrom, Year validTo, YearCycle cycle, FixedWeekdayInMonth weekdayInMonth, DayOfWeek weekday, Relation when)
private String relativeToWeekdayInMonth(RelativeToWeekdayInMonth hol) {
return constructor("JavaRelativeToWeekdayInMonth", string(hol.descriptionPropertiesKey()), enums(hol.officiality()), year(hol.validFrom()), year(hol.validTo()), yearCycle(hol.cycle()), fixedWeekdayInMonth(hol.weekdayInMonth()), dayOfWeek(hol.weekday()), enums(hol.when()));
return constructor("PojoRelativeToWeekdayInMonth", string(hol.descriptionPropertiesKey()), enums(hol.officiality()), year(hol.validFrom()), year(hol.validTo()), yearCycle(hol.cycle()), fixedWeekdayInMonth(hol.weekdayInMonth()), dayOfWeek(hol.weekday()), enums(hol.when()));
}

private String constructor(Object... arguments) {
Expand Down Expand Up @@ -370,12 +369,12 @@ private String movingConditions(List<MovingCondition> movingConditions) {
}
}

// public JavaMovingCondition(DayOfWeek substitute, With with, DayOfWeek weekday) {
// public PojoMovingCondition(DayOfWeek substitute, With with, DayOfWeek weekday) {
private String movingCondition(MovingCondition movingCondition) {
if (movingCondition == null) {
return "null";
} else {
return constructor("JavaMovingCondition", dayOfWeek(movingCondition.substitute()), enums(movingCondition.with()), dayOfWeek(movingCondition.weekday()));
return constructor("PojoMovingCondition", dayOfWeek(movingCondition.substitute()), enums(movingCondition.with()), dayOfWeek(movingCondition.weekday()));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void execute() throws MojoExecutionException {
throw new MojoExecutionException("Target directory doesn't exist or cannot be generated: "+ genDir.getAbsolutePath());
}

final File configurationService = Paths.get(outputDirectory.getAbsolutePath(), "de/focus_shift/jollyday/pojo/JavaConfigurationService.java").toFile();
final File configurationService = Paths.get(outputDirectory.getAbsolutePath(), "de/focus_shift/jollyday/pojo/PojoConfigurationService.java").toFile();

try (FileWriter fileWriter = new FileWriter(configurationService, false)) {
PojoGenerator generator = new PojoGenerator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
import de.focus_shift.jollyday.core.spi.MovingCondition;
import de.focus_shift.jollyday.core.spi.YearCycle;

public class JavaChristianHoliday extends DefaultMovingHoliday implements ChristianHoliday {
public class PojoChristianHoliday extends DefaultMovingHoliday implements ChristianHoliday {

private ChristianHolidayType type;
private Chronology chronology;

public JavaChristianHoliday(String descriptionPropertiesKey, HolidayType officiality, Year validFrom, Year validTo, YearCycle cycle, List<MovingCondition> conditions, ChristianHolidayType type, Chronology chronology) {
public PojoChristianHoliday(String descriptionPropertiesKey, HolidayType officiality, Year validFrom, Year validTo, YearCycle cycle, List<MovingCondition> conditions, ChristianHolidayType type, Chronology chronology) {
super(descriptionPropertiesKey, officiality, validFrom, validTo, cycle, conditions);
this.type = type;
this.chronology = chronology;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,17 @@
import de.focus_shift.jollyday.core.spi.Configuration;
import de.focus_shift.jollyday.core.spi.Holidays;

public class PojoConfiguration implements Configuration {

public class JavaConfiguration implements Configuration {

private JavaHolidays javaHolidays;
private PojoHolidays javaHolidays;
private List<Configuration> subConfigurations;
private String hierarchy;
private String description;

public JavaConfiguration() {
public PojoConfiguration() {
}

public JavaConfiguration(JavaHolidays javaHolidays, List<Configuration> subConfigurations, String hierarchy, String description) {
public PojoConfiguration(PojoHolidays javaHolidays, List<Configuration> subConfigurations, String hierarchy, String description) {
this.javaHolidays = javaHolidays;
this.subConfigurations = subConfigurations;
this.hierarchy = hierarchy;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
import de.focus_shift.jollyday.core.spi.EthiopianOrthodoxHolidayType;
import de.focus_shift.jollyday.core.spi.YearCycle;

public class JavaEthiopianOrthodoxHoliday extends DefaultHoliday implements EthiopianOrthodoxHoliday {
public class PojoEthiopianOrthodoxHoliday extends DefaultHoliday implements EthiopianOrthodoxHoliday {

private EthiopianOrthodoxHolidayType type;

public JavaEthiopianOrthodoxHoliday(String descriptionPropertiesKey, HolidayType officiality, Year validFrom, Year validTo, YearCycle cycle, EthiopianOrthodoxHolidayType type) {
public PojoEthiopianOrthodoxHoliday(String descriptionPropertiesKey, HolidayType officiality, Year validFrom, Year validTo, YearCycle cycle, EthiopianOrthodoxHolidayType type) {
super(descriptionPropertiesKey, officiality, validFrom, validTo, cycle);
this.type = type;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
import de.focus_shift.jollyday.core.spi.MovingCondition;
import de.focus_shift.jollyday.core.spi.YearCycle;

public class JavaFixed extends DefaultMovingHoliday implements Fixed {
public class PojoFixed extends DefaultMovingHoliday implements Fixed {

private MonthDay day;

public JavaFixed(String descriptionPropertiesKey, HolidayType officiality, Year validFrom, Year validTo, YearCycle cycle, List<MovingCondition> conditions, MonthDay day) {
public PojoFixed(String descriptionPropertiesKey, HolidayType officiality, Year validFrom, Year validTo, YearCycle cycle, List<MovingCondition> conditions, MonthDay day) {
super(descriptionPropertiesKey, officiality, validFrom, validTo, cycle, conditions);
this.day = day;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@
import de.focus_shift.jollyday.core.spi.FixedWeekdayBetweenFixed;
import de.focus_shift.jollyday.core.spi.YearCycle;


public class JavaFixedWeekdayBetweenFixed extends DefaultHoliday implements FixedWeekdayBetweenFixed {
public class PojoFixedWeekdayBetweenFixed extends DefaultHoliday implements FixedWeekdayBetweenFixed {

private Fixed from;
private Fixed to;
private DayOfWeek weekday;

public JavaFixedWeekdayBetweenFixed(String descriptionPropertiesKey, HolidayType officiality, Year validFrom, Year validTo, YearCycle cycle, Fixed from, Fixed to, DayOfWeek weekday) {
public PojoFixedWeekdayBetweenFixed(String descriptionPropertiesKey, HolidayType officiality, Year validFrom, Year validTo, YearCycle cycle, Fixed from, Fixed to, DayOfWeek weekday) {
super(descriptionPropertiesKey, officiality, validFrom, validTo, cycle);
this.from = from;
this.to = to;
Expand Down

0 comments on commit 92d094e

Please sign in to comment.