/
TaskSpringData.java
146 lines (124 loc) · 3.51 KB
/
TaskSpringData.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
package com.datastax.sample.springdata;
import java.io.Serializable;
import java.util.UUID;
//import org.springframework.data.cassandra.core.cql.PrimaryKeyType;
//import org.springframework.data.cassandra.core.mapping.CassandraType;
//import org.springframework.data.cassandra.core.mapping.CassandraType.Name;
//import org.springframework.data.cassandra.core.mapping.Column;
//import org.springframework.data.cassandra.core.mapping.PrimaryKeyColumn;
//import org.springframework.data.cassandra.core.mapping.Table;
import com.datastax.sample.model.Task;
import com.datastax.sample.model.TodoAppSchema;
/**
* Entity for table and Spring Data.
*
* @author Cedrick LUNVEN (@clunven)
*/
//@Table(value = TodoAppSchema.TABLE_TODO_TASKS)
public class TaskSpringData implements Serializable, Comparable<Task>, TodoAppSchema {
private static final long serialVersionUID = -5844442448334944278L;
//@PrimaryKeyColumn(
// name = TodoAppSchema.TASK_COL_UID, ordinal = 0,
// type = PrimaryKeyType.PARTITIONED)
//@CassandraType(type = Name.UUID)
private UUID uuid;
//@Column(TASK_COL_TITLE)
//@CassandraType(type = Name.TEXT)
private String title;
//@Column(TASK_COL_COMPLETED)
//@CassandraType(type = Name.BOOLEAN)
private boolean completed = false;
//@Column(TASK_COL_OFFSET)
//@CassandraType(type = Name.INT)
private int order = 0;
public TaskSpringData() {}
public Task mapAsTask() {
Task t = new Task();
t.setUuid(this.uuid);
t.setCompleted(this.completed);
t.setOrder(this.order);
t.setTitle(this.title);
return t;
}
public TaskSpringData(Task t) {
this.uuid = t.getUuid();
this.title = t.getTitle();
this.order = t.getOrder();
this.completed = t.isCompleted();
}
/** {@inheritDoc} */
@Override
public int compareTo(Task other) {
if (other == null)
return 1;
return order - other.getOrder();
}
/**
* Getter accessor for attribute 'uuid'.
*
* @return current value of 'uuid'
*/
public UUID getUuid() {
return uuid;
}
/**
* Setter accessor for attribute 'uuid'.
*
* @param uuid
* new value for 'uuid '
*/
public void setUuid(UUID uuid) {
this.uuid = uuid;
}
/**
* Getter accessor for attribute 'title'.
*
* @return current value of 'title'
*/
public String getTitle() {
return title;
}
/**
* Setter accessor for attribute 'title'.
*
* @param title
* new value for 'title '
*/
public void setTitle(String title) {
this.title = title;
}
/**
* Getter accessor for attribute 'completed'.
*
* @return current value of 'completed'
*/
public boolean isCompleted() {
return completed;
}
/**
* Setter accessor for attribute 'completed'.
*
* @param completed
* new value for 'completed '
*/
public void setCompleted(boolean completed) {
this.completed = completed;
}
/**
* Getter accessor for attribute 'order'.
*
* @return current value of 'order'
*/
public int getOrder() {
return order;
}
/**
* Setter accessor for attribute 'order'.
*
* @param order
* new value for 'order '
*/
public void setOrder(int order) {
this.order = order;
}
}