-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from bloomreach/dev
Dev > main v1.0.11
- Loading branch information
Showing
11 changed files
with
142 additions
and
23 deletions.
There are no files selected for viewing
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
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
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
13 changes: 13 additions & 0 deletions
13
src/main/java/com/bloomreach/discovery/api/model/core/FacetField.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* Copyright 2024 Bloomreach | ||
*/ | ||
|
||
package com.bloomreach.discovery.api.model.core | ||
|
||
import com.fasterxml.jackson.databind.JsonDeserializer | ||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize | ||
|
||
@JsonDeserialize(using = JsonDeserializer.None::class) | ||
class FacetField : FacetValue() { | ||
val name: String? = null | ||
} |
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
27 changes: 27 additions & 0 deletions
27
src/main/java/com/bloomreach/discovery/api/model/core/FacetFieldsCategory.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright 2024 Bloomreach | ||
*/ | ||
|
||
package com.bloomreach.discovery.api.model.core | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty | ||
import com.fasterxml.jackson.databind.JsonDeserializer | ||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize | ||
|
||
@JsonDeserialize(using = JsonDeserializer.None::class) | ||
data class FacetFieldsCategory( | ||
@JsonProperty("cat_id") | ||
val catId: String? = null, | ||
|
||
@JsonProperty("cat_name") | ||
val catName: String? = null, | ||
|
||
@JsonProperty("crumb") | ||
val crumb: String? = null, | ||
|
||
@JsonProperty("tree_path") | ||
val treePath: String? = null, | ||
|
||
@JsonProperty("parent") | ||
val parent: String? = null, | ||
) : FacetValue() |
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
14 changes: 14 additions & 0 deletions
14
src/main/java/com/bloomreach/discovery/api/model/core/FacetRnge.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* Copyright 2024 Bloomreach | ||
*/ | ||
|
||
package com.bloomreach.discovery.api.model.core | ||
|
||
import com.fasterxml.jackson.databind.JsonDeserializer | ||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize | ||
|
||
@JsonDeserialize(using = JsonDeserializer.None::class) | ||
data class FacetRnge( | ||
val start: Any? = null, | ||
val end: Any? = null, | ||
) : FacetValue() |
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
33 changes: 33 additions & 0 deletions
33
src/main/java/com/bloomreach/discovery/api/model/core/FacetValueDeserializer.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright 2024 Bloomreach | ||
*/ | ||
|
||
package com.bloomreach.discovery.api.model.core | ||
import com.fasterxml.jackson.core.JsonParser | ||
import com.fasterxml.jackson.core.JsonProcessingException | ||
import com.fasterxml.jackson.databind.DeserializationContext | ||
import com.fasterxml.jackson.databind.ObjectMapper | ||
import com.fasterxml.jackson.databind.deser.std.StdDeserializer | ||
import com.fasterxml.jackson.databind.node.ObjectNode | ||
import java.io.IOException | ||
|
||
class FacetValueDeserializer : StdDeserializer<FacetValue?>(FacetValue::class.java) { | ||
@Throws(IOException::class, JsonProcessingException::class) | ||
override fun deserialize(jsonParser: JsonParser, deserializationContext: DeserializationContext): FacetValue { | ||
val mapper = jsonParser.codec as ObjectMapper | ||
val root = mapper.readTree<ObjectNode>(jsonParser) | ||
// Determine the type based on existence of certain fields | ||
val type: Class<*> = when { | ||
root.has("start") -> { | ||
FacetRnge::class.java | ||
} | ||
root.has("cat_id") -> { | ||
FacetFieldsCategory::class.java | ||
} | ||
else -> { | ||
FacetField::class.java | ||
} | ||
} | ||
return mapper.treeToValue(root, type) as FacetValue | ||
} | ||
} |
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