blob: 51a1e91ee299fe02314043233240ca9d10138ba3 [file] [log] [blame]
{{> header}}
package chip.devicecontroller;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Optional;
{{! TODO: Use AutoValue for inner classes. }}
public class ChipEventStructs {
{{#zcl_clusters}}
{{#zcl_events}}
public static class {{asUpperCamelCase parent.name}}Cluster{{asUpperCamelCase name}}Event {
{{#zcl_event_fields}}
{{! TODO: This uses the vague type List<Object> for some list types. }}
public {{asJavaType type null parent.parent.name includeAnnotations=true}} {{asLowerCamelCase (asSymbol name)}};
{{/zcl_event_fields}}
public {{asUpperCamelCase parent.name}}Cluster{{asUpperCamelCase name}}Event(
{{#zcl_event_fields}}
{{#not_first}}, {{/not_first}}{{asJavaType type null parent.parent.name includeAnnotations=true}} {{asLowerCamelCase (asSymbol name)}}
{{/zcl_event_fields}}) {
{{#zcl_event_fields}}
this.{{asLowerCamelCase (asSymbol name)}} = {{asLowerCamelCase (asSymbol name)}};
{{/zcl_event_fields}}
}
@Override
public String toString() {
StringBuilder output = new StringBuilder();
output.append("{{asUpperCamelCase parent.name}}Cluster{{asUpperCamelCase name}}Event {\n");
{{#zcl_event_fields}}
{{! TODO: Print more descriptive types for optional, nullable, array, and struct. }}
output.append("\t{{asLowerCamelCase name}}: ");
{{#if isArray}}
output.append({{asLowerCamelCase name}});
{{else if (isOctetString type)}}
{{#if isOptional}}
output.append({{asLowerCamelCase name}}.isPresent() ? Arrays.toString({{asLowerCamelCase name}}.get()) : "");
{{else}}
output.append(Arrays.toString({{asLowerCamelCase name}}));
{{/if}}
{{else}}
output.append({{asLowerCamelCase name}});
{{/if}}
output.append("\n");
{{/zcl_event_fields}}
output.append("}\n");
return output.toString();
}
}
{{/zcl_events}}
{{/zcl_clusters}}
}