code: public static MetaAttribute findAttribute(MetaDataObject meta, Object value) {
  		if (value == null) {
  			throw new IllegalArgumentException("null as value not supported");
  		}
  
  		for (MetaAttribute attr : meta.getAttributes()) {
  			if (attr.getName().equals(TYPE_ATTRIBUTE)) {
  				continue;
  			}
  			if (attr.isDerived()) {
  				// we only consider persisted classes, not derived ones like
  				// "value" itself
  				continue;
  			}
  			if (attr.getType().getImplementationClass().isAssignableFrom(value.getClass())) {
  				return attr;
  			}
  		}
  		throw new IllegalArgumentException("cannot find anyType attribute for value '" + value + '\'');
  	}
docs: Finds a matching attribute for a given value.
  
  @param meta  the metadataobject
  @param value the value
  @return the attribute which will accept the given value