private static <T, U> void setData(Component component, SerializableTriConsumer<Attributes, T, U> setter, T key, U value) { Attributes attributes = component.attributes; if (attributes == null) { if (value == null) { return; } attributes = new Attributes(); component.attributes = attributes; } setter.accept(attributes, key, value); if (attributes.isEmpty()) { component.attributes = null; } }