class ReferMetadataProvider {

    public ReferMetadata createReferMetadata(Type type, String ref) {
        Type actualType = type;
        if (isCollection(type)) {
            actualType = getCollectionGeneric(type);
        }
        for (ReferMetadataCreator creator : creators) {
            if (creator.isApplicable(actualType, ref.replace("[*]", ""))) {
                return creator.getReferMetadata(actualType, ref);
            }
        }
        throw new IllegalArgumentException(String.format("Unable to refer to field %s " +
                "Class doesn't implement map interface and " +
                "class doesn't have public field and " +
                "class doesn't have appropriate getter.", ref));
    }

}