@@ -0,0 +1,2545 @@
+/**%0A *%0A * Copyright (c) Microsoft Corporation. All rights reserved.%0A * Licensed under the MIT License. See License.txt in the project root for license information.%0A *%0A */%0A%0Apackage com.microsoft.rest;%0A%0Aimport com.fasterxml.jackson.annotation.JsonProperty;%0Aimport org.apache.commons.lang3.ClassUtils;%0Aimport org.apache.commons.lang3.reflect.FieldUtils;%0Aimport org.joda.time.DateTime;%0A%0Aimport java.lang.reflect.Field;%0Aimport java.time.LocalDate;%0Aimport java.util.List;%0Aimport java.util.Map;%0Aimport java.util.Objects;%0A%0A/**%0A * ServiceClient is the abstraction for accessing REST operations and their payload data types.%0A */%0Apublic class Validator %7B%0A    public static void validate(Object request, Class type) throws NullPointerException %7B%0A        Field%5B%5D fields = FieldUtils.getAllFields(type);%0A        for (Field field : fields) %7B%0A            field.setAccessible(true);%0A            JsonProperty annotation = field.getAnnotation(JsonProperty.class);%0A            Object property = null;%0A            try %7B%0A                property = field.get(request);%0A            %7D catch (IllegalAccessException e) %7B%0A                // Ignore inaccessible fields%0A            %7D%0A            if (annotation != null && annotation.required()) %7B%0A                Objects.requireNonNull(property, field.getName() + %22 == null%22);%0A            %7D%0A%0A            if (property != null) %7B%0A                Class propertyType = property.getClass();%0A                if (ClassUtils.isAssignable(propertyType, List.class)) %7B%0A                    List%3C?%3E items = (List%3C?%3E)property;%0A                    for (Object item : items) %7B%0A                        Validator.validate(item, item.getClass());%0A                    %7D%0A                %7D%0A                if (ClassUtils.isAssignable(propertyType, Map.class)) %7B%0A                    Map%3C?, ?%3E entries = (Map%3C?, ?%3E)property;%0A                    for (Map.Entry%3C?, ?%3E entry : entries.entrySet()) %7B%0A                        Validator.validate(entry.getKey(), entry.getKey().getClass());%0A                        Validator.validate(entry.getValue(), entry.getValue().getClass());%0A                    %7D%0A                %7D%0A                else if (!(ClassUtils.isPrimitiveOrWrapper(propertyType) %7C%7C%0A                        ClassUtils.isAssignable(propertyType, LocalDate.class) %7C%7C%0A                        ClassUtils.isAssignable(propertyType, DateTime.class) %7C%7C%0A                        ClassUtils.isAssignable(propertyType, String.class))) %7B%0A                    Validator.validate(property, propertyType);%0A                %7D%0A            %7D%0A        %7D%0A    %7D%0A%7D%0A

Add validator based on JSON annotation