// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System; namespace osu.Framework.Bindables { public class NonNullableBindable : Bindable where T : class { public NonNullableBindable(T defaultValue) { if (defaultValue == null) throw new ArgumentNullException(nameof(defaultValue)); Value = Default = defaultValue; } private NonNullableBindable() { } public override T Value { get => base.Value; set { if (value == null) throw new ArgumentNullException(nameof(value), $"Cannot set {nameof(Value)} of a {nameof(NonNullableBindable)} to null."); base.Value = value; } } protected override Bindable CreateInstance() => new NonNullableBindable(); } }