@Override public boolean isNullOrMissing( String name ) { return Null.matches(get(name)); }
@Override public Object convert( Object value, Type type ) { if (value == null || value instanceof Null) return Null.getInstance(); return null; } }
@Override public int hashCode() { return INSTANCE.hashCode(); }
@Override public boolean isNullOrMissing( String name ) { return Null.matches(get(name)); }
@Override public Object convert( Object value, Type type ) { if (value == null || value instanceof Null) return Null.getInstance(); return null; } }
@Override public int hashCode() { return INSTANCE.hashCode(); }
@Override public boolean isNullOrMissing( String name ) { return Null.matches(get(name)); }
@Override public Object createNull() { return Null.getInstance(); }
@Override public boolean isNullOrMissing( String name ) { return Null.matches(get(name)); }
@Override public Object createNull() { return Null.getInstance(); }
public static boolean valuesAreEqual(Object thisValue, Object thatValue) { if (thisValue == thatValue) { return true; } if (thisValue == null || thisValue instanceof Null) { return Null.matches(thatValue); } if (thisValue instanceof Number && thatValue instanceof Number) { // Need to handle float vs. doubles Number thisNumber = (Number) thisValue; Number thatNumber = (Number) thatValue; return thisNumber.doubleValue() == thatNumber.doubleValue(); } if (thisValue instanceof Pattern && thatValue instanceof Pattern) { // java.util.regex.Pattern does not implement equals!! Pattern thisPattern = (Pattern) thisValue; Pattern thatPattern = (Pattern) thatValue; return thisPattern.pattern().equals(thatPattern.pattern()) && thisPattern.flags() == thatPattern.flags(); } return thisValue.equals(thatValue); }
/** * Parse the value given by the supplied string located at the supplied line and column numbers. This method looks for * known constant values, then attempts to parse the value as a number, and then calls * {@link #parseUnknownValue(String, int, int)}. * * @param value the string representation of the value * @param lineNumber the line number for the beginning of the value * @param columnNumber the column number for the beginning of the value * @return the value * @throws ParsingException if there is a problem parsing the value */ public Object parseValue( String value, int lineNumber, int columnNumber ) throws ParsingException { if (value.length() == 0) return value; if ("true".equalsIgnoreCase(value)) return Boolean.TRUE; if ("false".equalsIgnoreCase(value)) return Boolean.FALSE; if ("null".equalsIgnoreCase(value)) return Null.getInstance(); // Try to parse as a number ... Number number = parseNumber(value); if (number != null) return number; return parseUnknownValue(value, lineNumber, columnNumber); }
public static boolean valuesAreEqual(Object thisValue, Object thatValue) { if (thisValue == thatValue) { return true; } if (thisValue == null || thisValue instanceof Null) { return Null.matches(thatValue); } if (thisValue instanceof Number && thatValue instanceof Number) { // Need to handle float vs. doubles Number thisNumber = (Number) thisValue; Number thatNumber = (Number) thatValue; return thisNumber.doubleValue() == thatNumber.doubleValue(); } if (thisValue instanceof Pattern && thatValue instanceof Pattern) { // java.util.regex.Pattern does not implement equals!! Pattern thisPattern = (Pattern) thisValue; Pattern thatPattern = (Pattern) thatValue; return thisPattern.pattern().equals(thatPattern.pattern()) && thisPattern.flags() == thatPattern.flags(); } return thisValue.equals(thatValue); }
/** * Parse the value given by the supplied string located at the supplied line and column numbers. This method looks for * known constant values, then attempts to parse the value as a number, and then calls * {@link #parseUnknownValue(String, int, int)}. * * @param value the string representation of the value * @param lineNumber the line number for the beginning of the value * @param columnNumber the column number for the beginning of the value * @return the value * @throws ParsingException if there is a problem parsing the value */ public Object parseValue( String value, int lineNumber, int columnNumber ) throws ParsingException { if (value.length() == 0) return value; if ("true".equalsIgnoreCase(value)) return Boolean.TRUE; if ("false".equalsIgnoreCase(value)) return Boolean.FALSE; if ("null".equalsIgnoreCase(value)) return Null.getInstance(); // Try to parse as a number ... Number number = parseNumber(value); if (number != null) return number; return parseUnknownValue(value, lineNumber, columnNumber); }
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)); } }
/** * The method that does the actual setting for all of the <code>set...</code> methods. This method may be overridden by * subclasses when additional work needs to be performed during the set operations. * * @param name the name of the field being set * @param value the new value * @return the old value, or null if there was no existing value */ protected Object doSetValueIfAbsent( String name, Object value ) { if (value == null) { value = Null.getInstance(); } else { value = Utility.unwrap(value); } return document.put(name, value); }
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)); } }
/** * The method that does the actual setting for all of the <code>set...</code> methods. This method may be overridden by * subclasses when additional work needs to be performed during the set operations. * * @param name the name of the field being set * @param value the new value * @return the old value, or null if there was no existing value */ protected Object doSetValue( String name, Object value ) { if (value == null) { value = Null.getInstance(); } else { value = Utility.unwrap(value); } return document.put(name, value); }
try { if (numFields == 1) { if (!Null.matches(value = doc.get(OBJECT_ID))) { String bytesInBase16 = value.toString(); return values.createObjectId(bytesInBase16); if (!Null.matches(value = doc.get(DATE))) { if (value instanceof Date) { return value; if (!Null.matches(value = doc.get(REGEX_PATTERN))) { String pattern = value.toString(); return values.createRegex(pattern, null); if (!Null.matches(value = doc.get(UUID))) { return values.createUuid(value.toString()); if (!Null.matches(value = doc.get(CODE))) { String code = value.toString(); return values.createCode(code); if (!Null.matches(value = doc.get(TIMESTAMP))) { int time = doc.getInteger(TIMESTAMP); int inc = doc.getInteger(INCREMENT); return values.createTimestamp(time, inc); if (!Null.matches(value = doc.get(REGEX_PATTERN))) { String pattern = value.toString(); String options = doc.getString(REGEX_OPTIONS);
/** * The method that does the actual setting for all of the <code>set...</code> methods. This method may be overridden by * subclasses when additional work needs to be performed during the set operations. * * @param name the name of the field being set * @param value the new value * @return the old value, or null if there was no existing value */ protected Object doSetValueIfAbsent( String name, Object value ) { if (value == null) { value = Null.getInstance(); } else { value = Utility.unwrap(value); } return document.put(name, value); }