text:
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Linq;
using Azure.Core;
using Azure.Core.Pipeline;
using Azure.Storage.Files.Shares.Models;

namespace Azure.Storage.Files.Shares
{
    internal partial class DirectoryRestClient
    {
        private string url;
        private string version;
        private ClientDiagnostics _clientDiagnostics;
        private HttpPipeline _pipeline;

        ///  Initializes a new instance of DirectoryRestClient.
        /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param>
        /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param>
        /// <param name="url"> The URL of the service account, share, directory or file that is the target of the desired operation. </param>
        /// <param name="version"> Specifies the version of the operation to use for this request. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="url"/> or <paramref name="version"/> is null. </exception>
        public DirectoryRestClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string url, string version = "2020-10-02")
        {
            this.url = url ?? throw new ArgumentNullException(nameof(url));
            this.version = version ?? throw new ArgumentNullException(nameof(version));
            _clientDiagnostics = clientDiagnostics;
            _pipeline = pipeline;
        }

        internal HttpMessage CreateCreateRequest(string fileAttributes, string fileCreationTime, string fileLastWriteTime, int? timeout, IDictionary<string, string> metadata, string filePermission, string filePermissionKey)
        {
            var message = _pipeline.CreateMessage();
            var request = message.Request;
            request.Method = RequestMethod.Put;
            var uri = new RawRequestUriBuilder();
            uri.AppendRaw(url, false);
            uri.AppendQuery("restype", "directory", true);
            if (timeout != null)
            {
                uri.AppendQuery("timeout", timeout.Value, true);
            }
            request.Uri = uri;
            if (metadata != null)
            {
                request.Headers.Add("x-ms-meta-", metadata);
            }
            request.Headers.Add("x-ms-version", version);
            if (filePermission != null)
            {
                request.Headers.Add("x-ms-file-permission", filePermission);
            }
            if (filePermissionKey != null)
            {
                request.Headers.Add("x-ms-file-permission-key", filePermissionKey);
            }
            request.Headers.Add("x-ms-file-attributes", fileAttributes);
            request.Headers.Add("x-ms-file-creation-time", fileCreationTime);
            request.Headers.Add("x-ms-file-last-write-time", fileLastWriteTime);
            request.Headers.Add("Accept", "application/xml");
            return message;
        }

        ///  Creates a new directory under the specified share or parent directory.
        /// <param name="fileAttributes"> If specified, the provided file attributes shall be set. Default value: 'Archive' for file and 'Directory' for directory. 'None' can also be specified as default. </param>
        /// <param name="fileCreationTime"> Creation time for the file/directory. Default value: Now. </param>
        /// <param name="fileLastWriteTime"> Last write time for the file/directory. Default value: Now. </param>
        /// <param name="timeout"> The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations.. </param>
        /// <param name="metadata"> A name-value pair to associate with a file storage object. </param>
        /// <param name="filePermission"> If specified the permission (security descriptor) shall be set for the directory/file. This header can be used if Permission size is <= 8KB, else x-ms-file-permission-key header shall be used. Default value: Inherit. If SDDL is specified as input, it must have owner, group and dacl. Note: Only one of the x-ms-file-permission or x-ms-file-permission-key should be specified. </param>
        /// <param name="filePermissionKey"> Key of the permission to be set for the directory/file. Note: Only one of the x-ms-file-permission or x-ms-file-permission-key should be specified. </param>
        /// <param name="cancellationToken"> The cancellation token to use. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="fileAttributes"/>, <paramref name="fileCreationTime"/>, or <paramref name="fileLastWriteTime"/> is null. </exception>
        public async Task<ResponseWithHeaders<DirectoryCreateHeaders>> CreateAsync(string fileAttributes, string fileCreationTime, string fileLastWriteTime, int? timeout = null, IDictionary<string, string> metadata = null, string filePermission = null, string filePermissionKey = null, CancellationToken cancellationToken = default)
        {
            if (fileAttributes == null)
            {
                throw new ArgumentNullException(nameof(fileAttributes));
            }
            if (fileCreationTime == null)
            {
                throw new ArgumentNullException(nameof(fileCreationTime));
            }
            if (fileLastWriteTime == null)
            {
                throw new ArgumentNullException(nameof(fileLastWriteTime));
            }

            using var message = CreateCreateRequest(fileAttributes, fileCreationTime, fileLastWriteTime, timeout, metadata, filePermission, filePermissionKey);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
            var headers = new DirectoryCreateHeaders(message.Response);
            switch (message.Response.Status)
            {
                case 201:
                    return ResponseWithHeaders.FromValue(headers, message.Response);
                default:
                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
            }
        }

        ///  Creates a new directory under the specified share or parent directory.
        /// <param name="fileAttributes"> If specified, the provided file attributes shall be set. Default value: 'Archive' for file and 'Directory' for directory. 'None' can also be specified as default. </param>
        /// <param name="fileCreationTime"> Creation time for the file/directory. Default value: Now. </param>
        /// <param name="fileLastWriteTime"> Last write time for the file/directory. Default value: Now. </param>
        /// <param name="timeout"> The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations.. </param>
        /// <param name="metadata"> A name-value pair to associate with a file storage object. </param>
        /// <param name="filePermission"> If specified the permission (security descriptor) shall be set for the directory/file. This header can be used if Permission size is <= 8KB, else x-ms-file-permission-key header shall be used. Default value: Inherit. If SDDL is specified as input, it must have owner, group and dacl. Note: Only one of the x-ms-file-permission or x-ms-file-permission-key should be specified. </param>
        /// <param name="filePermissionKey"> Key of the permission to be set for the directory/file. Note: Only one of the x-ms-file-permission or x-ms-file-permission-key should be specified. </param>
        /// <param name="cancellationToken"> The cancellation token to use. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="fileAttributes"/>, <paramref name="fileCreationTime"/>, or <paramref name="fileLastWriteTime"/> is null. </exception>
        public ResponseWithHeaders<DirectoryCreateHeaders> Create(string fileAttributes, string fileCreationTime, string fileLastWriteTime, int? timeout = null, IDictionary<string, string> metadata = null, string filePermission = null, string filePermissionKey = null, CancellationToken cancellationToken = default)
        {
            if (fileAttributes == null)
            {
                throw new ArgumentNullException(nameof(fileAttributes));
            }
            if (fileCreationTime == null)
            {
                throw new ArgumentNullException(nameof(fileCreationTime));
            }
            if (fileLastWriteTime == null)
            {
                throw new ArgumentNullException(nameof(fileLastWriteTime));
            }

            using var message = CreateCreateRequest(fileAttributes, fileCreationTime, fileLastWriteTime, timeout, metadata, filePermission, filePermissionKey);
            _pipeline.Send(message, cancellationToken);
            var headers = new DirectoryCreateHeaders(message.Response);
            switch (message.Response.Status)
            {
                case 201:
                    return ResponseWithHeaders.FromValue(headers, message.Response);
                default:
                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
            }
        }

        internal HttpMessage CreateGetPropertiesRequest(string sharesnapshot, int? timeout)
        {
            var message = _pipeline.CreateMessage();
            var request = message.Request;
            request.Method = RequestMethod.Get;
            var uri = new RawRequestUriBuilder();
            uri.AppendRaw(url, false);
            uri.AppendQuery("restype", "directory", true);
            if (sharesnapshot != null)
            {
                uri.AppendQuery("sharesnapshot", sharesnapshot, true);
            }
            if (timeout != null)
            {
                uri.AppendQuery("timeout", timeout.Value, true);
            }
            request.Uri = uri;
            request.Headers.Add("x-ms-version", version);
            request.Headers.Add("Accept", "application/xml");
            return message;
        }

