2 * ========================LICENSE_START=================================
5 * Copyright (C) 2023 Nordix Foundation
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ========================LICENSE_END===================================
21 package org.oran.pmproducer.filter;
23 import java.util.ArrayList;
26 import lombok.ToString;
28 import org.apache.kafka.common.header.Header;
29 import org.apache.kafka.common.header.internals.RecordHeader;
30 import org.oran.pmproducer.tasks.TopicListener.DataFromTopic;
33 public class FilteredData {
34 public final byte[] key;
35 public final byte[] value;
36 public final String infoTypeId;
39 private final boolean isZipped;
41 private static final FilteredData emptyData = new FilteredData(null, null, null);
43 public boolean isEmpty() {
44 return (key == null || key.length == 0) && (value == null || value.length == 0);
47 public FilteredData(String type, byte[] key, byte[] value) {
48 this(type, key, value, false);
51 public FilteredData(String type, byte[] key, byte[] value, boolean isZipped) {
54 this.isZipped = isZipped;
55 this.infoTypeId = type;
58 public String getValueAString() {
59 return value == null ? "" : new String(this.value);
62 public static FilteredData empty() {
66 public Iterable<Header> headers() {
67 ArrayList<Header> result = new ArrayList<>();
69 result.add(new RecordHeader(DataFromTopic.ZIPPED_PROPERTY, null));
71 result.add(new RecordHeader(DataFromTopic.TYPE_ID_PROPERTY, infoTypeId.getBytes()));