-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy pathContentSearchElementToStringStyle.java
More file actions
38 lines (31 loc) · 1.27 KB
/
ContentSearchElementToStringStyle.java
File metadata and controls
38 lines (31 loc) · 1.27 KB
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
// SPDX-License-Identifier: MPL-2.0
// SPDX-FileCopyrightText: 2026 Tony Germano <tony@germano.name>
package com.mirth.connect.model;
import java.util.Collection;
import com.mirth.connect.donkey.model.message.ContentType;
public class ContentSearchElementToStringStyle extends SearchElementToStringStyle {
public ContentSearchElementToStringStyle() {
super();
setArraySeparator(", ");
setArrayStart("[");
setArrayEnd("]");
}
@Override
protected void appendDetail(StringBuffer buffer, String fieldName, Collection<?> coll) {
appendDetail(buffer, fieldName, (Object[]) coll.toArray());
}
@Override
protected void appendDetail(StringBuffer buffer, String fieldname, Object value) {
if (fieldname.equals("contentCode") && value instanceof Integer code) {
ContentType type = ContentType.fromCode(code);
String typeName = (type != null) ? type.toString() : "UNKNOWN";
String formatted = String.format("%d(%s)", code, typeName);
buffer.append(formatted);
} else {
super.appendDetail(buffer, fieldname, value);
}
}
public static ContentSearchElementToStringStyle instance() {
return new ContentSearchElementToStringStyle();
}
}