List<Color> (Color color, List<? extends Color> recentColors, int maxSize) { ArrayList<Color> colors = new ArrayList<>(recentColors); colors.remove(color); colors.add(0, color); if (colors.size() > maxSize) { colors = new ArrayList<>(recentColors.subList(0, maxSize)); } return colors; }