change Connection API Option to Nullable, to match Kotlin's style
This commit is contained in:
		@ -5,9 +5,8 @@ import javafx.scene.image.Image
 | 
			
		||||
import org.hso.texturesyncclient.model.Sha256
 | 
			
		||||
import org.hso.texturesyncclient.model.Texture
 | 
			
		||||
import java.io.*
 | 
			
		||||
import java.lang.IllegalArgumentException
 | 
			
		||||
import java.lang.RuntimeException
 | 
			
		||||
import java.net.*
 | 
			
		||||
import java.net.InetAddress
 | 
			
		||||
import java.net.Socket
 | 
			
		||||
import java.util.*
 | 
			
		||||
 | 
			
		||||
@Suppress("MemberVisibilityCanBePrivate")
 | 
			
		||||
@ -96,7 +95,7 @@ class Connection(val address: InetAddress, val port: Int = 10796) : Closeable {
 | 
			
		||||
 | 
			
		||||
    @Throws(IOException::class, ConnectionException::class)
 | 
			
		||||
    @Synchronized
 | 
			
		||||
    fun getTextureById(id: UUID): Optional<Texture> {
 | 
			
		||||
    fun getTextureById(id: UUID): Texture? {
 | 
			
		||||
        val io = getStreams()
 | 
			
		||||
 | 
			
		||||
        val obj = JsonObject()
 | 
			
		||||
@ -111,14 +110,12 @@ class Connection(val address: InetAddress, val port: Int = 10796) : Closeable {
 | 
			
		||||
        when (val pkg = Package.read(io.first)) {
 | 
			
		||||
            is JsonPackage -> {
 | 
			
		||||
                return if (pkg.content.isJsonNull) {
 | 
			
		||||
                    Optional.empty()
 | 
			
		||||
                    null
 | 
			
		||||
                } else {
 | 
			
		||||
                    try {
 | 
			
		||||
                        Optional.of(
 | 
			
		||||
                            Gson()
 | 
			
		||||
                                .fromJson<InternalTexture>(pkg.content, InternalTexture::class.java)
 | 
			
		||||
                                .toTexture()
 | 
			
		||||
                        )
 | 
			
		||||
                        Gson()
 | 
			
		||||
                            .fromJson<InternalTexture>(pkg.content, InternalTexture::class.java)
 | 
			
		||||
                            .toTexture()
 | 
			
		||||
                    } catch (e: JsonSyntaxException) {
 | 
			
		||||
                        throw ConnectionInvalidJsonException()
 | 
			
		||||
                    }
 | 
			
		||||
@ -133,7 +130,7 @@ class Connection(val address: InetAddress, val port: Int = 10796) : Closeable {
 | 
			
		||||
 | 
			
		||||
    @Throws(IOException::class, ConnectionException::class)
 | 
			
		||||
    @Synchronized
 | 
			
		||||
    fun getTextureByName(name: String): Optional<Texture> {
 | 
			
		||||
    fun getTextureByName(name: String): Texture? {
 | 
			
		||||
        val io = getStreams()
 | 
			
		||||
 | 
			
		||||
        val obj = JsonObject()
 | 
			
		||||
@ -148,14 +145,12 @@ class Connection(val address: InetAddress, val port: Int = 10796) : Closeable {
 | 
			
		||||
        when (val pkg = Package.read(io.first)) {
 | 
			
		||||
            is JsonPackage -> {
 | 
			
		||||
                return if (pkg.content.isJsonNull) {
 | 
			
		||||
                    Optional.empty()
 | 
			
		||||
                    null
 | 
			
		||||
                } else {
 | 
			
		||||
                    try {
 | 
			
		||||
                        Optional.of(
 | 
			
		||||
                            Gson()
 | 
			
		||||
                                .fromJson<InternalTexture>(pkg.content, InternalTexture::class.java)
 | 
			
		||||
                                .toTexture()
 | 
			
		||||
                        )
 | 
			
		||||
                        Gson()
 | 
			
		||||
                            .fromJson<InternalTexture>(pkg.content, InternalTexture::class.java)
 | 
			
		||||
                            .toTexture()
 | 
			
		||||
                    } catch (e: JsonSyntaxException) {
 | 
			
		||||
                        throw ConnectionInvalidJsonException()
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user