        ///  Returns all system properties for the specified directory, and can also be used to check the existence of a directory. The data returned does not include the files in the directory or any subdirectories.
        /// <param name="sharesnapshot"> The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. </param>
        /// <param name="timeout"> The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations.. </param>
        /// <param name="cancellationToken"> The cancellation token to use. </param>
        public async Task<ResponseWithHeaders<DirectoryGetPropertiesHeaders>> GetPropertiesAsync(string sharesnapshot = null, int? timeout = null, CancellationToken cancellationToken = default)
        {
            using var message = CreateGetPropertiesRequest(sharesnapshot, timeout);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
            var headers = new DirectoryGetPropertiesHeaders(message.Response);
            switch (message.Response.Status)
            {
                case 200:
                    return ResponseWithHeaders.FromValue(headers, message.Response);
                default:
                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
            }
        }

        ///  Returns all system properties for the specified directory, and can also be used to check the existence of a directory. The data returned does not include the files in the directory or any subdirectories.
        /// <param name="sharesnapshot"> The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. </param>
        /// <param name="timeout"> The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations.. </param>
        /// <param name="cancellationToken"> The cancellation token to use. </param>
        public ResponseWithHeaders<DirectoryGetPropertiesHeaders> GetProperties(string sharesnapshot = null, int? timeout = null, CancellationToken cancellationToken = default)
        {
            using var message = CreateGetPropertiesRequest(sharesnapshot, timeout);
            _pipeline.Send(message, cancellationToken);
            var headers = new DirectoryGetPropertiesHeaders(message.Response);
            switch (message.Response.Status)
            {
                case 200:
                    return ResponseWithHeaders.FromValue(headers, message.Response);
                default:
                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
            }
        }

        internal HttpMessage CreateDeleteRequest(int? timeout)
        {
            var message = _pipeline.CreateMessage();
            var request = message.Request;
            request.Method = RequestMethod.Delete;
            var uri = new RawRequestUriBuilder();
            uri.AppendRaw(url, false);
            uri.AppendQuery("restype", "directory", true);
            if (timeout != null)
            {
                uri.AppendQuery("timeout", timeout.Value, true);
            }
            request.Uri = uri;
            request.Headers.Add("x-ms-version", version);
            request.Headers.Add("Accept", "application/xml");
            return message;
        }

        ///  Removes the specified empty directory. Note that the directory must be empty before it can be deleted.
        /// <param name="timeout"> The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations.. </param>
        /// <param name="cancellationToken"> The cancellation token to use. </param>
        public async Task<ResponseWithHeaders<DirectoryDeleteHeaders>> DeleteAsync(int? timeout = null, CancellationToken cancellationToken = default)
        {
            using var message = CreateDeleteRequest(timeout);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
            var headers = new DirectoryDeleteHeaders(message.Response);
            switch (message.Response.Status)
            {
                case 202:
                    return ResponseWithHeaders.FromValue(headers, message.Response);
                default:
                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
            }
        }

        ///  Removes the specified empty directory. Note that the directory must be empty before it can be deleted.
        /// <param name="timeout"> The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations.. </param>
        /// <param name="cancellationToken"> The cancellation token to use. </param>
        public ResponseWithHeaders<DirectoryDeleteHeaders> Delete(int? timeout = null, CancellationToken cancellationToken = default)
        {
            using var message = CreateDeleteRequest(timeout);
            _pipeline.Send(message, cancellationToken);
            var headers = new DirectoryDeleteHeaders(message.Response);
            switch (message.Response.Status)
            {
                case 202:
                    return ResponseWithHeaders.FromValue(headers, message.Response);
                default:
                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
            }
        }

        internal HttpMessage CreateSetPropertiesRequest(string fileAttributes, string fileCreationTime, string fileLastWriteTime, int? timeout, string filePermission, string filePermissionKey)
        {
            var message = _pipeline.CreateMessage();
            var request = message.Request;
            request.Method = RequestMethod.Put;
            var uri = new RawRequestUriBuilder();
            uri.AppendRaw(url, false);
            uri.AppendQuery("restype", "directory", true);
            uri.AppendQuery("comp", "properties", true);
            if (timeout != null)
            {
                uri.AppendQuery("timeout", timeout.Value, true);
            }
            request.Uri = uri;
            request.Headers.Add("x-ms-version", version);
            if (filePermission != null)
            {
                request.Headers.Add("x-ms-file-permission", filePermission);
            }
            if (filePermissionKey != null)
            {
                request.Headers.Add("x-ms-file-permission-key", filePermissionKey);
            }
            request.Headers.Add("x-ms-file-attributes", fileAttributes);
            request.Headers.Add("x-ms-file-creation-time", fileCreationTime);
            request.Headers.Add("x-ms-file-last-write-time", fileLastWriteTime);
            request.Headers.Add("Accept", "application/xml");
            return message;
        }

        ///  Sets properties on the directory.
        /// <param name="fileAttributes"> If specified, the provided file attributes shall be set. Default value: 'Archive' for file and 'Directory' for directory. 'None' can also be specified as default. </param>
        /// <param name="fileCreationTime"> Creation time for the file/directory. Default value: Now. </param>
        /// <param name="fileLastWriteTime"> Last write time for the file/directory. Default value: Now. </param>
        /// <param name="timeout"> The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations.. </param>
        /// <param name="filePermission"> If specified the permission (security descriptor) shall be set for the directory/file. This header can be used if Permission size is <= 8KB, else x-ms-file-permission-key header shall be used. Default value: Inherit. If SDDL is specified as input, it must have owner, group and dacl. Note: Only one of the x-ms-file-permission or x-ms-file-permission-key should be specified. </param>
        /// <param name="filePermissionKey"> Key of the permission to be set for the directory/file. Note: Only one of the x-ms-file-permission or x-ms-file-permission-key should be specified. </param>
        /// <param name="cancellationToken"> The cancellation token to use. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="fileAttributes"/>, <paramref name="fileCreationTime"/>, or <paramref name="fileLastWriteTime"/> is null. </exception>
        public async Task<ResponseWithHeaders<DirectorySetPropertiesHeaders>> SetPropertiesAsync(string fileAttributes, string fileCreationTime, string fileLastWriteTime, int? timeout = null, string filePermission = null, string filePermissionKey = null, CancellationToken cancellationToken = default)
        {
            if (fileAttributes == null)
            {
                throw new ArgumentNullException(nameof(fileAttributes));
            }
            if (fileCreationTime == null)
            {
                throw new ArgumentNullException(nameof(fileCreationTime));
            }
            if (fileLastWriteTime == null)
            {
                throw new ArgumentNullException(nameof(fileLastWriteTime));
            }

            using var message = CreateSetPropertiesRequest(fileAttributes, fileCreationTime, fileLastWriteTime, timeout, filePermission, filePermissionKey);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
            var headers = new DirectorySetPropertiesHeaders(message.Response);
            switch (message.Response.Status)
            {
                case 200:
                    return ResponseWithHeaders.FromValue(headers, message.Response);
                default:
                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
            }
        }

