Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the role of inheritance in java

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

Today, I would like to talk to you about the role of inheritance in java. Many people may not know much about it. In order to make you understand better, the editor has summarized the following for you. I hope you can get something according to this article.

Parent class of configuration

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]", target.toString ()); return target;} public TaskNodeDefinition processConfiguration (TaskNodeDefinition taskNodeDefinition) throws Exception {LOGGER.info ("- > ConfigureDefinition processConfiguration () the [task node]", taskNodeDefinition.toString ()) Validate (taskNodeDefinition); return taskNodeDefinition;} public boolean validate (TaskNodeDefinition taskNodeDefinition) {LOGGER.info ("--> ConfigureDefinition validate () the [task node]", taskNodeDefinition.toString ()); return true;} public String validateReturnMessage (TaskNodeDefinition taskNodeDefinition) {LOGGER.info ("- > ConfigureDefinition validateReturnMessage () the [task node]", taskNodeDefinition.toString ()); validate (taskNodeDefinition); return valicateErrorMessage }} different subclasses have their own business logic. If not, the logic of the parent class 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]", 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]", 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]", taskNodeDefinition.toString ()); validate (taskNodeDefinition); return valicateErrorMessage;} Database layer Domain Model 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 }} after reading the above, do you have any further understanding of the role of inheritance in java? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report