net.nemerosa.ontrack.model.support.AbstractTemplateSynchronisationSource Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ontrack-model Show documentation
Show all versions of ontrack-model Show documentation
Ontrack module: ontrack-model
package net.nemerosa.ontrack.model.support;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import net.nemerosa.ontrack.json.ObjectMapperFactory;
import net.nemerosa.ontrack.model.exceptions.TemplateSynchronisationSourceConfigParseException;
import net.nemerosa.ontrack.model.structure.TemplateSynchronisationSource;
public abstract class AbstractTemplateSynchronisationSource implements TemplateSynchronisationSource {
protected final ObjectMapper objectMapper = ObjectMapperFactory.create();
private final Class configType;
protected AbstractTemplateSynchronisationSource(Class configType) {
this.configType = configType;
}
@Override
public T parseConfig(JsonNode node) {
try {
return objectMapper.treeToValue(node, configType);
} catch (JsonProcessingException e) {
throw new TemplateSynchronisationSourceConfigParseException(e);
}
}
@Override
public JsonNode forStorage(T config) {
return objectMapper.valueToTree(config);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy