Slide 8
Slide 8 text
public final class Task {
@NonNulla
private final String id;
@Nullableb
private final String title;
@Nullablec
private final String description;
private final boolean completed;
public Task(@Nullable String title, @Nullable String description,
@NonNull String id, boolean completed) {
this.id = id;
this.title = title;
this.description = description;
this.completed = completed;
}a
@NonNulld
public String getId() {
return id;
}b
@Nullablee
public String getTitle() {
return title;
}c
@Nullablef
public String getTitleForList() {
if (!Strings.isNullOrEmpty(title)) {
return title;
} else {
return description;
}
}d
@Nullableg
public String getDescription() {
return description;
}e
public boolean isCompleted() {
return completed;
}f
public boolean isActive() {
return !completed;
}g
public boolean isEmpty() {
return Strings.isNullOrEmpty(title) &&
Strings.isNullOrEmpty(description);
}h
@Overrideh
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Task task = (Task) o;
return Objects.equal(id, task.id) &&
Objects.equal(title, task.title) &&
Objects.equal(description, task.description);
}i
@Overridei
public int hashCode() {
return Objects.hashCode(id, title, description);
}j
@Overridej
public String toString() {
return "Task with title " + title;
}k
}l