public static void completeDefaults()

in src/main/java/com/amazonaws/schemamanager/repo/RepoUtils.java [154:188]


	public static void completeDefaults(RepoSchema repoSchema, Map<String, DefaultSchemaMetadata> defaults) {
		if (repoSchema == null) {
			return;
		}
		RepoSchemaMetadata meta = repoSchema.getMetadata();
		
		Path schemaPath = Paths.get(repoSchema.getPath());
		DefaultSchemaMetadata defaultMeta = defaults.get(schemaPath.getParent().toString());
		if (meta == null) {
			repoSchema.setMetadata(defaultMeta);
			return;
		}
		
		if (meta.getDefaultCompatibility() == null) {
			meta.setDefaultCompatibility(defaultMeta.getDefaultCompatibility());
		}
		
		Map<String, Map<String, String>> subjects = meta.getSubjects();
		if (subjects != null && subjects.isEmpty()) {
			//special case to avoid creating subjects for this particular schema.
			return;
		}
		if (subjects == null) {
			subjects = new HashMap<String, Map<String,String>>();
			subjects.computeIfAbsent(getSubjectName(repoSchema), m-> new HashMap<String, String>()).put("compatibility", meta.getDefaultCompatibility());
			repoSchema.getMetadata().setSubjects(subjects);
		}else {
			subjects.forEach((subj, m) -> {
				if (m.get("compatibility") == null) {
					m.put("compatibility", meta.getDefaultCompatibility());
				}
			});
		}
		
	}