All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sap.hcp.cf.log4j2.layout.CustomFieldsAdapter Maven / Gradle / Ivy

package com.sap.hcp.cf.log4j2.layout;

import static java.util.Arrays.asList;
import static java.util.Collections.emptyList;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import com.sap.hcp.cf.logging.common.LogContext;

public class CustomFieldsAdapter {

	private List customFields;

	public CustomFieldsAdapter(CustomField... customFields) {
		this.customFields = customFields == null ? emptyList() : asList(customFields);
	}

	public List getCustomFieldKeyNames() {
		List result = new ArrayList<>(customFields.size());
		for (CustomField customField : customFields) {
			result.add(customField.getKey());
		}
		return result;
	}

	public List getExcludedFieldKeyNames() {
		Collection contextFieldsKeys = LogContext.getContextFieldsKeys();
		List result = new ArrayList<>(customFields.size());
		for (CustomField customField : customFields) {
			if (!customField.isRetainOriginal() && !contextFieldsKeys.contains(customField.getKey())) {
				result.add(customField.getKey());
			}
		}
		return result;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy