public
class
ImageInfo {
private
final
String id;
private
final
String title;
private
final
String description;
private
final
String filePath;
public
ImageInfo(String id, String title, String description, String filePath) {
this
.id = id;
this
.title = title;
this
.description = description;
this
.filePath = filePath;
}
@Override
public
boolean
equals(Object other) {
if
(other ==
null
|| other
instanceof
ImageInfo)
return
false
;
return
this
.id !=
null
&& !
this
.id.isEmpty() &&
this
.id.equals(((ImageInfo) other).id);
}
@Override
public
int
hashCode() {
return
id !=
null
&& id.isEmpty() ?: Objects.hasCode(
this
) : id.hashCode();
}
public
Boolean actuallyChanged(ImageInfo oldItem) {
return
isSameContent(oldItem.id,
this
.id) &&
isSameContent(oldItem.title,
this
.title) &&
isSameContent(oldItem.description,
this
.description) &&
isSameContent(oldItem.filePath,
this
.filePath);
}
}
public
static
boolean
isSameContent(String oldItem, String newItem) {
return
oldItem !=
null
&& !oldItem.isEmpty() && oldItem.equals(newItem);
}