mirror of https://github.com/tasks/tasks
Make notification immutable
parent
74fca07c1b
commit
a49c233584
@ -1,65 +0,0 @@
|
||||
package org.tasks.jobs;
|
||||
|
||||
import static org.tasks.time.DateTimeUtils2.currentTimeMillis;
|
||||
import static org.tasks.time.DateTimeUtilsKt.printTimestamp;
|
||||
|
||||
import org.tasks.data.entity.Notification;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class AlarmEntry {
|
||||
|
||||
private final long alarmId;
|
||||
private final long taskId;
|
||||
private final long time;
|
||||
private final int type;
|
||||
|
||||
public AlarmEntry(long alarmId, long taskId, Long time, int type) {
|
||||
this.alarmId = alarmId;
|
||||
this.taskId = taskId;
|
||||
this.time = time;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return alarmId;
|
||||
}
|
||||
|
||||
public long getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public long getTaskId() {
|
||||
return taskId;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public Notification toNotification() {
|
||||
Notification notification = new Notification();
|
||||
notification.setTaskId(taskId);
|
||||
notification.setType(type);
|
||||
notification.setTimestamp(currentTimeMillis());
|
||||
return notification;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
AlarmEntry that = (AlarmEntry) o;
|
||||
return alarmId == that.alarmId && taskId == that.taskId && time == that.time && type == that.type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(alarmId, taskId, time, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AlarmEntry{alarmId=" + alarmId + ", taskId=" + taskId + ", time=" + printTimestamp(time) + ", type=" + type + '}';
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
package org.tasks.jobs
|
||||
|
||||
import org.tasks.data.entity.Notification
|
||||
import org.tasks.time.DateTimeUtils2.currentTimeMillis
|
||||
import org.tasks.time.printTimestamp
|
||||
|
||||
data class AlarmEntry(
|
||||
val id: Long,
|
||||
val taskId: Long,
|
||||
val time: Long,
|
||||
val type: Int
|
||||
) {
|
||||
fun toNotification(): Notification = Notification(
|
||||
taskId = taskId,
|
||||
type = type,
|
||||
timestamp = currentTimeMillis(),
|
||||
)
|
||||
|
||||
override fun toString(): String {
|
||||
return "AlarmEntry(id=$id, taskId=$taskId, time=${printTimestamp(time)}, type=$type)"
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue