您好,登錄后才能下訂單哦!
今天就跟大家聊聊有關java中繼承的作用是什么,可能很多人都不太了解,為了讓大家更加了解,小編給大家總結了以下內容,希望大家根據這篇文章可以有所收獲。
public class ConfigureDefinition implements Serializable { private final static Logger LOGGER = LoggerFactory.getLogger(ConfigureDefinition.class); public static String valicateErrorMessage; public TaskNodeDefinition addConfiguration(Object json,TaskNodeDefinition target){ LOGGER.info("--->ConfigureDefinition addConfiguration() the [task node]<taskNode:{}>", target.toString()); return target; } public TaskNodeDefinition processConfiguration(TaskNodeDefinition taskNodeDefinition) throws Exception{ LOGGER.info("--->ConfigureDefinition processConfiguration() the [task node]<taskNode:{}>", taskNodeDefinition.toString()); validate(taskNodeDefinition); return taskNodeDefinition; } public boolean validate(TaskNodeDefinition taskNodeDefinition) { LOGGER.info("--->ConfigureDefinition validate() the [task node]<taskNode:{}>", taskNodeDefinition.toString()); return true; } public String validateReturnMessage(TaskNodeDefinition taskNodeDefinition){ LOGGER.info("--->ConfigureDefinition validateReturnMessage() the [task node]<taskNode:{}>", taskNodeDefinition.toString()); validate(taskNodeDefinition); return valicateErrorMessage; } }
public class HttpRequestConfig extends ConfigureDefinition { private final static Logger LOGGER = LoggerFactory.getLogger(HttpRequestConfig.class); @Override public TaskNodeDefinition addConfiguration(Object json,TaskNodeDefinition target){ LOGGER.info("---> HttpRequestConfig addConfiguration() the [HTTP Request]<taskNode:{}> <{}>", target.getTaskId(),json); JSONObject jsonObject= JSONObject.fromObject(json); HttpRequestDefinition httpRequestDefinition=(HttpRequestDefinition)JSONObject.toBean(jsonObject, HttpRequestDefinition.class); target.setConfigure(httpRequestDefinition); return target; } @Override public TaskNodeDefinition processConfiguration(TaskNodeDefinition taskNodeDefinition) throws Exception { return super.processConfiguration(taskNodeDefinition); } @Override public boolean validate(TaskNodeDefinition taskNodeDefinition) { LOGGER.info("--->HttpRequestConfig validate() the [HTTP Request]<taskNode:{}>", taskNodeDefinition.toString()); if (Objects.isNull(taskNodeDefinition.getConfigure()) || Objects.isNull(taskNodeDefinition.getConfigure()) || Objects.isNull(((HttpRequestDefinition)taskNodeDefinition.getConfigure()).getGeneral()) || StringUtils.isAnyBlank(((HttpRequestDefinition)taskNodeDefinition.getConfigure()).getGeneral().getMethod(), ((HttpRequestDefinition)taskNodeDefinition.getConfigure()).getGeneral().getPath(), ((HttpRequestDefinition)taskNodeDefinition.getConfigure()).getGeneral().getAccessKeyId())) { valicateErrorMessage="You must specify a value in the following fields: method、path、accessKeyId"; return false; } valicateErrorMessage=null; return true; } @Override public String validateReturnMessage(TaskNodeDefinition taskNodeDefinition){ LOGGER.info("--->HttpRequestConfig validateReturnMessage() the [HTTP Request]<taskNode:{}>", taskNodeDefinition.toString()); validate(taskNodeDefinition); return valicateErrorMessage; }
public class HttpRequestDefinition extends HttpRequestConfig implements Serializable { private GeneralDefinition general; private RequestDefinition request; private ResponseDefinition response; public GeneralDefinition getGeneral() { return general; } public void setGeneral(GeneralDefinition general) { this.general = general; } public RequestDefinition getRequest() { return request; } public void setRequest(RequestDefinition request) { this.request = request; } public ResponseDefinition getResponse() { return response; } public void setResponse(ResponseDefinition response) { this.response = response; } }
看完上述內容,你們對java中繼承的作用是什么有進一步的了解嗎?如果還想了解更多知識或者相關內容,請關注億速云行業資訊頻道,感謝大家的支持。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。