/* Copyright 2010-present MongoDB Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License 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 MongoDB.Shared;
namespace MongoDB.Bson
{
///
/// Represents the BSON MinKey value.
///
public class BsonMinKey : BsonValue, IComparable, IEquatable
{
// private static fields
private static BsonMinKey __value = new BsonMinKey();
// constructors
// private so only the singleton instance can be created
private BsonMinKey()
{
}
// public operators
///
/// Compares two BsonMinKey values.
///
/// The first BsonMinKey.
/// The other BsonMinKey.
/// True if the two BsonMinKey values are not equal according to ==.
public static bool operator !=(BsonMinKey lhs, BsonMinKey rhs)
{
return !(lhs == rhs);
}
///
/// Compares two BsonMinKey values.
///
/// The first BsonMinKey.
/// The other BsonMinKey.
/// True if the two BsonMinKey values are equal according to ==.
public static bool operator ==(BsonMinKey lhs, BsonMinKey rhs)
{
if (object.ReferenceEquals(lhs, null)) { return object.ReferenceEquals(rhs, null); }
return lhs.Equals(rhs);
}
// public static properties
///
/// Gets the singleton instance of BsonMinKey.
///
public static BsonMinKey Value { get { return __value; } }
// public properties
///
/// Gets the BsonType of this BsonValue.
///
public override BsonType BsonType
{
get { return BsonType.MinKey; }
}
// public methods
///
/// Compares this BsonMinKey to another BsonMinKey.
///
/// The other BsonMinKey.
/// A 32-bit signed integer that indicates whether this BsonMinKey is less than, equal to, or greather than the other.
public int CompareTo(BsonMinKey other)
{
if (other == null) { return 1; }
return 0; // it's a singleton
}
///
/// Compares the BsonMinKey to another BsonValue.
///
/// The other BsonValue.
/// A 32-bit signed integer that indicates whether this BsonMinKey is less than, equal to, or greather than the other BsonValue.
public override int CompareTo(BsonValue other)
{
if (other == null) { return 1; }
if (other is BsonMinKey) { return 0; }
return -1;
}
///
/// Compares this BsonMinKey to another BsonMinKey.
///
/// The other BsonMinKey.
/// True if the two BsonMinKey values are equal.
public bool Equals(BsonMinKey rhs)
{
if (object.ReferenceEquals(rhs, null) || GetType() != rhs.GetType()) { return false; }
return true; // it's a singleton
}
///
/// Compares this BsonMinKey to another object.
///
/// The other object.
/// True if the other object is a BsonMinKey and equal to this one.
public override bool Equals(object obj)
{
return Equals(obj as BsonMinKey); // works even if obj is null or of a different type
}
///
/// Gets the hash code.
///
/// The hash code.
public override int GetHashCode()
{
return Hasher.GetHashCode(BsonType);
}
///
/// Returns a string representation of the value.
///
/// A string representation of the value.
public override string ToString()
{
return "BsonMinKey";
}
}
}