RecordType extends AbstractType { public boolean isAssignableValue(Object source) { if (source == null) { return true; } if (source instanceof TypedMap) { return this.equals(((TypedMap) source).getType()); } if (source instanceof Map) { for (Entry<?, ?> entry : ((Map<?, ?>) source).entrySet()) { if ((entry.getKey() instanceof String) == false) { return false; } String fieldName = (String) entry.getKey(); if (getFieldType(fieldName).isAssignableValue(entry.getValue()) == false) { return false; } } return true; } return false; } RecordType();  RecordType(final String id, final String name);  RecordType(final String id, final String name,
			final Map<String, Type> fieldTypes); Map<String, Type> getFieldTypes(); void setFieldTypes(Map<String, Type> fieldTypes); Type getFieldType(final String fieldName); @SuppressWarnings("unchecked") Object convertToTypedObject(final Object source); boolean isAssignableValue(Object source); @Override boolean isValid();  }
@Test public void testIsAssignableValue() throws Exception { final Map<String, Object> valueA1 = new HashMap<String, Object>() { private static final long serialVersionUID = 3284655428518660243L; { put("a", "valueA"); put("b", 1); } }; final Map<String, Object> valueA2 = new HashMap<String, Object>() { private static final long serialVersionUID = 6776775395656328695L; { put("a", "valueA"); } }; final Map<String, Object> valueA3 = new HashMap<String, Object>() { private static final long serialVersionUID = -5765762438505921584L; { put("a", "valueA"); put("c", true); } }; assertTrue(recordTypeA.isAssignableValue(valueA1)); assertTrue(recordTypeA.isAssignableValue(valueA2)); try { recordTypeA.isAssignableValue(valueA3); fail(); } catch (NoSuchRecordFieldException e) { } final Map<String, Object> valueB1 = new HashMap<String, Object>() { private static final long serialVersionUID = -3644426118423305930L; { put("c", true); put("d", new String[] { "x", "y", "z" }); } }; final Map<String, Object> valueB2 = new HashMap<String, Object>() { private static final long serialVersionUID = -185879951518993662L; { put("c", true); put("d", new String[] {}); } }; final Map<String, Object> valueB3 = new HashMap<String, Object>() { private static final long serialVersionUID = -6515925286263685839L; { put("c", true); put("d", null); } }; assertTrue(recordTypeB.isAssignableValue(valueB1)); assertTrue(recordTypeB.isAssignableValue(valueB2)); assertTrue(recordTypeB.isAssignableValue(valueB3)); final Map<String, Object> valueC1 = new HashMap<String, Object>() { private static final long serialVersionUID = -1730034652757831321L; { put("e", valueA1); put("f", Calendar.getInstance()); } }; final Map<String, Object> valueC2 = new HashMap<String, Object>() { private static final long serialVersionUID = -811765504132330071L; { put("e", valueB1); put("f", Calendar.getInstance()); } }; assertTrue(recordTypeC.isAssignableValue(valueC1)); try { recordTypeC.isAssignableValue(valueC2); fail(); } catch (NoSuchRecordFieldException e) { } }