in coap/src/main/java/org/apache/mina/coap/CoapMessage.java [109:128]
public CoapMessage(int version, MessageType type, int code, int id, byte[] token, CoapOption[] options,
byte[] payload) {
super();
this.version = version;
this.type = type;
this.code = code;
this.id = id;
this.token = token == null ? EMPTY_BYTE_ARRAY : token;
this.payload = payload == null ? EMPTY_BYTE_ARRAY : payload;
this.options = options == null ? new CoapOption[] {} : options;
// sort options by code (easier for delta encoding)
Arrays.<CoapOption> sort(this.options, new Comparator<CoapOption>() {
@Override
public int compare(CoapOption o1, CoapOption o2) {
return o1.getType().getCode() < o2.getType().getCode() ? -1 : (o1.getType().getCode() == o2.getType()
.getCode() ? 0 : 1);
};
});
}