@Override public boolean isNullOrMissing( String name ) { return Null.matches(get(name)); }
@Override public boolean isNullOrMissing( String name ) { return Null.matches(get(name)); }
@Override public boolean isNullOrMissing( String name ) { return Null.matches(get(name)); }
@Override public boolean isNullOrMissing( String name ) { return Null.matches(get(name)); }
protected void addValidatorsForDisallowedTypes( Document parent, Path parentPath, Problems problems, CompositeValidator validators ) { Object disallowed = parent.get("disallowed"); if (Null.matches(disallowed)) return; String requiredName = parentPath.getLast(); if (requiredName != null) { EnumSet<Type> disallowedTypes = Type.typesWithNames(disallowed); validators.add(new DisallowedTypesValidator(requiredName, disallowedTypes)); } }
protected void addValidatorsForDisallowedTypes( Document parent, Path parentPath, Problems problems, CompositeValidator validators ) { Object disallowed = parent.get("disallowed"); if (Null.matches(disallowed)) return; String requiredName = parentPath.getLast(); if (requiredName != null) { EnumSet<Type> disallowedTypes = Type.typesWithNames(disallowed); validators.add(new DisallowedTypesValidator(requiredName, disallowedTypes)); } }
public boolean hasProperty( Document document, Name propertyName ) { // Get the properties container ... Document properties = document.getDocument(PROPERTIES); if (properties == null) { return false; } // Get the namespace container for the property name's namespace ... Document urlProps = properties.getDocument(propertyName.getNamespaceUri()); if (urlProps == null) { return false; } // Get the property ... Object fieldValue = urlProps.get(propertyName.getLocalName()); return !Null.matches(fieldValue); }
public boolean hasProperty( Document document, Name propertyName ) { // Get the properties container ... Document properties = document.getDocument(PROPERTIES); if (properties == null) { return false; } // Get the namespace container for the property name's namespace ... Document urlProps = properties.getDocument(propertyName.getNamespaceUri()); if (urlProps == null) { return false; } // Get the property ... Object fieldValue = urlProps.get(propertyName.getLocalName()); return !Null.matches(fieldValue); }
public boolean hasProperties( Document document ) { // Get the properties container ... Document properties = document.getDocument(PROPERTIES); if (properties == null) { return false; } for (Field nsField : properties.fields()) { Document urlProps = nsField.getValueAsDocument(); if (urlProps != null) { for (Field propField : urlProps.fields()) { if (!Null.matches(propField.getValue())) { return true; } } } } return false; }
public boolean hasProperties( Document document ) { // Get the properties container ... Document properties = document.getDocument(PROPERTIES); if (properties == null) { return false; } for (Field nsField : properties.fields()) { Document urlProps = nsField.getValueAsDocument(); if (urlProps != null) { for (Field propField : urlProps.fields()) { if (!Null.matches(propField.getValue())) { return true; } } } } return false; }
public int countProperties( Document document ) { // Get the properties container ... Document properties = document.getDocument(PROPERTIES); if (properties == null) { return 0; } int count = 0; for (Field nsField : properties.fields()) { Document urlProps = nsField.getValueAsDocument(); if (urlProps != null) { for (Field propField : urlProps.fields()) { if (!Null.matches(propField.getValue())) { ++count; } } } } return count; }
public int countProperties( Document document ) { // Get the properties container ... Document properties = document.getDocument(PROPERTIES); if (properties == null) { return 0; } int count = 0; for (Field nsField : properties.fields()) { Document urlProps = nsField.getValueAsDocument(); if (urlProps != null) { for (Field propField : urlProps.fields()) { if (!Null.matches(propField.getValue())) { ++count; } } } } return count; }
@Override public void merge( Document other ) { if (other == this) return; for (Field field : other.fields()) { Document otherDoc = field.getValueAsDocument(); if (!Null.matches(otherDoc)) { // Get the corresponding value in this document ... EditableDocument thisField = getDocument(field.getName()); if (!Null.matches(thisField)) { // There are docs in both sides, so merge them ... thisField.merge(otherDoc); } else { // There is not a document on this side (perhaps another value), so replace with that other doc ... doSetValue(field.getName(), otherDoc); } } else { // The field is something other than a document, so just set it on this document ... doSetValue(field.getName(), field.getValue()); } } }
@Override public void merge( Document other ) { if (other == this) return; for (Field field : other.fields()) { Document otherDoc = field.getValueAsDocument(); if (!Null.matches(otherDoc)) { // Get the corresponding value in this document ... EditableDocument thisField = getDocument(field.getName()); if (!Null.matches(thisField)) { // There are docs in both sides, so merge them ... thisField.merge(otherDoc); } else { // There is not a document on this side (perhaps another value), so replace with that other doc ... doSetValue(field.getName(), otherDoc); } } else { // The field is something other than a document, so just set it on this document ... doSetValue(field.getName(), field.getValue()); } } }
protected void assertField( String name, Object value ) { Object actual = bson.get(name); if (value == null) { assertTrue(Null.matches(actual)); } else { assertEquals(value, actual); } } }
@Override public void validate( Object fieldValue, String fieldName, Document parent, Path pathToParent, Problems problems, SchemaDocumentResolver resolver ) { if (Null.matches(fieldValue) && fieldName != null) { if (pathToParent.size() == 0) { problems.recordError(pathToParent.with(fieldName), "The top-level '" + fieldName + "' field is required"); } else { problems.recordError(pathToParent.with(fieldName), "The '" + fieldName + "' field on '" + pathToParent + "' is required"); } } else { problems.recordSuccess(); } }
@Override public void validate( Object fieldValue, String fieldName, Document parent, Path pathToParent, Problems problems, SchemaDocumentResolver resolver ) { if (Null.matches(fieldValue) && fieldName != null) { if (pathToParent.size() == 0) { problems.recordError(pathToParent.with(fieldName), "The top-level '" + fieldName + "' field is required"); } else { problems.recordError(pathToParent.with(fieldName), "The '" + fieldName + "' field on '" + pathToParent + "' is required"); } } else { problems.recordSuccess(); } }
@Test public void shouldParseValueAsNullGivenNullLiteral() throws Exception { value = parser("null").parseValue(); assertTrue(Null.matches(value)); }
@Test public void shouldParseValueAsNullGivenNoContent() throws Exception { value = parser("").parseValue(); assertTrue(Null.matches(value)); }
@Test public void shouldParseValueAsNullGivenNullLiteralWithIncorrectCase() throws Exception { value = parser("nULl").parseValue(); assertTrue(Null.matches(value)); }