﻿//---------------------------------------------------------------------
// <copyright file="QueryIsNotNullExpression.cs" company="Microsoft">
//      Copyright (C) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
// </copyright>
//---------------------------------------------------------------------

namespace Microsoft.Test.Taupo.Query.Contracts.CommonExpressions
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    /// <summary>
    /// Expression node representing IsNotNull operation in a query
    /// </summary>
    public class QueryIsNotNullExpression : QueryExpression
    {
        internal QueryIsNotNullExpression(QueryExpression argument, QueryType type)
            : base(type)
        {
            this.Argument = argument;
        }

        /// <summary>
        /// Gets the Argument of the IsNotNull expression 
        /// </summary>
        public QueryExpression Argument { get; private set; }

        /// <summary>
        /// Returns a <see cref="System.String"/> that represents this instance.
        /// </summary>
        /// <returns>
        /// A <see cref="System.String"/> that represents this instance.
        /// </returns>
        public override string ToString()
        {
            return this.Argument + ".IsNotNull()";
        }

        /// <summary>
        /// The Accept method used to support the double-dispatch visitor pattern with a visitor that returns a result.
        /// </summary>
        /// <typeparam name="TResult">The result type returned by the visitor</typeparam>
        /// <param name="visitor">The visitor that is visiting this expression</param>
        /// <returns>The result of visiting this expression</returns>
        public override TResult Accept<TResult>(ICommonExpressionVisitor<TResult> visitor)
        {
            return visitor.Visit(this);
        }
    }
}