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

com.commercetools.rmf.diff.RamlDiff.kt Maven / Gradle / Ivy

Go to download

RAML API client code generators based on the REST Modeling Framework. https://github.com/vrapio/rest-modeling-framework

There is a newer version: 1.0.0-20241120142200
Show newest version
package com.commercetools.rmf.diff

import io.vrap.rmf.raml.model.modules.Api

class RamlDiff private constructor(original: Api, changed: Api, private val differs: List>) {
    private val dataProvider = DataProvider(original, changed)
    class Builder {
        private var differs: List> = listOf()
        private var original: Api? = null
        private var changed: Api? = null

        fun original(original: Api): Builder {
            this.original = original
            return this
        }

        fun changed(changed: Api): Builder {
            this.changed = changed
            return this
        }

        fun plus(differ: List>): Builder {
            differs = differs.plus(differ)
            return this
        }

        fun plus(differ: Differ<*>): Builder {
            differs = differs.plus(differ as Differ)
            return this
        }

        fun build(): RamlDiff {
            return RamlDiff(original!!, changed!!, differs)
        }
    }

    fun diff(): List> {
        return differs.flatMap {
            it.diff(dataProvider.by(it.diffDataType) as DiffData)
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy