New EI Consumer API, aligned to ORAN WG2
[nonrtric.git] / enrichment-coordinator-service / src / main / java / org / oransc / enrichment / repository / EiType.java
index 997484d..a354198 100644 (file)
 
 package org.oransc.enrichment.repository;
 
-import org.immutables.gson.Gson;
-import org.immutables.value.Value;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
 
-@Value.Immutable
-@Gson.TypeAdapters
-public interface EiType {
-    public String id();
+import lombok.Getter;
 
-    public Object jobDataSchema();
+public class EiType {
+    @Getter
+    private final String id;
+
+    @Getter
+    private final Object jobDataSchema;
+
+    private final Map<String, EiProducer> producers = new HashMap<>();
+
+    public EiType(String id, Object jobDataSchema) {
+        this.id = id;
+        this.jobDataSchema = jobDataSchema;
+    }
+
+    public synchronized Collection<EiProducer> getProducers() {
+        return Collections.unmodifiableCollection(producers.values());
+    }
+
+    public synchronized Collection<String> getProducerIds() {
+        return Collections.unmodifiableCollection(producers.keySet());
+    }
+
+    public synchronized void addProducer(EiProducer producer) {
+        this.producers.put(producer.getId(), producer);
+    }
+
+    public synchronized EiProducer removeProducer(EiProducer producer) {
+        return this.producers.remove(producer.getId());
+    }
 }