        ///  Sets properties on the directory.
        /// <param name="fileAttributes"> If specified, the provided file attributes shall be set. Default value: 'Archive' for file and 'Directory' for directory. 'None' can also be specified as default. </param>
        /// <param name="fileCreationTime"> Creation time for the file/directory. Default value: Now. </param>
        /// <param name="fileLastWriteTime"> Last write time for the file/directory. Default value: Now. </param>
        /// <param name="timeout"> The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations.. </param>
        /// <param name="filePermission"> If specified the permission (security descriptor) shall be set for the directory/file. This header can be used if Permission size is <= 8KB, else x-ms-file-permission-key header shall be used. Default value: Inherit. If SDDL is specified as input, it must have owner, group and dacl. Note: Only one of the x-ms-file-permission or x-ms-file-permission-key should be specified. </param>
        /// <param name="filePermissionKey"> Key of the permission to be set for the directory/file. Note: Only one of the x-ms-file-permission or x-ms-file-permission-key should be specified. </param>
        /// <param name="cancellationToken"> The cancellation token to use. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="fileAttributes"/>, <paramref name="fileCreationTime"/>, or <paramref name="fileLastWriteTime"/> is null. </exception>
        public ResponseWithHeaders<DirectorySetPropertiesHeaders> SetProperties(string fileAttributes, string fileCreationTime, string fileLastWriteTime, int? timeout = null, string filePermission = null, string filePermissionKey = null, CancellationToken cancellationToken = default)
        {
            if (fileAttributes == null)
            {
                throw new ArgumentNullException(nameof(fileAttributes));
            }
            if (fileCreationTime == null)
            {
                throw new ArgumentNullException(nameof(fileCreationTime));
            }
            if (fileLastWriteTime == null)
            {
                throw new ArgumentNullException(nameof(fileLastWriteTime));
            }

            using var message = CreateSetPropertiesRequest(fileAttributes, fileCreationTime, fileLastWriteTime, timeout, filePermission, filePermissionKey);
            _pipeline.Send(message, cancellationToken);
            var headers = new DirectorySetPropertiesHeaders(message.Response);
            switch (message.Response.Status)
            {
                case 200:
                    return ResponseWithHeaders.FromValue(headers, message.Response);
                default:
                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
            }
        }

        internal HttpMessage CreateSetMetadataRequest(int? timeout, IDictionary<string, string> metadata)
        {
            var message = _pipeline.CreateMessage();
            var request = message.Request;
            request.Method = RequestMethod.Put;
            var uri = new RawRequestUriBuilder();
            uri.AppendRaw(url, false);
            uri.AppendQuery("restype", "directory", true);
            uri.AppendQuery("comp", "metadata", true);
            if (timeout != null)
            {
                uri.AppendQuery("timeout", timeout.Value, true);
            }
            request.Uri = uri;
            if (metadata != null)
            {
                request.Headers.Add("x-ms-meta-", metadata);
            }
            request.Headers.Add("x-ms-version", version);
            request.Headers.Add("Accept", "application/xml");
            return message;
        }

        ///  Updates user defined metadata for the specified directory.
        /// <param name="timeout"> The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations.. </param>
        /// <param name="metadata"> A name-value pair to associate with a file storage object. </param>
        /// <param name="cancellationToken"> The cancellation token to use. </param>
        public async Task<ResponseWithHeaders<DirectorySetMetadataHeaders>> SetMetadataAsync(int? timeout = null, IDictionary<string, string> metadata = null, CancellationToken cancellationToken = default)
        {
            using var message = CreateSetMetadataRequest(timeout, metadata);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
            var headers = new DirectorySetMetadataHeaders(message.Response);
            switch (message.Response.Status)
            {
                case 200:
                    return ResponseWithHeaders.FromValue(headers, message.Response);
                default:
                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
            }
        }

        ///  Updates user defined metadata for the specified directory.
        /// <param name="timeout"> The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations.. </param>
        /// <param name="metadata"> A name-value pair to associate with a file storage object. </param>
        /// <param name="cancellationToken"> The cancellation token to use. </param>
        public ResponseWithHeaders<DirectorySetMetadataHeaders> SetMetadata(int? timeout = null, IDictionary<string, string> metadata = null, CancellationToken cancellationToken = default)
        {
            using var message = CreateSetMetadataRequest(timeout, metadata);
            _pipeline.Send(message, cancellationToken);
            var headers = new DirectorySetMetadataHeaders(message.Response);
            switch (message.Response.Status)
            {
                case 200:
                    return ResponseWithHeaders.FromValue(headers, message.Response);
                default:
                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
            }
        }

        internal HttpMessage CreateListFilesAndDirectoriesSegmentRequest(string prefix, string sharesnapshot, string marker, int? maxresults, int? timeout, IEnumerable<ListFilesIncludeType> include, bool? includeExtendedInfo)
        {
            var message = _pipeline.CreateMessage();
            var request = message.Request;
            request.Method = RequestMethod.Get;
            var uri = new RawRequestUriBuilder();
            uri.AppendRaw(url, false);
            uri.AppendQuery("restype", "directory", true);
            uri.AppendQuery("comp", "list", true);
            if (prefix != null)
            {
                uri.AppendQuery("prefix", prefix, true);
            }
            if (sharesnapshot != null)
            {
                uri.AppendQuery("sharesnapshot", sharesnapshot, true);
            }
            if (marker != null)
            {
                uri.AppendQuery("marker", marker, true);
            }
            if (maxresults != null)
            {
                uri.AppendQuery("maxresults", maxresults.Value, true);
            }
            if (timeout != null)
            {
                uri.AppendQuery("timeout", timeout.Value, true);
            }
            if (include != null)
            {
                uri.AppendQueryDelimited("include", include, ",", true);
            }
            request.Uri = uri;
            request.Headers.Add("x-ms-version", version);
            if (includeExtendedInfo != null)
            {
                request.Headers.Add("x-ms-file-extended-info", includeExtendedInfo.Value);
            }
            request.Headers.Add("Accept", "application/xml");
            return message;
        }

        ///  Returns a list of files or directories under the specified share or directory. It lists the contents only for a single level of the directory hierarchy.
        /// <param name="prefix"> Filters the results to return only entries whose name begins with the specified prefix. </param>
        /// <param name="sharesnapshot"> The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. </param>
        /// <param name="marker"> A string value that identifies the portion of the list to be returned with the next list operation. The operation returns a marker value within the response body if the list returned was not complete. The marker value may then be used in a subsequent call to request the next set of list items. The marker value is opaque to the client. </param>
        /// <param name="maxresults"> Specifies the maximum number of entries to return. If the request does not specify maxresults, or specifies a value greater than 5,000, the server will return up to 5,000 items. </param>
        /// <param name="timeout"> The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations.. </param>
        /// <param name="include"> Include this parameter to specify one or more datasets to include in the response. </param>
        /// <param name="includeExtendedInfo"> Include extended information. </param>
        /// <param name="cancellationToken"> The cancellation token to use. </param>
        public async Task<ResponseWithHeaders<ListFilesAndDirectoriesSegmentResponse, DirectoryListFilesAndDirectoriesSegmentHeaders>> ListFilesAndDirectoriesSegmentAsync(string prefix = null, string sharesnapshot = null, string marker = null, int? maxresults = null, int? timeout = null, IEnumerable<ListFilesIncludeType> include = null, bool? includeExtendedInfo = null, CancellationToken cancellationToken = default)
        {
            using var message = CreateListFilesAndDirectoriesSegmentRequest(prefix, sharesnapshot, marker, maxresults, timeout, include, includeExtendedInfo);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
            var headers = new DirectoryListFilesAndDirectoriesSegmentHeaders(message.Response);
            switch (message.Response.Status)
            {
                case 200:
                    {
                        ListFilesAndDirectoriesSegmentResponse value = default;
                        var document = XDocument.Load(message.Response.ContentStream, LoadOptions.PreserveWhitespace);
                        if (document.Element("EnumerationResults") is XElement enumerationResultsElement)
                        {
                            value = ListFilesAndDirectoriesSegmentResponse.DeserializeListFilesAndDirectoriesSegmentResponse(enumerationResultsElement);
                        }
                        return ResponseWithHeaders.FromValue(value, headers, message.Response);
                    }
                default:
                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
            }
        }

