/*
* Copyright (c) 2013-2016 Stuart Boston
*
* This file is part of the OMDB API.
*
* The OMDB API is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* The OMDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the OMDB API. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.omdbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public abstract class AbstractJsonMapping {
private static final Logger LOG = LoggerFactory.getLogger(AbstractJsonMapping.class);
private boolean response = Boolean.FALSE;
@JsonProperty("Error")
private String error = "";
public boolean isResponse() {
return response;
}
@JsonProperty("Response")
public void setResponse(String response) {
this.response = Boolean.parseBoolean(response);
}
public void setResponse(boolean response) {
this.response = response;
}
public String getError() {
return error;
}
public void setError(String error) {
this.error = error;
}
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
protected void handleUnknown(String key, Object value) {
StringBuilder unknown = new StringBuilder(this.getClass().getSimpleName());
unknown.append(": Unknown property='").append(key);
unknown.append("' value='").append(value).append("'");
LOG.trace(unknown.toString());
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
}
}