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

com.atlan.pkg.serde.RowSerializer.kt Maven / Gradle / Ivy

There is a newer version: 4.2.0
Show newest version
/* SPDX-License-Identifier: Apache-2.0
   Copyright 2023 Atlan Pte. Ltd. */
package com.atlan.pkg.serde

import com.atlan.model.assets.Asset
import com.atlan.model.fields.AtlanField
import com.atlan.pkg.PackageContext
import mu.KLogger

/**
 * Class to generally serialize an asset object into a row of tabular data.
 * Note: this will always serialize the qualifiedName and type of the asset as the first two columns.
 *
 * @param ctx context in which the package is running
 * @param asset the asset to be serialized
 * @param fields the full list of fields to be serialized from the asset, in the order they should be serialized
 * @param logger through which to record any problems
 */
class RowSerializer(
    private val ctx: PackageContext<*>,
    private val asset: Asset,
    private val fields: List,
    private val logger: KLogger,
) {
    /**
     * Actually serialize the provided inputs into a list of string values.
     *
     * @return the list of string values giving a row-based tabular representation of the asset
     */
    fun getRow(): Iterable {
        val row = mutableListOf()
        row.add(FieldSerde.getValueForField(ctx, asset, Asset.QUALIFIED_NAME, logger))
        row.add(FieldSerde.getValueForField(ctx, asset, Asset.TYPE_NAME, logger))
        for (field in fields) {
            if (field != Asset.QUALIFIED_NAME && field != Asset.TYPE_NAME) {
                row.add(FieldSerde.getValueForField(ctx, asset, field, logger))
            }
        }
        return row
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy