EventPropertyResponseProjection.java.txt 1.7 KB
Newer Older
1 2
package com.github.graphql;

3 4 5 6 7
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseProjection;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
import java.util.StringJoiner;
8

9 10 11
/**
 * Response projection for EventProperty
 */
12
public class EventPropertyResponseProjection implements GraphQLResponseProjection {
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

    private Map<String, Object> fields = new LinkedHashMap<>();

    public EventPropertyResponseProjection() {
    }

    public EventPropertyResponseProjection floatVal() {
        fields.put("floatVal", null);
        return this;
    }

    public EventPropertyResponseProjection booleanVal() {
        fields.put("booleanVal", null);
        return this;
    }

    public EventPropertyResponseProjection intVal() {
        fields.put("intVal", null);
        return this;
    }

    public EventPropertyResponseProjection stringVal() {
        fields.put("stringVal", null);
        return this;
    }

    public EventPropertyResponseProjection child(EventPropertyResponseProjection subProjection) {
        fields.put("child", subProjection);
        return this;
    }

    public EventPropertyResponseProjection parent(EventResponseProjection subProjection) {
        fields.put("parent", subProjection);
        return this;
    }


    @Override
    public String toString() {
        if (fields.isEmpty()) {
            return "";
        }
        StringJoiner joiner = new StringJoiner(" ", "{ ", " }");
        for (Map.Entry<String, Object> property : fields.entrySet()) {
            joiner.add(property.getKey());
            if (property.getValue() != null) {
                joiner.add(" ").add(property.getValue().toString());
            }
        }
        return joiner.toString();
    }
}