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

com.ing.baker.runtime.common.Utils.scala Maven / Gradle / Ivy

There is a newer version: 4.1.0-RC3
Show newest version
package com.ing.baker.runtime.common

import java.io.ByteArrayOutputStream
import java.util.zip.GZIPOutputStream

import com.ing.baker.il.CompiledRecipe
import com.ing.baker.runtime.serialization.ProtoMap

object Utils {

  def recipeToByteArray(compiledRecipe: CompiledRecipe): Array[Byte] = ProtoMap.ctxToProto(compiledRecipe).toByteArray

  def recipeToGZippedByteArray(compiledRecipe: CompiledRecipe): Array[Byte] = {
    val recipeBytes = recipeToByteArray(compiledRecipe)
    val byteStream = new ByteArrayOutputStream(recipeBytes.length)
    val zipStream = new GZIPOutputStream(byteStream)
    zipStream.write(recipeBytes)
    zipStream.close()
    byteStream.toByteArray
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy