I have a Object:
public class ListAnnotationsOrigin implements Serializable {
/**
*
*/
private static final long serialVersionUID = 8443084209405942551L;
@JsonProperty("opcombo")
private List<opcombo> listComboOp;
@JsonProperty("vicombo")
private List<vicombo> listComboVi;
@JsonProperty("vicombo")
private String vicombo;
@JsonProperty("viversion")
private String idVersionVi;
@JsonProperty("closed")
private String closed;
@JsonProperty("params")
private List<SegmentOrigin> listSegmentOrigin; // <-- here
// getters,setters etc.
I want sort listSegmentOrigin
@Entity
@Table(name = "SegmentOrigin")
public class SegmentOrigin implements Comparable<T>{ // <-- ERROR
....
@JsonProperty("idSegment")
private String idSegment;
public int compareTo(SegmentOrigin arg0) {
if (this.getIdSegment().compareTo(arg0.getIdSegment())) { // <<--ERROR type mismatch: cannot convert from int to boolean
return 1;
} else {
return 0;
}
}
}
In my controller->
ListAnnotationsOrigin list = this.getListAnnotationsOrigin ();
return Collections.sort((List<SegmentOrigin>) list.getListSegmentOrigin());
I send my List from ListAnnotationsOrigin in an orderly manner, Then when I implements Comparable{ I get red line "implements methods unics"
I import -> public int compareTo(SegmentOrigin arg0) { ... and I get other error, thanks.
compareTo()returns an int, and not a boolean.return this.getIdSegment().compareTo(arg0.getIdSegment())should do the work.Comparable<T>instead ofTuse type which should be compared, in your caseSegmentOrigin.if(condition)expect atconditionexpression which could be evaluated as boolean, but what OP has evaluates toint.