code: protected Map<String, ClassNode> getPropertiesToEnsureConstraintsFor(final ClassNode classNode) {
          final Map<String, ClassNode> fieldsToConstrain = new HashMap<String, ClassNode>();
          final List<FieldNode> allFields = classNode.getFields();
          for (final FieldNode field : allFields) {
              if (!field.isStatic()) {
                      final PropertyNode property = classNode.getProperty(field.getName());
                      if(property != null) {
                          fieldsToConstrain.put(field.getName(), field.getType());
                      }
              }
          }
          final Map<String, MethodNode> declaredMethodsMap = classNode.getDeclaredMethodsMap();
          for (Entry<String, MethodNode> methodEntry : declaredMethodsMap.entrySet()) {
              final MethodNode value = methodEntry.getValue();
              if (!value.isStatic() && value.isPublic() && classNode.equals(value.getDeclaringClass()) && value.getLineNumber() > 0) {
                  Parameter[] parameters = value.getParameters();
                  if (parameters == null || parameters.length == 0) {
                      final String methodName = value.getName();
                      if (methodName.startsWith("get")) {
                          final ClassNode returnType = value.getReturnType();
                          final String restOfMethodName = methodName.substring(3);
                          final String propertyName = GrailsNameUtils.getPropertyName(restOfMethodName);
  
                          fieldsToConstrain.put(propertyName, returnType);
                      }
                  }
              }
          }
  
          final ClassNode superClass = classNode.getSuperClass();
          if (!superClass.equals(new ClassNode(Object.class))) {
              fieldsToConstrain.putAll(getPropertiesToEnsureConstraintsFor(superClass));
          }
          return fieldsToConstrain;
      }
docs: Retrieves a Map describing all of the properties which need to be constrained for the class
  represented by classNode.  The keys in the Map will be property names and the values are the
  type of the corresponding property.
  
  @param classNode the class to inspect
  @return a Map describing all of the properties which need to be constrained