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

uidsonic.fluid-json-basic.0.9.24.source-code.JSONPath.kt Maven / Gradle / Ivy

The newest version!
package com.github.fluidsonic.fluid.json


class JSONPath(elements: List = emptyList()) {

	val elements = elements.toList()

	override fun equals(other: Any?) = (this === other || (other is JSONPath && elements == other.elements))
	override fun hashCode() = elements.hashCode()

	override fun toString() =
		if (elements.isNotEmpty())
			elements.joinToString(separator = "", prefix = "")
		else
			""


	companion object {

		val root = JSONPath()
	}


	sealed class Element {

		class ListIndex(val value: Int) : Element() {

			override fun equals(other: Any?) = (this === other || (other is ListIndex && value == other.value))
			override fun hashCode() = value
			override fun toString() = "[$value]"
		}


		class MapKey(val value: String) : Element() {

			override fun equals(other: Any?) = (this === other || (other is MapKey && value == other.value))
			override fun hashCode() = value.hashCode()
			override fun toString() = ".\"$value\""
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy