public String getContent() { for (NewsContent newsContent : newsContents) { if (newsContent.getLang().getSymbol().equals(lang)) { return newsContent.getContent(); } } return null; }
private NewsContent getNewsContent() { for (NewsContent newsContent : newsContents) { if (newsContent.getLang().getSymbol().equals(lang)) { return newsContent; } } NewsContent newsContent = new NewsContent(); newsContent.setLang(Lang.valueOf(lang)); newsContent.setNews(this); newsContents.add(newsContent); return newsContent; }
// setContent方法依赖于setLang方法先执行 public void setContent(String content) { log.info("设置内容"); log.info("模型语言:" + lang); NewsContent newsContent = getNewsContent(); newsContent.setContent(content); }
// setTitle方法依赖于setLang方法先执行 public void setTitle(String title) { log.info("设置标题"); log.info("模型语言:" + lang); NewsContent newsContent = getNewsContent(); newsContent.setTitle(title); }