package cn.axzo.msg.center.service.domain;

/**
 * @author yanglin
 */
public class UrlConfigWalker {

    public static void walkDown(UrlConfig urlConfig, UrlConfigVisitor visitor) {
        if (urlConfig == null) return;
        visitor.visitUrlConfig(urlConfig);
        visitPcOms(urlConfig, visitor);
        visitPcCms(urlConfig, visitor);
        visitPcGaGeneral(urlConfig, visitor);
        visitAppWorker(urlConfig, visitor);
        visitAppManager(urlConfig, visitor);
    }

    private static void visitPcOms(UrlConfig urlConfig, UrlConfigVisitor visitor) {
        if (urlConfig.getPcOms() != null)
            visitor.visitPcOms(urlConfig.getPcOms());
    }

    private static void visitPcCms(UrlConfig urlConfig, UrlConfigVisitor visitor) {
        if (urlConfig.getPcCms() != null)
            visitor.visitPcCms(urlConfig.getPcCms());
    }

    private static void visitPcGaGeneral(UrlConfig urlConfig, UrlConfigVisitor visitor) {
        if (urlConfig.getPcGaGeneral() != null)
            visitor.visitPcGaGeneral(urlConfig.getPcGaGeneral());
    }

    private static void visitAppWorker(UrlConfig urlConfig, UrlConfigVisitor visitor) {
        if (urlConfig.getAppWorker() == null) return;
        visitor.visitAppWorker(urlConfig.getAppWorker());
        if (urlConfig.getAppWorker().getIos() != null)
            visitor.visitAppWorkerIos(urlConfig.getAppWorker().getIos());
        if (urlConfig.getAppWorker().getAndroid() != null)
            visitor.visitAppWorkerAndroid(urlConfig.getAppWorker().getAndroid());
    }

    private static void visitAppManager(UrlConfig urlConfig, UrlConfigVisitor visitor) {
        if (urlConfig.getAppManager() == null) return;
        visitor.visitAppManager(urlConfig.getAppManager());
        if (urlConfig.getAppManager().getIos() != null)
            visitor.visitAppManagerIos(urlConfig.getAppManager().getIos());
        if (urlConfig.getAppManager().getAndroid() != null)
            visitor.visitAppManagerAndroid(urlConfig.getAppManager().getAndroid());
    }

}