        ///  Returns a list of files or directories under the specified share or directory. It lists the contents only for a single level of the directory hierarchy.
        /// <param name="prefix"> Filters the results to return only entries whose name begins with the specified prefix. </param>
        /// <param name="sharesnapshot"> The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. </param>
        /// <param name="marker"> A string value that identifies the portion of the list to be returned with the next list operation. The operation returns a marker value within the response body if the list returned was not complete. The marker value may then be used in a subsequent call to request the next set of list items. The marker value is opaque to the client. </param>
        /// <param name="maxresults"> Specifies the maximum number of entries to return. If the request does not specify maxresults, or specifies a value greater than 5,000, the server will return up to 5,000 items. </param>
        /// <param name="timeout"> The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations.. </param>
        /// <param name="include"> Include this parameter to specify one or more datasets to include in the response. </param>
        /// <param name="includeExtendedInfo"> Include extended information. </param>
        /// <param name="cancellationToken"> The cancellation token to use. </param>
        public ResponseWithHeaders<ListFilesAndDirectoriesSegmentResponse, DirectoryListFilesAndDirectoriesSegmentHeaders> ListFilesAndDirectoriesSegment(string prefix = null, string sharesnapshot = null, string marker = null, int? maxresults = null, int? timeout = null, IEnumerable<ListFilesIncludeType> include = null, bool? includeExtendedInfo = null, CancellationToken cancellationToken = default)
        {
            using var message = CreateListFilesAndDirectoriesSegmentRequest(prefix, sharesnapshot, marker, maxresults, timeout, include, includeExtendedInfo);
            _pipeline.Send(message, cancellationToken);
            var headers = new DirectoryListFilesAndDirectoriesSegmentHeaders(message.Response);
            switch (message.Response.Status)
            {
                case 200:
                    {
                        ListFilesAndDirectoriesSegmentResponse value = default;
                        var document = XDocument.Load(message.Response.ContentStream, LoadOptions.PreserveWhitespace);
                        if (document.Element("EnumerationResults") is XElement enumerationResultsElement)
                        {
                            value = ListFilesAndDirectoriesSegmentResponse.DeserializeListFilesAndDirectoriesSegmentResponse(enumerationResultsElement);
                        }
                        return ResponseWithHeaders.FromValue(value, headers, message.Response);
                    }
                default:
                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
            }
        }

        internal HttpMessage CreateListHandlesRequest(string marker, int? maxresults, int? timeout, string sharesnapshot, bool? recursive)
        {
            var message = _pipeline.CreateMessage();
            var request = message.Request;
            request.Method = RequestMethod.Get;
            var uri = new RawRequestUriBuilder();
            uri.AppendRaw(url, false);
            uri.AppendQuery("comp", "listhandles", true);
            if (marker != null)
            {
                uri.AppendQuery("marker", marker, true);
            }
            if (maxresults != null)
            {
                uri.AppendQuery("maxresults", maxresults.Value, true);
            }
            if (timeout != null)
            {
                uri.AppendQuery("timeout", timeout.Value, true);
            }
            if (sharesnapshot != null)
            {
                uri.AppendQuery("sharesnapshot", sharesnapshot, true);
            }
            request.Uri = uri;
            if (recursive != null)
            {
                request.Headers.Add("x-ms-recursive", recursive.Value);
            }
            request.Headers.Add("x-ms-version", version);
            request.Headers.Add("Accept", "application/xml");
            return message;
        }

        ///  Lists handles for directory.
        /// <param name="marker"> A string value that identifies the portion of the list to be returned with the next list operation. The operation returns a marker value within the response body if the list returned was not complete. The marker value may then be used in a subsequent call to request the next set of list items. The marker value is opaque to the client. </param>
        /// <param name="maxresults"> Specifies the maximum number of entries to return. If the request does not specify maxresults, or specifies a value greater than 5,000, the server will return up to 5,000 items. </param>
        /// <param name="timeout"> The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations.. </param>
        /// <param name="sharesnapshot"> The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. </param>
        /// <param name="recursive"> Specifies operation should apply to the directory specified in the URI, its files, its subdirectories and their files. </param>
        /// <param name="cancellationToken"> The cancellation token to use. </param>
        public async Task<ResponseWithHeaders<ListHandlesResponse, DirectoryListHandlesHeaders>> ListHandlesAsync(string marker = null, int? maxresults = null, int? timeout = null, string sharesnapshot = null, bool? recursive = null, CancellationToken cancellationToken = default)
        {
            using var message = CreateListHandlesRequest(marker, maxresults, timeout, sharesnapshot, recursive);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
            var headers = new DirectoryListHandlesHeaders(message.Response);
            switch (message.Response.Status)
            {
                case 200:
                    {
                        ListHandlesResponse value = default;
                        var document = XDocument.Load(message.Response.ContentStream, LoadOptions.PreserveWhitespace);
                        if (document.Element("EnumerationResults") is XElement enumerationResultsElement)
                        {
                            value = ListHandlesResponse.DeserializeListHandlesResponse(enumerationResultsElement);
                        }
                        return ResponseWithHeaders.FromValue(value, headers, message.Response);
                    }
                default:
                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
            }
        }

        ///  Lists handles for directory.
        /// <param name="marker"> A string value that identifies the portion of the list to be returned with the next list operation. The operation returns a marker value within the response body if the list returned was not complete. The marker value may then be used in a subsequent call to request the next set of list items. The marker value is opaque to the client. </param>
        /// <param name="maxresults"> Specifies the maximum number of entries to return. If the request does not specify maxresults, or specifies a value greater than 5,000, the server will return up to 5,000 items. </param>
        /// <param name="timeout"> The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations.. </param>
        /// <param name="sharesnapshot"> The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. </param>
        /// <param name="recursive"> Specifies operation should apply to the directory specified in the URI, its files, its subdirectories and their files. </param>
        /// <param name="cancellationToken"> The cancellation token to use. </param>
        public ResponseWithHeaders<ListHandlesResponse, DirectoryListHandlesHeaders> ListHandles(string marker = null, int? maxresults = null, int? timeout = null, string sharesnapshot = null, bool? recursive = null, CancellationToken cancellationToken = default)
        {
            using var message = CreateListHandlesRequest(marker, maxresults, timeout, sharesnapshot, recursive);
            _pipeline.Send(message, cancellationToken);
            var headers = new DirectoryListHandlesHeaders(message.Response);
            switch (message.Response.Status)
            {
                case 200:
                    {
                        ListHandlesResponse value = default;
                        var document = XDocument.Load(message.Response.ContentStream, LoadOptions.PreserveWhitespace);
                        if (document.Element("EnumerationResults") is XElement enumerationResultsElement)
                        {
                            value = ListHandlesResponse.DeserializeListHandlesResponse(enumerationResultsElement);
                        }
                        return ResponseWithHeaders.FromValue(value, headers, message.Response);
                    }
                default:
                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
            }
        }

