Skip to content
This repository has been archived by the owner on Apr 14, 2022. It is now read-only.

Commit

Permalink
Chore: expressions with type arguments replaced with diamond type <> (L…
Browse files Browse the repository at this point in the history
  • Loading branch information
dbmalkovsky authored Dec 25, 2021
1 parent 947c163 commit 662b866
Show file tree
Hide file tree
Showing 24 changed files with 55 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public class CalendarPanel extends JPanel {
* that a date is selected in the calendar panel, or the YearMonth is changed in the calendar
* panel.
*/
private ArrayList<CalendarListener> calendarListeners = new ArrayList<CalendarListener>();
private ArrayList<CalendarListener> calendarListeners = new ArrayList<>();

/**
* constantFirstWeekdayLabelCell, This constant indicates the location of the first weekday
Expand Down Expand Up @@ -413,7 +413,7 @@ private void addBorderLabels() {
* This function should not depend on any settings variables.
*/
private void addDateLabels() {
dateLabels = new ArrayList<JLabel>();
dateLabels = new ArrayList<>();
for (int i = 0; i < 42; ++i) {
int dateLabelColumnX = ((i % 7)) + constantFirstDateLabelCell.x;
int dateLabelRowY = ((i / 7) + constantFirstDateLabelCell.y);
Expand Down Expand Up @@ -446,7 +446,7 @@ public void mouseLiberalClick(MouseEvent e) {
* This function should not depend on any settings variables.
*/
private void addWeekNumberLabels() {
weekNumberLabels = new ArrayList<JLabel>();
weekNumberLabels = new ArrayList<>();
int weekNumberLabelColumnX = constantFirstWeekNumberLabelCell.x;
int weekNumberLabelWidthInCells = 1;
int weekNumberLabelHeightInCells = 1;
Expand Down Expand Up @@ -475,7 +475,7 @@ private void addWeekNumberLabels() {
* This function should not depend on any settings variables.
*/
private void addWeekdayLabels() {
weekdayLabels = new ArrayList<JLabel>();
weekdayLabels = new ArrayList<>();
int weekdayLabelRowY = constantFirstWeekdayLabelCell.y;
int weekdayLabelWidthInCells = 1;
int weekdayLabelHeightInCells = 3;
Expand Down Expand Up @@ -713,7 +713,7 @@ public void run() {
});
}
// Set the days of the week labels, and create an array to represent the weekday positions.
ArrayList<DayOfWeek> daysOfWeekAsDisplayed = new ArrayList<DayOfWeek>();
ArrayList<DayOfWeek> daysOfWeekAsDisplayed = new ArrayList<>();
int isoFirstDayOfWeekValue = settings.getFirstDayOfWeekDisplayedOnCalendar().getValue();
int isoLastDayOfWeekOverflowed = isoFirstDayOfWeekValue + 6;
int weekdayLabelArrayIndex = 0;
Expand All @@ -729,7 +729,7 @@ public void run() {
// Set the dates of the month labels.
// Also save the label for the selected date, if one is present in the current month.
// Also save the first date in each used row, for later use while displaying week numbers.
ArrayList<LocalDate> firstDateInEachUsedRow = new ArrayList<LocalDate>();
ArrayList<LocalDate> firstDateInEachUsedRow = new ArrayList<>();
boolean insideValidRange = false;
int dayOfMonth = 1;
JLabel selectedDateLabel = null;
Expand Down Expand Up @@ -902,7 +902,7 @@ public void run() {
* are registered with this CalendarPanel.
*/
public ArrayList<CalendarListener> getCalendarListeners() {
return new ArrayList<CalendarListener>(calendarListeners);
return new ArrayList<>(calendarListeners);
}

/**
Expand Down Expand Up @@ -1812,7 +1812,7 @@ void zApplyVisibilityOfButtons() {
private Integer zGetWeekNumberForASevenDayRange(LocalDate firstDateInRange,
WeekFields weekFieldRules, boolean requireUnanimousWeekNumber) {
// Get the week number for each of the seven days in the range.
ArrayList<Integer> weekNumbersList = new ArrayList<Integer>();
ArrayList<Integer> weekNumbersList = new ArrayList<>();
for (int daysIntoTheFuture = 0; daysIntoTheFuture <= 6; ++daysIntoTheFuture) {
LocalDate currentDateInRange;
// This try block handles an exception that can occur at LocalDate.MAX
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ public class CalendarPanelBeanInfo extends SimpleBeanInfo {
* lowercase strings. Any properties that are not in this list, will be marked as "not
* preferred". (All of the defaults for preferred properties are overwritten.)
*/
private static HashSet<String> preferredProperties = new HashSet<String>(Arrays.asList(
"selecteddate"));
private static HashSet<String> preferredProperties = new HashSet<>(Arrays.asList("selecteddate"));

/**
* propertyDescriptions, These are the descriptions to add to the properties. The key is the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public class DatePicker extends JPanel implements CustomPopupCloseListener {
* dateChangeListeners, This holds a list of date change listeners that wish to be notified each
* time that the last valid date is changed.
*/
private ArrayList<DateChangeListener> dateChangeListeners = new ArrayList<DateChangeListener>();
private ArrayList<DateChangeListener> dateChangeListeners = new ArrayList<>();

/**
* lastPopupCloseTime, This holds a timestamp that indicates when the calendar was last closed.
Expand Down Expand Up @@ -349,7 +349,7 @@ public LocalDate getDate() {
* that are registered with this DatePicker.
*/
public ArrayList<DateChangeListener> getDateChangeListeners() {
return new ArrayList<DateChangeListener>(dateChangeListeners);
return new ArrayList<>(dateChangeListeners);
}

/**
Expand Down Expand Up @@ -1059,7 +1059,7 @@ public void zEventCustomPopupWasClosed(CustomPopup popup) {

public void addComponentListener(ComponentListener listener) {
if (componentListeners == null) {
componentListeners = new ArrayList<ComponentListener>();
componentListeners = new ArrayList<>();
}
componentListeners.add(listener);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ public class DatePickerBeanInfo extends SimpleBeanInfo {
* lowercase strings. Any properties that are not in this list, will be marked as "not
* preferred". (All of the defaults for preferred properties are overwritten.)
*/
private static HashSet<String> preferredProperties = new HashSet<String>(Arrays.asList(
"date", "text"));
private static HashSet<String> preferredProperties = new HashSet<>(Arrays.asList("date", "text"));

/**
* propertyDescriptions, These are the descriptions to add to the properties. The key is the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ public DatePickerSettings copySettings() {
result.colors = null;
} else {
// A shallow copy is okay here, because the map key and value are immutable types.
result.colors = new EnumMap<DateArea, Color>(this.colors);
result.colors = new EnumMap<>(this.colors);
}
result.firstDayOfWeek = this.firstDayOfWeek;
// The Font class is immutable.
Expand Down Expand Up @@ -1832,7 +1832,7 @@ public void setLocale(Locale locale) {
FormatStyle.SHORT, FormatStyle.MEDIUM, FormatStyle.LONG, FormatStyle.FULL};

// Create a set of default parsing formatters for the specified locale.
ArrayList<DateTimeFormatter> parsingFormats = new ArrayList<DateTimeFormatter>();
ArrayList<DateTimeFormatter> parsingFormats = new ArrayList<>();
DateTimeFormatter parseFormat;
for (int i = 0; i < allFormatStyles.length; ++i) {
parseFormat = new DateTimeFormatterBuilder().parseLenient().parseCaseInsensitive().
Expand Down Expand Up @@ -2335,7 +2335,7 @@ private LocalDate zGetParentSelectedDate() {
* invisible.
*/
private ArrayList<CalendarBorderProperties> zGetDefaultBorderPropertiesList() {
ArrayList<CalendarBorderProperties> results = new ArrayList<CalendarBorderProperties>();
ArrayList<CalendarBorderProperties> results = new ArrayList<>();
Color defaultDateBoxBorderColor = new Color(99, 130, 191);
Color defaultWeekdayEndcapsBorderColor = colorBackgroundWeekdayLabels;
Color defaultWeekNumberEndcapsBorderColor = colorBackgroundWeekNumberLabels;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public class DateTimePicker extends JPanel {
* notified whenever the last valid date or the last valid time has changed.
*/
private ArrayList<DateTimeChangeListener> dateTimeChangeListeners
= new ArrayList<DateTimeChangeListener>();
= new ArrayList<>();

/**
* timePicker, This holds the time picker component of this DateTimePicker.
Expand Down Expand Up @@ -168,7 +168,7 @@ public void removeDateTimeChangeListener(DateTimeChangeListener listener) {
* that are registered with this DateTimePicker.
*/
public ArrayList<DateTimeChangeListener> getDateTimeChangeListeners() {
return new ArrayList<DateTimeChangeListener>(dateTimeChangeListeners);
return new ArrayList<>(dateTimeChangeListeners);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ public class DateTimePickerBeanInfo extends SimpleBeanInfo {
* lowercase strings. Any properties that are not in this list, will be marked as "not
* preferred". (All of the defaults for preferred properties are overwritten.)
*/
private static HashSet<String> preferredProperties = new HashSet<String>(Arrays.asList(
"datetimepermissive", "datetimestrict"));
private static HashSet<String> preferredProperties = new HashSet<>(Arrays.asList("datetimepermissive", "datetimestrict"));

/**
* propertyDescriptions, These are the descriptions to add to the properties. The key is the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public class TimePicker
* timeChangeListeners, This holds a list of time change listeners that wish to be notified
* whenever the last valid time is changed.
*/
private ArrayList<TimeChangeListener> timeChangeListeners = new ArrayList<TimeChangeListener>();
private ArrayList<TimeChangeListener> timeChangeListeners = new ArrayList<>();

/**
* timeMenuPanel, This holds the menu panel GUI component of this time picker. This should be
Expand Down Expand Up @@ -410,7 +410,7 @@ public LocalTime getTime() {
* that are registered with this TimePicker.
*/
public ArrayList<TimeChangeListener> getTimeChangeListeners() {
return new ArrayList<TimeChangeListener>(timeChangeListeners);
return new ArrayList<>(timeChangeListeners);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ public class TimePickerBeanInfo extends SimpleBeanInfo {
* lowercase strings. Any properties that are not in this list, will be marked as "not
* preferred". (All of the defaults for preferred properties are overwritten.)
*/
private static HashSet<String> preferredProperties = new HashSet<String>(Arrays.asList(
"time", "text"));
private static HashSet<String> preferredProperties = new HashSet<>(Arrays.asList("time", "text"));

/**
* propertyDescriptions, These are the descriptions to add to the properties. The key is the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ public TimePickerSettings() {
*/
public TimePickerSettings(Locale timeLocale) {
// Add all the default colors to the colors map.
colors = new HashMap< TimeArea, Color>();
colors = new HashMap<>();
for (TimeArea area : TimeArea.values()) {
colors.put(area, area.defaultColor);
}
Expand All @@ -357,7 +357,7 @@ public TimePickerSettings(Locale timeLocale) {
// Generate default parsing formats.
FormatStyle[] allFormatStyles = new FormatStyle[]{
FormatStyle.SHORT, FormatStyle.MEDIUM, FormatStyle.LONG, FormatStyle.FULL};
formatsForParsing = new ArrayList<DateTimeFormatter>();
formatsForParsing = new ArrayList<>();
formatsForParsing.add(DateTimeFormatter.ISO_LOCAL_TIME);
for (FormatStyle formatStyle : allFormatStyles) {
DateTimeFormatter parseFormat = new DateTimeFormatterBuilder().parseLenient().
Expand Down Expand Up @@ -406,7 +406,7 @@ public void generatePotentialMenuTimes(TimeIncrement timeIncrement,
LocalTime startTime = (optionalStartTime == null) ? LocalTime.MIN : optionalStartTime;
LocalTime endTime = (optionalEndTime == null) ? LocalTime.MAX : optionalEndTime;
// Initialize our needed variables.
potentialMenuTimes = new ArrayList<LocalTime>();
potentialMenuTimes = new ArrayList<>();
int increment = timeIncrement.minutes;
// Start at midnight, which is the earliest time of day for LocalTime values.
LocalTime entry = LocalTime.MIDNIGHT;
Expand Down Expand Up @@ -434,11 +434,11 @@ public void generatePotentialMenuTimes(TimeIncrement timeIncrement,
* by this function.
*/
public void generatePotentialMenuTimes(ArrayList<LocalTime> desiredTimes) {
potentialMenuTimes = new ArrayList<LocalTime>();
potentialMenuTimes = new ArrayList<>();
if (desiredTimes == null || desiredTimes.isEmpty()) {
return;
}
TreeSet<LocalTime> timeSet = new TreeSet<LocalTime>();
TreeSet<LocalTime> timeSet = new TreeSet<>();
for (LocalTime desiredTime : desiredTimes) {
if (desiredTime != null) {
timeSet.add(desiredTime);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ public static void main(String[] args) {
// Create a list to hold our border properties. Borders properties will be applied to the
// calendar in the order that they appear this list.
ArrayList<CalendarBorderProperties> borderProperties
= new ArrayList<CalendarBorderProperties>();
= new ArrayList<>();
// Set all borders to be yellow, and 10 pixels thick.
// (Parts of the yellow border will be overwritten by other border settings.)
borderProperties.add(new CalendarBorderProperties(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ private void zSetAllColumnEditorsAndRenderers(JTable table) {
columnLoop:
for (int columnIndex = 0; columnIndex < columnCount; ++columnIndex) {
TableColumn column = table.getColumnModel().getColumn(columnIndex);
ArrayList<Class> nonNullTypes = new ArrayList<Class>();
ArrayList<Class> nonNullTypes = new ArrayList<>();
// Loop through all the rows that should be sampled.
rowLoop:
for (int rowIndex = 0; (rowIndex < rowCount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ public static String convertStringFromDuration(

private static HashSet<DurationUnit> getUsedDurationUnitSet(
DurationUnit smallestUnit, DurationUnit largestUnit) {
HashSet<DurationUnit> result = new HashSet<DurationUnit>();
HashSet<DurationUnit> result = new HashSet<>();
for (DurationUnit unit : DurationUnit.values()) {
if (unit.compareTo(smallestUnit) >= 0 && unit.compareTo(largestUnit) <= 0) {
result.add(unit);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private void initializeSettingsFromLocale(Locale locale) {
}
this.locale = locale;

translationsUnitsSingular = new HashMap<DurationUnit, String>();
translationsUnitsSingular = new HashMap<>();
translationsUnitsSingular.put(DurationUnit.Second,
TranslationSource.getTranslation(locale, "singular.Second", "sec"));
translationsUnitsSingular.put(DurationUnit.Minute,
Expand All @@ -78,7 +78,7 @@ private void initializeSettingsFromLocale(Locale locale) {
translationsUnitsSingular.put(DurationUnit.Year,
TranslationSource.getTranslation(locale, "singular.Year", "year"));

translationsUnitsPlural = new HashMap<DurationUnit, String>();
translationsUnitsPlural = new HashMap<>();
translationsUnitsPlural.put(DurationUnit.Second,
TranslationSource.getTranslation(locale, "plural.Second", "secs"));
translationsUnitsPlural.put(DurationUnit.Minute,
Expand Down Expand Up @@ -117,7 +117,7 @@ private void initializeSettingsFromLocale(Locale locale) {
}

public HashMap<DurationUnit, Boolean> getSimplePluralUnitsMap(boolean settingForAllUnits) {
HashMap<DurationUnit, Boolean> result = new HashMap<DurationUnit, Boolean>();
HashMap<DurationUnit, Boolean> result = new HashMap<>();
result.put(DurationUnit.Second, settingForAllUnits);
result.put(DurationUnit.Minute, settingForAllUnits);
result.put(DurationUnit.Hour, settingForAllUnits);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public static void main(String[] args) {
dateSettings = new DatePickerSettings();
// Create a list to hold the border properties.
ArrayList<CalendarBorderProperties> customPropertiesList
= new ArrayList<CalendarBorderProperties>();
= new ArrayList<>();
// Set the borders properties for everything to Blue.
CalendarBorderProperties weekdayLabelBorderProperties = new CalendarBorderProperties(
new Point(3, 1), new Point(5, 5), Color.YELLOW, 5);
Expand Down Expand Up @@ -270,7 +270,7 @@ public static void main(String[] args) {
calendarPanel = new CalendarPanel(dateSettings);
// Create a list to hold the border properties.
ArrayList<CalendarBorderProperties> customPropertiesList2
= new ArrayList<CalendarBorderProperties>();
= new ArrayList<>();
// Set the borders properties for everything to Blue.
CalendarBorderProperties weekdayLabelBorderProperties2 = new CalendarBorderProperties(
new Point(3, 1), new Point(5, 5), Color.YELLOW, 5);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
public class GetAllLanguages {

public static void main(String[] args) {
TreeSet<String> languageCodes = new TreeSet<String>();
TreeSet<String> languageCodes = new TreeSet<>();
for (Locale locale : Locale.getAvailableLocales()) {
languageCodes.add(locale.getLanguage());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public static ArrayList<DateTimeFormatter> getExtraParsingFormatsForLocale(Local
}

// If no extra parsing formats were found, then return an empty list.
ArrayList<DateTimeFormatter> extraParsingFormatters = new ArrayList<DateTimeFormatter>();
ArrayList<DateTimeFormatter> extraParsingFormatters = new ArrayList<>();
if (definedFormats == null) {
return extraParsingFormatters;
}
Expand Down Expand Up @@ -163,7 +163,7 @@ private static String getStandaloneMonthName(Month month, Locale locale, boolean
private static String[] getStandaloneMonthNamesArray(Locale locale, boolean capitalize,
boolean shortVersion) {
Month[] monthEnums = Month.values();
ArrayList<String> monthNamesArrayList = new ArrayList<String>();
ArrayList<String> monthNamesArrayList = new ArrayList<>();
for (Month monthEnum : monthEnums) {
monthNamesArrayList.add(getStandaloneMonthName(monthEnum, locale, capitalize, shortVersion));
}
Expand Down Expand Up @@ -209,7 +209,7 @@ private static String getFormattingMonthName(Month month, Locale locale, boolean
public static String[] getFormattingMonthNamesArray(Locale locale, boolean capitalize,
boolean shortVersion) {
Month[] monthEnums = Month.values();
ArrayList<String> monthNamesArrayList = new ArrayList<String>();
ArrayList<String> monthNamesArrayList = new ArrayList<>();
for (Month monthEnum : monthEnums) {
monthNamesArrayList.add(getFormattingMonthName(
monthEnum, locale, capitalize, shortVersion));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static ArrayList<DateTimeFormatter> getExtraTimeParsingFormatsForLocale(L
}

// If no extra parsing formats were found, then return an empty list.
ArrayList<DateTimeFormatter> extraParsingFormatters = new ArrayList<DateTimeFormatter>();
ArrayList<DateTimeFormatter> extraParsingFormatters = new ArrayList<>();
if (definedFormats == null) {
return extraParsingFormatters;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public static <T> T getMostCommonElementInList(List<T> sourceList) {
if (sourceList == null || sourceList.isEmpty()) {
return null;
}
Map<T, Integer> hashMap = new HashMap<T, Integer>();
Map<T, Integer> hashMap = new HashMap<>();
for (T element : sourceList) {
Integer countOrNull = hashMap.get(element);
int newCount = (countOrNull == null) ? 1 : (countOrNull + 1);
Expand Down
Loading

0 comments on commit 662b866

Please sign in to comment.