Repository: ignite Updated Branches: refs/heads/master 83b2bf5e1 -> d7fd58077
IGNITE-2166: .NET: Added toBuilder() method to BinaryObject interface. This closes #379. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/22cf3a34 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/22cf3a34 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/22cf3a34 Branch: refs/heads/master Commit: 22cf3a345e8f6bd517d4b0e875cabdd69491713e Parents: c160ed4 Author: Pavel Tupitsyn <ptupit...@gridgain.com> Authored: Mon Jan 18 18:31:39 2016 +0300 Committer: vozerov-gridgain <voze...@gridgain.com> Committed: Mon Jan 18 18:31:39 2016 +0300 ---------------------------------------------------------------------- .../apache/ignite/internal/binary/BinaryEnumObjectImpl.java | 3 +-- .../Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs | 8 ++++---- .../dotnet/Apache.Ignite.Core/Binary/IBinaryObject.cs | 8 ++++++++ .../dotnet/Apache.Ignite.Core/Impl/Binary/Binary.cs | 3 +++ .../dotnet/Apache.Ignite.Core/Impl/Binary/BinaryEnum.cs | 6 ++++++ .../dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObject.cs | 6 ++++++ 6 files changed, 28 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/22cf3a34/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java index 536c582..180e20a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java @@ -23,7 +23,6 @@ import org.apache.ignite.binary.BinaryObjectBuilder; import org.apache.ignite.binary.BinaryObjectException; import org.apache.ignite.binary.BinaryType; import org.apache.ignite.internal.GridDirectTransient; -import org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl; import org.apache.ignite.internal.processors.cache.CacheObject; import org.apache.ignite.internal.processors.cache.CacheObjectContext; import org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl; @@ -124,7 +123,7 @@ public class BinaryEnumObjectImpl implements BinaryObjectEx, Externalizable, Cac /** {@inheritDoc} */ @Override public BinaryObjectBuilder toBuilder() throws BinaryObjectException { - return BinaryObjectBuilderImpl.wrap(this); + throw new UnsupportedOperationException("Builder cannot be created for enum."); } /** {@inheritDoc} */ http://git-wip-us.apache.org/repos/asf/ignite/blob/22cf3a34/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs index 373e173..d442fb1 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs @@ -265,7 +265,7 @@ namespace Apache.Ignite.Core.Tests.Binary Assert.AreEqual(0, meta.Fields.Count); // Populate it with field. - IBinaryObjectBuilder builder = _grid.GetBinary().GetBuilder(binObj); + IBinaryObjectBuilder builder = binObj.ToBuilder(); Assert.IsNull(builder.GetField<object>("val")); @@ -288,7 +288,7 @@ namespace Apache.Ignite.Core.Tests.Binary Assert.AreEqual(BinaryTypeNames.TypeNameObject, meta.GetFieldTypeName("val")); // Perform field remove. - builder = _grid.GetBinary().GetBuilder(binObj); + builder = binObj.ToBuilder(); Assert.AreEqual(val, builder.GetField<object>("val")); @@ -314,7 +314,7 @@ namespace Apache.Ignite.Core.Tests.Binary .SetField("val2", inner) .Build(); - binObj = _grid.GetBinary().GetBuilder(binObj).RemoveField("val").Build(); + binObj = binObj.ToBuilder().RemoveField("val").Build(); Remove obj = binObj.Deserialize<Remove>(); @@ -636,7 +636,7 @@ namespace Apache.Ignite.Core.Tests.Binary Assert.AreEqual(6, obj.FDouble); // Overwrite. - binObj = _grid.GetBinary().GetBuilder(binObj) + binObj = binObj.ToBuilder() .SetField<byte>("fByte", 7) .SetField("fBool", false) .SetField<short>("fShort", 8) http://git-wip-us.apache.org/repos/asf/ignite/blob/22cf3a34/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryObject.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryObject.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryObject.cs index c5aa80e..841972d 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryObject.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryObject.cs @@ -63,5 +63,13 @@ namespace Apache.Ignite.Core.Binary /// The value of underlying enum in int form. /// </value> int EnumValue { get; } + + /// <summary> + /// Creates a new <see cref="IBinaryObjectBuilder"/> based on this object. + /// <para /> + /// This is equivalent to <see cref="IBinary.GetBuilder(IBinaryObject)"/>. + /// </summary> + /// <returns>New <see cref="IBinaryObjectBuilder"/> based on this object.</returns> + IBinaryObjectBuilder ToBuilder(); } } http://git-wip-us.apache.org/repos/asf/ignite/blob/22cf3a34/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Binary.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Binary.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Binary.cs index 43a4bb8..7062606 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Binary.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Binary.cs @@ -104,6 +104,9 @@ namespace Apache.Ignite.Core.Impl.Binary if (obj0 == null) throw new ArgumentException("Unsupported object type: " + obj.GetType()); + if (obj0 is BinaryEnum) + throw new InvalidOperationException("Builder cannot be created for enum."); + IBinaryTypeDescriptor desc = _marsh.GetDescriptor(true, obj0.TypeId); return Builder0(null, obj0, desc); http://git-wip-us.apache.org/repos/asf/ignite/blob/22cf3a34/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryEnum.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryEnum.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryEnum.cs index 97f44b0..50b2eb8 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryEnum.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryEnum.cs @@ -87,6 +87,12 @@ namespace Apache.Ignite.Core.Impl.Binary } /** <inheritdoc /> */ + public IBinaryObjectBuilder ToBuilder() + { + return _marsh.Ignite.GetBinary().GetBuilder(this); + } + + /** <inheritdoc /> */ public bool Equals(BinaryEnum other) { if (ReferenceEquals(null, other)) http://git-wip-us.apache.org/repos/asf/ignite/blob/22cf3a34/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObject.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObject.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObject.cs index 90607dd..16f95a1 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObject.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObject.cs @@ -133,6 +133,12 @@ namespace Apache.Ignite.Core.Impl.Binary } } + /** <inheritdoc /> */ + public IBinaryObjectBuilder ToBuilder() + { + return _marsh.Ignite.GetBinary().GetBuilder(this); + } + /// <summary> /// Internal deserialization routine. /// </summary>