Java 11 migrate remaining p (#1122)
* Moves partial-response to Java 11 * Moves pipeline to Java 11 * Moves poison-pill to Java 11 * Moves priority-queue to Java 11 * Moves private-class-data to Java 11 * Moves producer-consumer to Java 11 * Moves promise to Java 11 * Moves property to Java 11 * Moves prototype to Java 11 * Moves proxy to Java 11 * Corrects checkstyle errors * Fixes build for pipeline pattern
This commit is contained in:
committed by
Ilkka Seppälä
parent
1401accb4f
commit
428efc7d53
@ -38,13 +38,16 @@ public class FieldJsonMapper {
|
||||
* @return json of required fields from video
|
||||
*/
|
||||
public String toJson(Video video, String[] fields) throws Exception {
|
||||
StringBuilder json = new StringBuilder().append("{");
|
||||
var json = new StringBuilder().append("{");
|
||||
|
||||
for (int i = 0, fieldsLength = fields.length; i < fieldsLength; i++) {
|
||||
var i = 0;
|
||||
var fieldsLength = fields.length;
|
||||
while (i < fieldsLength) {
|
||||
json.append(getString(video, Video.class.getDeclaredField(fields[i])));
|
||||
if (i != fieldsLength - 1) {
|
||||
json.append(",");
|
||||
}
|
||||
i++;
|
||||
}
|
||||
json.append("}");
|
||||
return json.toString();
|
||||
@ -52,7 +55,7 @@ public class FieldJsonMapper {
|
||||
|
||||
private String getString(Video video, Field declaredField) throws IllegalAccessException {
|
||||
declaredField.setAccessible(true);
|
||||
Object value = declaredField.get(video);
|
||||
var value = declaredField.get(video);
|
||||
if (declaredField.get(video) instanceof Integer) {
|
||||
return "\"" + declaredField.getName() + "\"" + ": " + value;
|
||||
}
|
||||
|
Reference in New Issue
Block a user