        internal HttpMessage CreateForceCloseHandlesRequest(string handleId, int? timeout, string marker, string sharesnapshot, bool? recursive)
        {
            var message = _pipeline.CreateMessage();
            var request = message.Request;
            request.Method = RequestMethod.Put;
            var uri = new RawRequestUriBuilder();
            uri.AppendRaw(url, false);
            uri.AppendQuery("comp", "forceclosehandles", true);
            if (timeout != null)
            {
                uri.AppendQuery("timeout", timeout.Value, true);
            }
            if (marker != null)
            {
                uri.AppendQuery("marker", marker, true);
            }
            if (sharesnapshot != null)
            {
                uri.AppendQuery("sharesnapshot", sharesnapshot, true);
            }
            request.Uri = uri;
            request.Headers.Add("x-ms-handle-id", handleId);
            if (recursive != null)
            {
                request.Headers.Add("x-ms-recursive", recursive.Value);
            }
            request.Headers.Add("x-ms-version", version);
            request.Headers.Add("Accept", "application/xml");
            return message;
        }

        ///  Closes all handles open for given directory.
        /// <param name="handleId"> Specifies handle ID opened on the file or directory to be closed. Asterisk ('*') is a wildcard that specifies all handles. </param>
        /// <param name="timeout"> The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations.. </param>
        /// <param name="marker"> A string value that identifies the portion of the list to be returned with the next list operation. The operation returns a marker value within the response body if the list returned was not complete. The marker value may then be used in a subsequent call to request the next set of list items. The marker value is opaque to the client. </param>
        /// <param name="sharesnapshot"> The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. </param>
        /// <param name="recursive"> Specifies operation should apply to the directory specified in the URI, its files, its subdirectories and their files. </param>
        /// <param name="cancellationToken"> The cancellation token to use. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="handleId"/> is null. </exception>
        public async Task<ResponseWithHeaders<DirectoryForceCloseHandlesHeaders>> ForceCloseHandlesAsync(string handleId, int? timeout = null, string marker = null, string sharesnapshot = null, bool? recursive = null, CancellationToken cancellationToken = default)
        {
            if (handleId == null)
            {
                throw new ArgumentNullException(nameof(handleId));
            }

            using var message = CreateForceCloseHandlesRequest(handleId, timeout, marker, sharesnapshot, recursive);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
            var headers = new DirectoryForceCloseHandlesHeaders(message.Response);
            switch (message.Response.Status)
            {
                case 200:
                    return ResponseWithHeaders.FromValue(headers, message.Response);
                default:
                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
            }
        }

        ///  Closes all handles open for given directory.
        /// <param name="handleId"> Specifies handle ID opened on the file or directory to be closed. Asterisk ('*') is a wildcard that specifies all handles. </param>
        /// <param name="timeout"> The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations.. </param>
        /// <param name="marker"> A string value that identifies the portion of the list to be returned with the next list operation. The operation returns a marker value within the response body if the list returned was not complete. The marker value may then be used in a subsequent call to request the next set of list items. The marker value is opaque to the client. </param>
        /// <param name="sharesnapshot"> The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. </param>
        /// <param name="recursive"> Specifies operation should apply to the directory specified in the URI, its files, its subdirectories and their files. </param>
        /// <param name="cancellationToken"> The cancellation token to use. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="handleId"/> is null. </exception>
        public ResponseWithHeaders<DirectoryForceCloseHandlesHeaders> ForceCloseHandles(string handleId, int? timeout = null, string marker = null, string sharesnapshot = null, bool? recursive = null, CancellationToken cancellationToken = default)
        {
            if (handleId == null)
            {
                throw new ArgumentNullException(nameof(handleId));
            }

            using var message = CreateForceCloseHandlesRequest(handleId, timeout, marker, sharesnapshot, recursive);
            _pipeline.Send(message, cancellationToken);
            var headers = new DirectoryForceCloseHandlesHeaders(message.Response);
            switch (message.Response.Status)
            {
                case 200:
                    return ResponseWithHeaders.FromValue(headers, message.Response);
                default:
                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
            }
        }

        internal HttpMessage CreateListFilesAndDirectoriesSegmentNextPageRequest(string nextLink, string prefix, string sharesnapshot, string marker, int? maxresults, int? timeout, IEnumerable<ListFilesIncludeType> include, bool? includeExtendedInfo)
        {
            var message = _pipeline.CreateMessage();
            var request = message.Request;
            request.Method = RequestMethod.Get;
            var uri = new RawRequestUriBuilder();
            uri.AppendRaw(url, false);
            uri.AppendRawNextLink(nextLink, false);
            request.Uri = uri;
            request.Headers.Add("x-ms-version", version);
            if (includeExtendedInfo != null)
            {
                request.Headers.Add("x-ms-file-extended-info", includeExtendedInfo.Value);
            }
            request.Headers.Add("Accept", "application/xml");
            return message;
        }

        ///  Returns a list of files or directories under the specified share or directory. It lists the contents only for a single level of the directory hierarchy.
        /// <param name="nextLink"> The URL to the next page of results. </param>
        /// <param name="prefix"> Filters the results to return only entries whose name begins with the specified prefix. </param>
        /// <param name="sharesnapshot"> The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. </param>
        /// <param name="marker"> A string value that identifies the portion of the list to be returned with the next list operation. The operation returns a marker value within the response body if the list returned was not complete. The marker value may then be used in a subsequent call to request the next set of list items. The marker value is opaque to the client. </param>
        /// <param name="maxresults"> Specifies the maximum number of entries to return. If the request does not specify maxresults, or specifies a value greater than 5,000, the server will return up to 5,000 items. </param>
        /// <param name="timeout"> The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations.. </param>
        /// <param name="include"> Include this parameter to specify one or more datasets to include in the response. </param>
        /// <param name="includeExtendedInfo"> Include extended information. </param>
        /// <param name="cancellationToken"> The cancellation token to use. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="nextLink"/> is null. </exception>
        public async Task<ResponseWithHeaders<ListFilesAndDirectoriesSegmentResponse, DirectoryListFilesAndDirectoriesSegmentHeaders>> ListFilesAndDirectoriesSegmentNextPageAsync(string nextLink, string prefix = null, string sharesnapshot = null, string marker = null, int? maxresults = null, int? timeout = null, IEnumerable<ListFilesIncludeType> include = null, bool? includeExtendedInfo = null, CancellationToken cancellationToken = default)
        {
            if (nextLink == null)
            {
                throw new ArgumentNullException(nameof(nextLink));
            }

            using var message = CreateListFilesAndDirectoriesSegmentNextPageRequest(nextLink, prefix, sharesnapshot, marker, maxresults, timeout, include, includeExtendedInfo);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
            var headers = new DirectoryListFilesAndDirectoriesSegmentHeaders(message.Response);
            switch (message.Response.Status)
            {
                case 200:
                    {
                        ListFilesAndDirectoriesSegmentResponse value = default;
                        var document = XDocument.Load(message.Response.ContentStream, LoadOptions.PreserveWhitespace);
                        if (document.Element("EnumerationResults") is XElement enumerationResultsElement)
                        {
                            value = ListFilesAndDirectoriesSegmentResponse.DeserializeListFilesAndDirectoriesSegmentResponse(enumerationResultsElement);
                        }
                        return ResponseWithHeaders.FromValue(value, headers, message.Response);
                    }
                default:
                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
            }
        }

