
com.solidstategroup.bullettrain.Feature Maven / Gradle / Ivy
package com.solidstategroup.bullettrain;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Data;
import java.io.IOException;
import java.io.Serializable;
/**
* Representation of the feature flag model model representation of the Feature
*/
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Feature implements Serializable {
private String name;
private String description;
@JsonIgnore
public void parse(String data) throws IOException {
ObjectMapper mapper = MapperFactory.getMappper();
Feature prototype = mapper.readValue(data, Feature.class);
fromPrototype(prototype);
}
@JsonIgnore
private void fromPrototype(Feature prototype) throws IOException {
setName(prototype.getName());
setDescription(prototype.getDescription());
}
@JsonIgnore
@Override
public String toString() {
ObjectMapper mapper = MapperFactory.getMappper();
try {
return mapper.writeValueAsString(this);
} catch (JsonProcessingException e) {
return super.toString();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy