class Utils {

    public static <T extends ServiceDocument> void validateState(
            ServiceDocumentDescription desc, T state) {
        for (PropertyDescription prop : desc.propertyDescriptions.values()) {
            if (prop.usageOptions != null &&
                    prop.usageOptions.contains(PropertyUsageOption.REQUIRED)) {
                Object o = ReflectionUtils.getPropertyValue(prop, state);
                if (o == null) {
                    if (prop.usageOptions.contains(PropertyUsageOption.ID)) {
                        ReflectionUtils.setPropertyValue(prop, state, UUID.randomUUID().toString());
                    } else {
                        throw new IllegalArgumentException(
                                prop.accessor.getName() + " is a required field.");
                    }
                }
            }
        }
    }

    private  Utils();

}