Coverage Report - com.ctrip.apollo.core.dto.AppConfigVO
 
Classes in this File Line Coverage Branch Coverage Complexity
AppConfigVO
0%
0/29
0%
0/2
1.037
AppConfigVO$OverrideAppConfig
0%
0/12
0%
0/2
1.037
AppConfigVO$OverrideClusterConfig
0%
0/8
N/A
1.037
 
 1  
 package com.ctrip.apollo.core.dto;
 2  
 
 3  
 
 4  
 import com.ctrip.apollo.core.enums.Env;
 5  
 
 6  
 import java.util.LinkedList;
 7  
 import java.util.List;
 8  
 
 9  
 public class AppConfigVO {
 10  
 
 11  
   private String appId;
 12  
 
 13  
   private Env env;
 14  
 
 15  
   /**
 16  
    * latest version if version is zero, or is release version
 17  
    */
 18  
   private long versionId;
 19  
 
 20  
   /**
 21  
    * default cluster and app self’s configs
 22  
    */
 23  
   private List<ItemDTO> defaultClusterConfigs;
 24  
 
 25  
   /**
 26  
    * default cluster and override other app configs
 27  
    */
 28  
   private List<OverrideAppConfig> overrideAppConfigs;
 29  
 
 30  
   /**
 31  
    * configs in different cluster maybe different.
 32  
    * overrideClusterConfigs only save diff configs from default cluster.
 33  
    * For example:
 34  
    * default cluster has 3 configs:
 35  
    * {a -> A, b -> B, c -> C}
 36  
    *
 37  
    * cluster1 has 1 config
 38  
    * {b -> D}
 39  
    *
 40  
    * if client read cluster1 configs will return {a -> A, b -> D, c -> C}
 41  
    */
 42  
   private List<OverrideClusterConfig> overrideClusterConfigs;
 43  
 
 44  0
   public AppConfigVO() {
 45  
 
 46  0
   }
 47  
 
 48  
   public static AppConfigVO newInstance(String appId, long versionId) {
 49  0
     AppConfigVO instance = new AppConfigVO();
 50  0
     instance.setAppId(appId);
 51  0
     instance.setVersionId(versionId);
 52  0
     instance.setDefaultClusterConfigs(new LinkedList<>());
 53  0
     instance.setOverrideAppConfigs(new LinkedList<>());
 54  0
     instance.setOverrideClusterConfigs(new LinkedList<>());
 55  0
     return instance;
 56  
   }
 57  
 
 58  
   public boolean isLatestVersion() {
 59  0
     return versionId == 0;
 60  
   }
 61  
 
 62  
   public static class OverrideAppConfig {
 63  
 
 64  
     private String appId;
 65  
     private List<ItemDTO> configs;
 66  
 
 67  0
     public OverrideAppConfig() {
 68  
 
 69  0
     }
 70  
 
 71  
     public String getAppId() {
 72  0
       return appId;
 73  
     }
 74  
 
 75  
     public void setAppId(String appId) {
 76  0
       this.appId = appId;
 77  0
     }
 78  
 
 79  
     public List<ItemDTO> getConfigs() {
 80  0
       return configs;
 81  
     }
 82  
 
 83  
     public void setConfigs(List<ItemDTO> configs) {
 84  0
       this.configs = configs;
 85  0
     }
 86  
 
 87  
     public void addConfig(ItemDTO config) {
 88  0
       if (configs == null) {
 89  0
         configs = new LinkedList<>();
 90  
       }
 91  0
       configs.add(config);
 92  0
     }
 93  
   }
 94  
 
 95  
 
 96  
   public static class OverrideClusterConfig {
 97  
 
 98  
     private String clusterName;
 99  
     private List<ItemDTO> configs;
 100  
 
 101  0
     public OverrideClusterConfig() {
 102  0
     }
 103  
 
 104  
     public String getClusterName() {
 105  0
       return clusterName;
 106  
     }
 107  
 
 108  
     public void setClusterName(String clusterName) {
 109  0
       this.clusterName = clusterName;
 110  0
     }
 111  
 
 112  
     public List<ItemDTO> getConfigs() {
 113  0
       return configs;
 114  
     }
 115  
 
 116  
     public void setConfigs(List<ItemDTO> configs) {
 117  0
       this.configs = configs;
 118  0
     }
 119  
   }
 120  
 
 121  
 
 122  
   public String getAppId() {
 123  0
     return appId;
 124  
   }
 125  
 
 126  
   public void setAppId(String appId) {
 127  0
     this.appId = appId;
 128  0
   }
 129  
 
 130  
   public Env getEnv() {
 131  0
     return env;
 132  
   }
 133  
 
 134  
   public void setEnv(Env env) {
 135  0
     this.env = env;
 136  0
   }
 137  
 
 138  
   public long getVersionId() {
 139  0
     return versionId;
 140  
   }
 141  
 
 142  
   public void setVersionId(long versionId) {
 143  0
     this.versionId = versionId;
 144  0
   }
 145  
 
 146  
   public List<ItemDTO> getDefaultClusterConfigs() {
 147  0
     return defaultClusterConfigs;
 148  
   }
 149  
 
 150  
   public void setDefaultClusterConfigs(List<ItemDTO> defaultClusterConfigs) {
 151  0
     this.defaultClusterConfigs = defaultClusterConfigs;
 152  0
   }
 153  
 
 154  
   public List<OverrideAppConfig> getOverrideAppConfigs() {
 155  0
     return overrideAppConfigs;
 156  
   }
 157  
 
 158  
   public void setOverrideAppConfigs(List<OverrideAppConfig> overrideAppConfigs) {
 159  0
     this.overrideAppConfigs = overrideAppConfigs;
 160  0
   }
 161  
 
 162  
   public List<OverrideClusterConfig> getOverrideClusterConfigs() {
 163  0
     return overrideClusterConfigs;
 164  
   }
 165  
 
 166  
   public void setOverrideClusterConfigs(List<OverrideClusterConfig> overrideClusterConfigs) {
 167  0
     this.overrideClusterConfigs = overrideClusterConfigs;
 168  0
   }
 169  
 
 170  
   @Override
 171  
   public String toString() {
 172  0
     return "Config4PortalDTO{" +
 173  
         "appId=" + appId +
 174  
         ", env=" + env +
 175  
         ", versionId=" + versionId +
 176  
         ", defaultClusterConfigs=" + defaultClusterConfigs +
 177  
         ", overrideAppConfigs=" + overrideAppConfigs +
 178  
         ", overrideClusterConfigs=" + overrideClusterConfigs +
 179  
         '}';
 180  
   }
 181  
 }