@Test public void setIfEmptyOnlySetsIfEmpty() throws URISyntaxException { JType firstClass = mock(JDefinedClass.class); JType secondClass = mock(JDefinedClass.class); URI schemaUri = getClass().getResource("/schema/address.json").toURI(); Schema schema = new SchemaStore().create(schemaUri, "#/."); schema.setJavaTypeIfEmpty(firstClass); assertThat(schema.getJavaType(), is(equalTo(firstClass))); schema.setJavaTypeIfEmpty(secondClass); assertThat(schema.getJavaType(), is(not(equalTo(secondClass)))); }
public synchronized Schema create(URI id, String refFragmentPathDelimiters) { URI normalizedId = id.normalize(); if (!schemas.containsKey(normalizedId)) { URI baseId = removeFragment(id).normalize(); JsonNode baseContent = contentResolver.resolve(baseId); Schema baseSchema = new Schema(baseId, baseContent, null); if (normalizedId.toString().contains("#")) { JsonNode childContent = fragmentResolver.resolve(baseContent, '#' + id.getFragment(), refFragmentPathDelimiters); schemas.put(normalizedId, new Schema(normalizedId, childContent, baseSchema)); } else { schemas.put(normalizedId, baseSchema); } } return schemas.get(normalizedId); }
SchemaStore { public synchronized Schema create(URI id, String refFragmentPathDelimiters) { URI normalizedId = id.normalize(); if (!schemas.containsKey(normalizedId)) { URI baseId = removeFragment(id).normalize(); JsonNode baseContent = contentResolver.resolve(baseId); Schema baseSchema = new Schema(baseId, baseContent, null); if (normalizedId.toString().contains("#")) { JsonNode childContent = fragmentResolver.resolve(baseContent, '#' + id.getFragment(), refFragmentPathDelimiters); schemas.put(normalizedId, new Schema(normalizedId, childContent, baseSchema)); } else { schemas.put(normalizedId, baseSchema); } } return schemas.get(normalizedId); } }
SchemaStore { public synchronized Schema create(URI id, String refFragmentPathDelimiters) { URI normalizedId = id.normalize(); if (!schemas.containsKey(normalizedId)) { URI baseId = removeFragment(id).normalize(); JsonNode baseContent = contentResolver.resolve(baseId); Schema baseSchema = new Schema(baseId, baseContent, null); if (normalizedId.toString().contains("#")) { JsonNode childContent = fragmentResolver.resolve(baseContent, '#' + id.getFragment(), refFragmentPathDelimiters); schemas.put(normalizedId, new Schema(normalizedId, childContent, baseSchema)); } else { schemas.put(normalizedId, baseSchema); } } return schemas.get(normalizedId); } SchemaStore();  SchemaStore(ContentResolver contentResolver); }
SchemaStore { public synchronized Schema create(URI id, String refFragmentPathDelimiters) { URI normalizedId = id.normalize(); if (!schemas.containsKey(normalizedId)) { URI baseId = removeFragment(id).normalize(); JsonNode baseContent = contentResolver.resolve(baseId); Schema baseSchema = new Schema(baseId, baseContent, null); if (normalizedId.toString().contains("#")) { JsonNode childContent = fragmentResolver.resolve(baseContent, '#' + id.getFragment(), refFragmentPathDelimiters); schemas.put(normalizedId, new Schema(normalizedId, childContent, baseSchema)); } else { schemas.put(normalizedId, baseSchema); } } return schemas.get(normalizedId); } SchemaStore();  SchemaStore(ContentResolver contentResolver); synchronized Schema create(URI id, String refFragmentPathDelimiters); @SuppressWarnings("PMD.UselessParentheses") Schema create(Schema parent, String path, String refFragmentPathDelimiters); synchronized void clearCache(); }
SchemaStore { public synchronized Schema create(URI id, String refFragmentPathDelimiters) { URI normalizedId = id.normalize(); if (!schemas.containsKey(normalizedId)) { URI baseId = removeFragment(id).normalize(); JsonNode baseContent = contentResolver.resolve(baseId); Schema baseSchema = new Schema(baseId, baseContent, null); if (normalizedId.toString().contains("#")) { JsonNode childContent = fragmentResolver.resolve(baseContent, '#' + id.getFragment(), refFragmentPathDelimiters); schemas.put(normalizedId, new Schema(normalizedId, childContent, baseSchema)); } else { schemas.put(normalizedId, baseSchema); } } return schemas.get(normalizedId); } SchemaStore();  SchemaStore(ContentResolver contentResolver); synchronized Schema create(URI id, String refFragmentPathDelimiters); @SuppressWarnings("PMD.UselessParentheses") Schema create(Schema parent, String path, String refFragmentPathDelimiters); synchronized void clearCache();  }