        ///  Returns a list of files or directories under the specified share or directory. It lists the contents only for a single level of the directory hierarchy.
        /// <param name="nextLink"> The URL to the next page of results. </param>
        /// <param name="prefix"> Filters the results to return only entries whose name begins with the specified prefix. </param>
        /// <param name="sharesnapshot"> The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. </param>
        /// <param name="marker"> A string value that identifies the portion of the list to be returned with the next list operation. The operation returns a marker value within the response body if the list returned was not complete. The marker value may then be used in a subsequent call to request the next set of list items. The marker value is opaque to the client. </param>
        /// <param name="maxresults"> Specifies the maximum number of entries to return. If the request does not specify maxresults, or specifies a value greater than 5,000, the server will return up to 5,000 items. </param>
        /// <param name="timeout"> The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations.. </param>
        /// <param name="include"> Include this parameter to specify one or more datasets to include in the response. </param>
        /// <param name="includeExtendedInfo"> Include extended information. </param>
        /// <param name="cancellationToken"> The cancellation token to use. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="nextLink"/> is null. </exception>
        public ResponseWithHeaders<ListFilesAndDirectoriesSegmentResponse, DirectoryListFilesAndDirectoriesSegmentHeaders> ListFilesAndDirectoriesSegmentNextPage(string nextLink, string prefix = null, string sharesnapshot = null, string marker = null, int? maxresults = null, int? timeout = null, IEnumerable<ListFilesIncludeType> include = null, bool? includeExtendedInfo = null, CancellationToken cancellationToken = default)
        {
            if (nextLink == null)
            {
                throw new ArgumentNullException(nameof(nextLink));
            }

            using var message = CreateListFilesAndDirectoriesSegmentNextPageRequest(nextLink, prefix, sharesnapshot, marker, maxresults, timeout, include, includeExtendedInfo);
            _pipeline.Send(message, cancellationToken);
            var headers = new DirectoryListFilesAndDirectoriesSegmentHeaders(message.Response);
            switch (message.Response.Status)
            {
                case 200:
                    {
                        ListFilesAndDirectoriesSegmentResponse value = default;
                        var document = XDocument.Load(message.Response.ContentStream, LoadOptions.PreserveWhitespace);
                        if (document.Element("EnumerationResults") is XElement enumerationResultsElement)
                        {
                            value = ListFilesAndDirectoriesSegmentResponse.DeserializeListFilesAndDirectoriesSegmentResponse(enumerationResultsElement);
                        }
                        return ResponseWithHeaders.FromValue(value, headers, message.Response);
                    }
                default:
                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
            }
        }
    }
}


