今天就跟大家聊聊有关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进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。