This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open class AvroSerializer @JvmOverloads constructor(val codecFactory: CodecFactory = CodecFactory.snappyCodec()) { | |
/** | |
* Avro instance 를 직렬화하여 byte array 로 변환합니다. | |
*/ | |
fun <T : SpecificRecordBase> writeAvroObject(graph: T?): ByteArray { | |
return graph?.let { | |
val sdw = SpecificDatumWriter<T>(graph.schema) | |
val dfw = DataFileWriter(sdw).setCodec(codecFactory) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** 모든 수형에 대해 builder 패턴을 제공하기 위해 사용 : Kotlin 의 apply method 와 같다 */ | |
implicit class AnyRefExtension[T <: AnyRef](underlying: T) { | |
def build(builder: T => T): T = builder(underlying) | |
def let(procedure: T => Unit): Unit = procedure(underlying) | |
} | |
/** 모든 Option 에 대해 Kotlin 의 let 과 같은 기능을 제공한다 */ | |
implicit class OptionExteions[T](underlying: Option[T]) { | |
def let(procedure: T => Unit): Unit = underlying foreach { procedure } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Product { | |
val productArity: Int | |
fun elements(index: Int): Any? | |
fun toList(): List<*> = productIterator().toList() | |
fun productIterator(): Iterator<*> = object : Iterator<Any?> { | |
var currIndex = 0 | |
override fun hasNext(): Boolean = currIndex < productArity | |
override fun next(): Any? = elements(currIndex++) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data class Tuple1<out T1 : Any>(override val first: T1) : Product1<T1>, Serializable { | |
override fun toString(): String { | |
return "($first)" | |
} | |
} | |
data class Tuple2<out T1 : Any, out T2 : Any>( | |
override val first: T1, | |
override val second: T2) : Product2<T1, T2>, Serializable { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright (c) 2016. Sunghyouk Bae <[email protected]> | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software | |
* distributed under the License is distributed on an "AS IS" BASIS, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package kesti4j | |
import java.util.function._ | |
/** | |
* @author [email protected] | |
*/ | |
package object core { | |
object Implicits { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class GsCollectionsFunSuite extends AbstractCoreFunSuite { | |
test("FastList collection") { | |
val fastlist = FastList.newListWith[Int](1, 2, 3, 4, 5) | |
val collected: FastList[Int] = fastlist.collect(new Function[Int, Int] { | |
override def valueOf(obj: Int): Int = obj * obj | |
}) | |
collected should contain allOf(1, 4, 9, 16, 25) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package kesti4s.core.collections | |
import com.gs.collections.api.block.function._ | |
import com.gs.collections.api.block.function.primitive._ | |
import com.gs.collections.api.block.predicate._ | |
import com.gs.collections.api.block.predicate.primitive._ | |
import com.gs.collections.api.block.procedure._ | |
import com.gs.collections.api.block.procedure.primitive._ | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package kr.hconnect.data.model; | |
import com.google.common.base.Objects; | |
import kr.hconnect.core.tools.HashTool; | |
import lombok.Getter; | |
import lombok.Setter; | |
/** | |
* Hibernate, JPA 의 모든 엔티티의 기본 클래스입니다. | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package kr.hconnect.data.model; | |
import com.google.common.base.Objects; | |
import kr.hconnect.core.tools.HashTool; | |
import lombok.Getter; | |
import lombok.Setter; | |
/** | |
* Hibernate, JPA 의 모든 엔티티의 기본 클래스입니다. | |
* |
NewerOlder