/** * Check if the field identified by the field name exists according to the schema. * @param type contains metadata about fields * @param fieldName is the field's field name to test * @return a String error message if the field doesn't exist, or null to indicate success */ public static String exists(EventType type, String fieldName) { Class clazz = getClass(type, fieldName); if (clazz == null) { return "Parent view does not contain a field named '" + fieldName + '\''; } return null; }
/** * Check if the fields identified by the field names both exists according to the schema. * @param type contains metadata about fields * @param fieldNameOne is the first field's field name to test * @param fieldNameTwo is the first field's field name to test * @return a String error message if either of the fields doesn't exist, or null to indicate success */ public static String exists(EventType type, String fieldNameOne, String fieldNameTwo) { Class clazz = getClass(type, fieldNameOne); if (clazz == null) { return "Parent view does not contain a field named '" + fieldNameOne + '\''; } clazz = getClass(type, fieldNameTwo); if (clazz == null) { return "Parent view does not contain a field named '" + fieldNameTwo + '\''; } return null; }
private static String checkFieldNumeric(EventType type, String numericFieldName) { Class clazz = getClass(type, numericFieldName); if (clazz == null) { return "Parent view does not contain a field named '" + numericFieldName + '\''; } if (!JavaClassHelper.isNumeric(clazz)) { return "Parent view field named '" + numericFieldName + "' is not a number"; } return null; }
/** * Check if the field identified by the field name is of type long according to the schema. * @param type contains metadata about fields * @param longFieldName is the field's field name to test * @return a String error message if the field doesn't exist or is not a long, or null to indicate success */ public static String checkLong(EventType type, String longFieldName) { Class clazz = getClass(type, longFieldName); if (clazz == null) { return "Parent view does not contain a field named '" + longFieldName + '\''; } if ((clazz != Long.class) && (clazz != long.class)) { return "Parent view field named '" + longFieldName + "' is not of type long"; } return checkFieldNumeric(type, longFieldName); }