text:
{-# LANGUAGE ViewPatterns #-}

module Y2017.M12.D13.Solution where

{--
A little simple thing for today's Haskell exercise.

Yesterday's date was 2017-12-12. I noticed something after I had already
published yesterday's SQL problem.

Yesterday's date has the following property

Both the month and the day are composed of digits from the year. That is to
say that the following holds:
--}

import Data.List (unfoldr)
import qualified Data.Set as Set
import Data.Time
import Data.Time.Calendar

composableDate :: Day -> Bool
composableDate (toGregorian -> (yr, mos, day)) =
   mos `isComposedOfDigitsIn` yr && day `isComposedOfDigitsIn` yr

isComposedOfDigitsIn :: Int -> Integer -> Bool
isComposedOfDigitsIn (show -> x) (Set.fromList . show -> yr) =
   all (`Set.member` yr) x

{--
>>> composableDate (read "2017-12-12")
True
>>> composableDate (read "2017-12-13")
False
--}

-- Great!

-- Now: what are all the dates in 2017 that have the composeableDate property?

allComposeableDatesIn :: Integer -> [Day]
allComposeableDatesIn yr =
   filter composableDate .  validDatesIn yr $ fromGregorian yr 1 1

{--
>>> take 5 $ allComposeableDatesIn 2107
[2017-01-01,2107-01-02,2107-01-07,2107-01-10,2107-01-11]
>>> length (allComposeableDatesIn 2017)
66
--}

validDatesIn :: Integer -> Day -> [Day]
-- validDatesIn yr day = day:unfoldr (nextDay yr) day
validDatesIn yr = (:) <*> unfoldr (nextDay yr)

nextDay :: Integer -> Day -> Maybe (Day, Day)
nextDay yr today =
   let tomorrow = addDays 1 today
       (yr1, _, _) = toGregorian tomorrow in
   if yr1 > yr then Nothing else Just (tomorrow, tomorrow)
-- I'm sure there's some kind of Mayan spin to all this, but you tell me.

redpajama_set_name: RedPajamaGithub


text:
/*
 *  This file was autogenerated by the GPUdb schema processor.
 *
 *  DO NOT EDIT DIRECTLY.
 */
package com.gpudb.protocol;

import com.gpudb.Record;
import com.gpudb.Type;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.apache.avro.generic.GenericData;

/**
 * A set of results returned by {@link
 * com.gpudb.GPUdb#getRecordsByColumn(GetRecordsByColumnRequest)}.
 */
public class GetRecordsByColumnResponse {
    private String tableName;
    private List<Record> data;
    private long totalNumberOfRecords;
    private boolean hasMoreRecords;
    private Map<String, String> info;
    private Type dataType;

    /**
     * Constructs a GetRecordsByColumnResponse object with default parameters.
     */
    public GetRecordsByColumnResponse() {
    }

    /**
     *
     * @return The same table name as was passed in the parameter list.
     *
     */
    public String getTableName() {
        return tableName;
    }

    /**
     *
     * @param tableName  The same table name as was passed in the parameter
     *                   list.
     *
     * @return {@code this} to mimic the builder pattern.
     *
     */
    public GetRecordsByColumnResponse setTableName(String tableName) {
        this.tableName = (tableName == null) ? "" : tableName;
        return this;
    }

    /**
     *
     * @return Avro binary encoded response.
     *
     */
    public List<Record> getData() {
        return data;
    }

    /**
     *
     * @param data  Avro binary encoded response.
     *
     * @return {@code this} to mimic the builder pattern.
     *
     */
    public GetRecordsByColumnResponse setData(List<Record> data) {
        this.data = (data == null) ? new ArrayList<Record>() : data;
        return this;
    }

    /**
     *
     * @return Total/Filtered number of records.
     *
     */
    public long getTotalNumberOfRecords() {
        return totalNumberOfRecords;
    }

    /**
     *
     * @param totalNumberOfRecords  Total/Filtered number of records.
     *
     * @return {@code this} to mimic the builder pattern.
     *
     */
    public GetRecordsByColumnResponse setTotalNumberOfRecords(long totalNumberOfRecords) {
        this.totalNumberOfRecords = totalNumberOfRecords;
        return this;
    }

    /**
     *
     * @return Too many records. Returned a partial set.
     *
     */
    public boolean getHasMoreRecords() {
        return hasMoreRecords;
    }

    /**
     *
     * @param hasMoreRecords  Too many records. Returned a partial set.
     *
     * @return {@code this} to mimic the builder pattern.
     *
     */
    public GetRecordsByColumnResponse setHasMoreRecords(boolean hasMoreRecords) {
        this.hasMoreRecords = hasMoreRecords;
        return this;
    }

    /**
     *
     * @return Additional information.
     *
     */
    public Map<String, String> getInfo() {
        return info;
    }

    /**
     *
     * @param info  Additional information.
     *
     * @return {@code this} to mimic the builder pattern.
     *
     */
    public GetRecordsByColumnResponse setInfo(Map<String, String> info) {
        this.info = (info == null) ? new LinkedHashMap<String, String>() : info;
        return this;
    }

    /**
     *
     * @return The {@link Type} object containing the type of the dynamically
     *         generated data.
     *
     */
    public Type getDataType() {
        return dataType;
    }

    /**
     *
     * @param dataType  The {@link Type} object containing the type of the
     *                  dynamically generated data.
     *
     * @return {@code this} to mimic the builder pattern.
     *
     */
    public GetRecordsByColumnResponse setDataType(Type dataType) {
        this.dataType = dataType;
        return this;
    }
    @Override
    public boolean equals(Object obj) {
        if( obj == this ) {
            return true;
        }

        if( (obj == null) || (obj.getClass() != this.getClass()) ) {
            return false;
        }

        GetRecordsByColumnResponse that = (GetRecordsByColumnResponse)obj;

        return ( this.tableName.equals( that.tableName )
                 && this.data.equals( that.data )
                 && ( this.totalNumberOfRecords == that.totalNumberOfRecords )
                 && ( this.hasMoreRecords == that.hasMoreRecords )
                 && this.info.equals( that.info )
                 && this.dataType.equals( that.dataType ) );
    }

    @Override
    public String toString() {
        GenericData gd = GenericData.get();
        StringBuilder builder = new StringBuilder();
        builder.append( "{" );
        builder.append( gd.toString( "tableName" ) );
        builder.append( ": " );
        builder.append( gd.toString( this.tableName ) );
        builder.append( ", " );
        builder.append( gd.toString( "data" ) );
        builder.append( ": " );
        builder.append( gd.toString( this.data ) );
        builder.append( ", " );
        builder.append( gd.toString( "totalNumberOfRecords" ) );
        builder.append( ": " );
        builder.append( gd.toString( this.totalNumberOfRecords ) );
        builder.append( ", " );
        builder.append( gd.toString( "hasMoreRecords" ) );
        builder.append( ": " );
        builder.append( gd.toString( this.hasMoreRecords ) );
        builder.append( ", " );
        builder.append( gd.toString( "info" ) );
        builder.append( ": " );
        builder.append( gd.toString( this.info ) );
        builder.append( ", " );
        builder.append( gd.toString( "dataType" ) );
        builder.append( ": " );
        builder.append( gd.toString( this.dataType ) );
        builder.append( "}" );

        return builder.toString();
    }

    @Override
    public int hashCode() {
        int hashCode = 1;
        hashCode = (31 * hashCode) + this.tableName.hashCode();
        hashCode = (31 * hashCode) + this.data.hashCode();
        hashCode = (31 * hashCode) + ((Long)this.totalNumberOfRecords).hashCode();
        hashCode = (31 * hashCode) + ((Boolean)this.hasMoreRecords).hashCode();
        hashCode = (31 * hashCode) + this.info.hashCode();
        hashCode = (31 * hashCode) + this.dataType.hashCode();
        return hashCode;
    }

}


text:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
	<persistence-unit name="fox-sysbase">
		<class>com.yy.cloud.core.sysbase.data.domain.YYSystemdictionary</class>

	</persistence-unit>
</persistence>


text:
#ifndef B2_GROWABLE_BUFFER_H
#define B2_GROWABLE_BUFFER_H

#include <Box2D/Common/b2BlockAllocator.h>
#include <string.h>
#include <memory.h>
#include <algorithm>

/// A simple array-like container, similar to std::vector.
/// If we ever start using stl, we should replace this with std::vector.
template <typename T>
class b2GrowableBuffer
{
public:
	b2GrowableBuffer(b2BlockAllocator& allocator) :
		data(NULL),
		count(0),
		capacity(0),
		allocator(&allocator)
	{
	#if defined(LIQUIDFUN_SIMD_NEON)
		// b2ParticleAssemply.neon.s assumes these values are at fixed offsets.
        // If this assert fails, be sure to update the assembly offsets!
		// ldr r3, [r9, #0] @ r3 = out = contacts.data
        // ldr r6, [r9, #8] @ r6 = contacts.capacity
		b2Assert((intptr_t)&data - (intptr_t)(this) == 0
			  && (intptr_t)&capacity - (intptr_t)(this) == 8);
	#endif // defined(LIQUIDFUN_SIMD_NEON)
	}

	b2GrowableBuffer(const b2GrowableBuffer<T>& rhs) :
		data(NULL),
		count(rhs.count),
		capacity(rhs.capacity),
		allocator(rhs.allocator)
	{
		if (rhs.data != NULL)
		{
			data = (T*) allocator->Allocate(sizeof(T) * capacity);
			memcpy(data, rhs.data, sizeof(T) * count);
		}
	}

	~b2GrowableBuffer()
	{
		Free();
	}

	T& Append()
	{
		if (count >= capacity)
		{
			Grow();
		}
		return data[count++];
	}

	void Reserve(int32 newCapacity)
	{
		if (capacity >= newCapacity)
			return;

		// Reallocate and copy.
		T* newData = (T*) allocator->Allocate(sizeof(T) * newCapacity);
		if (data)
		{
			memcpy(newData, data, sizeof(T) * count);
			allocator->Free(data, sizeof(T) * capacity);
		}

		// Update pointer and capacity.
		capacity = newCapacity;
		data = newData;
	}

	void Grow()
	{
		// Double the capacity.
		int32 newCapacity = capacity ? 2 * capacity
						  : b2_minParticleSystemBufferCapacity;
		b2Assert(newCapacity > capacity);
		Reserve(newCapacity);
	}

	void Free()
	{
		if (data == NULL)
			return;

		allocator->Free(data, sizeof(data[0]) * capacity);
		data = NULL;
		capacity = 0;
		count = 0;
	}

	void Shorten(const T* newEnd)
	{
		b2Assert(newEnd >= data);
		count = (int32) (newEnd - data);
	}

	T& operator[](int i)
	{
		return data[i];
	}

	const T& operator[](int i) const
	{
		return data[i];
	}

	T* Data()
	{
		return data;
	}

	const T* Data() const
	{
		return data;
	}

	T* Begin()
	{
		return data;
	}

	const T* Begin() const
	{
		return data;
	}

	T* End()
	{
		return &data[count];
	}

	const T* End() const
	{
		return &data[count];
	}

	int32 GetCount() const
	{
		return count;
	}

	void SetCount(int32 newCount)
	{
		b2Assert(0 <= newCount && newCount <= capacity);
		count = newCount;
	}

	int32 GetCapacity() const
	{
		return capacity;
	}

	template<class UnaryPredicate>
	T* RemoveIf(UnaryPredicate pred)
	{
		T* newEnd = std::remove_if(data, data + count, pred);
		Shorten(newEnd);
		return newEnd;
	}

	template<class BinaryPredicate>
	T* Unique(BinaryPredicate pred)
	{
		T* newEnd = std::unique(data, data + count, pred);
		Shorten(newEnd);
		return newEnd;
	}

private:
	T* data;
	int32 count;
	int32 capacity;
	b2BlockAllocator* allocator;
};

#endif // B2_GROWABLE_BUFFER_H


text:
package main

import "golang.org/x/sys/windows/registry"
import "github.com/pkg/errors"
import "fmt"
import "os/exec"
import "os"
import "encoding/xml"
import "time"
import "strings"

type DSACatalogGranulePick struct {
	XMLName        xml.Name `xml:"GranulePick"`
	PlatformType   string   `xml:"PlatformType,attr"`
	MfgCode        string   `xml:"MfgCode,attr"`
	SelectionState string   `xml:"SelectionState,attr"`
}

type DSACatalogState struct {
	XMLName          xml.Name                `xml:"StateCookieInfo"`
	UsingNetwork     bool                    `xml:"Client>NetworkInfo>IsNetworkDeployment"`
	GranulePicks     []DSACatalogGranulePick `xml:"Client>UserPicks>GranulePicks>GranulePick"`
	LastDiscLocation string
}

const (
	CAP2020_CATALOG          = `SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\20-20 COMMERCIAL CATALOGS`
	CAP2020_SOFTWARE         = `SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{5D4D912A-D5EE-4748-84B8-7C2C75EC4408}`
	CAP2020_SOFTWARE_CURRENT = `13.00.13037`
	PATH_CATALOG             = `\\10.0.9.29\2020catalogbeta\ClientSetup\setup.exe`
	PATH_SOFTWARE            = `\\10.0.9.29\2020software\Setup.exe`
)

const (
	CATALOG_STATE_MISSNG = iota
	CATALOG_STATE_LOCAL
	CATALOG_STATE_NETWORK
	CATALOG_STATE_INVALID
)

func GetCatalogStatus() (int, error) {
	f, err := os.Open(`C:\ProgramData\2020\DSA\2020Catalogs-StateCookie.xml`)
	if err != nil {
		// This is fine, it likely just means the software isn't installed
		return CATALOG_STATE_MISSNG, nil
	}
	defer f.Close()

	var catalogstate DSACatalogState
	dec := xml.NewDecoder(f)
	err = dec.Decode(&catalogstate)
	if err != nil {
		return CATALOG_STATE_INVALID, errors.Wrap(err, "Cannot decode DSA state XML file")
	}

	// The Demo package is mandatory for all installs, so we can check if it's selected
	// in order to determine whether anything is locally installed.
	for j := range catalogstate.GranulePicks {
		if catalogstate.GranulePicks[j].MfgCode == `DMO` &&
			catalogstate.GranulePicks[j].PlatformType == `CAP` &&
			catalogstate.GranulePicks[j].SelectionState == `Selected` {
			return CATALOG_STATE_LOCAL, nil
		}
	}

	if !strings.EqualFold(catalogstate.LastDiscLocation, `\\10.0.9.29\2020catalogbeta\ClientSetup\`) {
		fmt.Printf("Catalog Last Disc Location is incorrectly %s\n", catalogstate.LastDiscLocation)
		return CATALOG_STATE_INVALID, nil
	}

	return CATALOG_STATE_NETWORK, nil
}

func CleanCatalog() error {
	return os.RemoveAll(`C:\ProgramData\2020\DSA`)
}

func UninstallCatalog() error {
	k, err := registry.OpenKey(registry.LOCAL_MACHINE, CAP2020_CATALOG, registry.READ)
	if err != nil {
		return errors.Wrap(err, "Cannot open registry key for uninstall")
	}
	defer k.Close()

	v, _, err := k.GetStringValue("UninstallString")
	if err != nil {
		return errors.Wrap(err, "Cannot read value UninstallString")
	}

	// Verify that the uninstall command looks like one we recognize.
	if !strings.EqualFold(v, `C:\Program Files (x86)\2020\DSA\dsa.exe /removeall /rootpath "C:\ProgramData\2020\DSA"`) {
		return errors.Errorf("UninstallString had an unexpected value of %s", v)
	}

	out, err := exec.Command(`C:\Program Files (x86)\2020\DSA\dsa.exe`, "/removeall", "/rootpath", `"C:\ProgramData\2020\DSA"`).CombinedOutput()
	if err != nil {
		return errors.Wrapf(err, "Uninstall command output: %s", out)
	}
	return nil
}

// "Is Installed", "Is Current", error
func GetSoftwareStatus() (bool, bool, error) {
	k, err := registry.OpenKey(registry.LOCAL_MACHINE, CAP2020_SOFTWARE, registry.READ)
	if err == registry.ErrNotExist {
		return false, false, nil
	} else if err != nil {
		return false, false, errors.Wrap(err, "Cannot open registry key for software version")
	}
	defer k.Close()

	v, _, err := k.GetStringValue("DisplayVersion")
	if err != nil {
		return false, false, errors.Wrap(err, "Cannot read value DisplayVersion")
	}

	return true, (v == CAP2020_SOFTWARE_CURRENT), nil
}

func InstallNetworkCatalog() error {
	out, err := exec.Command(PATH_CATALOG).CombinedOutput()
	if err != nil {
		return errors.Wrapf(err, "Setup command output: %s", out)
	}

	return nil
}

func InstallSoftware() error {
	out, err := exec.Command(PATH_SOFTWARE).CombinedOutput()
	if err != nil {
		return errors.Wrapf(err, "Install command output: %s", out)
	}

	return nil
}

func UninstallSoftware() error {
	out, err := exec.Command("msiexec", "/x", `{5D4D912A-D5EE-4748-84B8-7C2C75EC4408}`, "/passive", "/forcerestart").CombinedOutput()
	if err != nil {
		return errors.Wrapf(err, "Uninstall command output: %s", out)
	}

	return nil
}

func ExitWithSuccess(m string) {
	fmt.Printf("SUCCESS: %s\n\n", m)
	time.Sleep(10 * time.Second)
	os.Exit(0)
}

func ExitWithError(m string, e error) {
	fmt.Printf("ERROR: %s (%+v)\n\n", m, e)
	time.Sleep(5 * time.Minute)
	os.Exit(1)
}

func ExitWithoutSuccess(m string) {
	fmt.Printf("UNSUCCESSFUL: %s\n\n", m)
	time.Sleep(5 * time.Minute)
	os.Exit(2)
}

func main() {
	var err error

	softInstalled, softCurrent, err := GetSoftwareStatus()
	if err != nil {
		ExitWithError("Unable to check software status.", err)
	}

	if !softInstalled {
		fmt.Println("2020 software is not installed.")
		err = InstallSoftware()
		if err != nil {
			ExitWithError("Unable to install the 2020 software. Restart your computer and try again manually.", err)
		}
		ExitWithoutSuccess("Complete the install process manually and run this again afterward.")
	}

	if !softCurrent {
		fmt.Println("2020 software is out of date. Uninstalling current software...")
		err = UninstallSoftware()
		if err != nil {
			ExitWithError("Unable to uninstall the 2020 software. Restart your computer and try again manually.", err)
		}
		ExitWithoutSuccess("Software uninstall will require a reboot. After reboot, run again to update software.")
	}

	fmt.Println("Looks like the 2020 software is up to date. Let's check your catalog...")

	catState, err := GetCatalogStatus()
	if err != nil {
		ExitWithError("Unable to check for Network Deployment.", err)
	}

	if catState == CATALOG_STATE_NETWORK {
		ExitWithSuccess("You are using the 2020 Network Deployment. Nice.")
	}

	if catState == CATALOG_STATE_LOCAL {
		fmt.Println("Looks like you have the catalog installed locally, not on the network.")
		fmt.Println("Uninstalling local catalog.")
		err = UninstallCatalog()
		if err != nil {
			ExitWithError("Can't run the uninstaller for the catalog. Try running it yourself.", err)
		}
		fmt.Println("Clearing out remaining files after uninstall.")
		CleanCatalog()
	}

	fmt.Println("Installing the network catalog...")
	err = InstallNetworkCatalog()
	if err != nil {
		ExitWithError("Failed to install the network catalog.", err)
	}
	fmt.Println("Checking the catalog status again...")
	catState, err = GetCatalogStatus()
	if err == nil && catState == CATALOG_STATE_NETWORK {
		ExitWithSuccess("Looks good. Network catalog is now installed.")
	}
	ExitWithoutSuccess("Finish installing the catalog by using the wizard. You can close this window.")
}