一个多层嵌套的类,json的辅助类需要初始化,要怎么写比较简便?

public class PieOption {
 private SeriesBean series;
    public static class SeriesBean {
        private LabelBean label;
        public static class LabelBean {      
            private EmphasisBean emphasis;
            public static class EmphasisBean {
                private boolean show;
                private TextStyleBean textStyle;
                public static class TextStyleBean {
                    private String fontSize;
                    private String fontWeight;
                }
            }
        }
    }
}

new个对象再调用set方法实在是太费事了
SeriesBean.LabelBean.EmphasisBean.TextStyleBean textStyleBean = new SeriesBean.LabelBean.EmphasisBean.TextStyleBean();这样写太可怕了

阅读 3.4k
1 个回答

不要写成内部类...

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题