1 changed files with 31 additions and 0 deletions
@ -0,0 +1,31 @@ |
|||||||
|
package com.redhat.pctsec.model.api.request; |
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JacksonException; |
||||||
|
import com.fasterxml.jackson.core.JsonParser; |
||||||
|
import com.fasterxml.jackson.databind.DeserializationContext; |
||||||
|
import com.fasterxml.jackson.databind.JsonDeserializer; |
||||||
|
import com.fasterxml.jackson.databind.JsonNode; |
||||||
|
|
||||||
|
import java.io.IOException; |
||||||
|
import java.net.URI; |
||||||
|
|
||||||
|
public class ComponentJsonDeserializer extends JsonDeserializer<Component> { |
||||||
|
|
||||||
|
@Override |
||||||
|
public Component deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JacksonException { |
||||||
|
|
||||||
|
JsonNode node = jsonParser.readValueAsTree(); |
||||||
|
JsonNode componentT = node.get("type"); |
||||||
|
if(componentT.asText().equals("git")) |
||||||
|
{ |
||||||
|
URI repo = URI.create(node.get("repo").asText()); |
||||||
|
String ref = node.get("ref").asText(); |
||||||
|
return new git(repo, ref); |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
return new build(componentT.asText(), node.get("build-id").asText()); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
Loading…
Reference in new issue