/* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ using System; using System.Collections.Generic; using System.Linq; using Amazon.DynamoDBv2.Model; using System.IO; using Amazon.Runtime.Internal.Util; using Amazon.Util; namespace Amazon.DynamoDBv2.DocumentModel { /// /// A DynamoDBEntry that represents a DynamoDB bool (BOOL) type. /// public class DynamoDBBool : DynamoDBEntry { /// /// Construct an instance of DynamnDBBool /// /// public DynamoDBBool(bool value) { Value = value; } /// /// Gets and sets the Value property. /// public bool Value { get; set; } /// /// Constant DynamoDBBool for the true value /// public static readonly DynamoDBBool True = new DynamoDBBool(true); /// /// Constant DynamoDBBool for the false value /// public static readonly DynamoDBBool False = new DynamoDBBool(false); #region Overrides internal override AttributeValue ConvertToAttributeValue(AttributeConversionConfig conversionConfig) { return new AttributeValue { BOOL = Value }; } /// /// Implement the Clone method /// /// public override object Clone() { return new DynamoDBBool(Value); } #endregion /// /// Explicitly convert DynamoDBBool to Boolean /// /// Boolean value of this object public override Boolean AsBoolean() { return this.Value; } /// /// Implicitly convert Boolean to DynamoDBBool /// /// Boolean data to convert /// DynamoDBBool representing the data public static implicit operator DynamoDBBool(Boolean data) { return new DynamoDBBool(data); } /// /// Explicitly convert DynamoDBBool to Boolean /// /// DynamoDBBool to convert /// Boolean value of DynamoDBBool public static explicit operator Boolean(DynamoDBBool p) { return p.AsBoolean(); } #region Overrides /// /// Implement the Equals method /// /// /// public override bool Equals(object obj) { var otherBool = obj as DynamoDBBool; if (otherBool == null) return false; return (this.Value == otherBool.Value); } /// /// Implement the GetHashCode method /// /// public override int GetHashCode() { return Value.GetHashCode(); } #endregion } }