class ImageComparator implements Comparator<Image>, Serializable {

    @Override
    public int compare(Image image1, Image image2) {
        return image1.getCreated() == null || image2.getCreated() == null
                ? image1.getDate().compareTo(image2.getDate())
                : image1.getCreated().compareTo(image2.getCreated());
    }

}