FINERACT-2181: Add customData field to InvestorBusinessEvent

This commit is contained in:
Jose Alberto Hernandez
2025-04-15 15:14:45 +02:00
committed by Adam Saghy
parent b9b5eb60d1
commit 2143d35e29
4 changed files with 72 additions and 5 deletions
@@ -0,0 +1,39 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.infrastructure.event.external.service.serialization.serializer;
import java.nio.ByteBuffer;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.fineract.infrastructure.event.business.domain.BusinessEvent;
public abstract class AbstractBusinessEventWithCustomDataSerializer<T extends BusinessEvent<?>> implements BusinessEventSerializer {
protected Map<String, ByteBuffer> collectCustomData(final T event) {
return getExternalEventCustomDataSerializers().stream().collect(HashMap::new, (map, serializer) -> {
ByteBuffer buffer = serializer.serialize(event);
if (buffer != null) {
map.put(serializer.key(), buffer);
}
}, HashMap::putAll);
}
protected abstract List<ExternalEventCustomDataSerializer<T>> getExternalEventCustomDataSerializers();
}