Search in sources :

Example 11 with BinaryObjectBuilder

use of org.apache.ignite.binary.BinaryObjectBuilder in project ignite by apache.

the class BinaryObjectBuilderDefaultMappersSelfTest method testNullField.

/**
     * @throws Exception If failed.
     */
public void testNullField() throws Exception {
    BinaryObjectBuilder builder = builder("Class");
    builder.setField("objField", (Object) null);
    builder.setField("otherField", "value");
    BinaryObject obj = builder.build();
    assertNull(obj.field("objField"));
    assertEquals("value", obj.field("otherField"));
    assertEquals(BinaryArrayIdentityResolver.instance().hashCode(obj), obj.hashCode());
    builder = builder(obj);
    builder.setField("objField", "value", Object.class);
    builder.setField("otherField", (Object) null);
    obj = builder.build();
    assertNull(obj.field("otherField"));
    assertEquals("value", obj.field("objField"));
    assertEquals(BinaryArrayIdentityResolver.instance().hashCode(obj), obj.hashCode());
}
Also used : BinaryObject(org.apache.ignite.binary.BinaryObject) BinaryObjectBuilder(org.apache.ignite.binary.BinaryObjectBuilder)

Example 12 with BinaryObjectBuilder

use of org.apache.ignite.binary.BinaryObjectBuilder in project ignite by apache.

the class BinaryObjectBuilderDefaultMappersSelfTest method testStringArrayField.

/**
     * @throws Exception If failed.
     */
public void testStringArrayField() throws Exception {
    BinaryObjectBuilder builder = builder("Class");
    builder.setField("stringArrayField", new String[] { "str1", "str2", "str3" });
    BinaryObject po = builder.build();
    assertEquals(expectedHashCode("Class"), po.type().typeId());
    assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
    assertTrue(Arrays.equals(new String[] { "str1", "str2", "str3" }, po.<String[]>field("stringArrayField")));
}
Also used : BinaryObject(org.apache.ignite.binary.BinaryObject) BinaryObjectBuilder(org.apache.ignite.binary.BinaryObjectBuilder)

Example 13 with BinaryObjectBuilder

use of org.apache.ignite.binary.BinaryObjectBuilder in project ignite by apache.

the class BinaryObjectBuilderDefaultMappersSelfTest method testLongArrayField.

/**
     * @throws Exception If failed.
     */
public void testLongArrayField() throws Exception {
    BinaryObjectBuilder builder = builder("Class");
    builder.setField("longArrayField", new long[] { 1, 2, 3 });
    BinaryObject po = builder.build();
    assertEquals(expectedHashCode("Class"), po.type().typeId());
    assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
    assertTrue(Arrays.equals(new long[] { 1, 2, 3 }, po.<long[]>field("longArrayField")));
}
Also used : BinaryObject(org.apache.ignite.binary.BinaryObject) BinaryObjectBuilder(org.apache.ignite.binary.BinaryObjectBuilder)

Example 14 with BinaryObjectBuilder

use of org.apache.ignite.binary.BinaryObjectBuilder in project ignite by apache.

the class BinaryObjectBuilderDefaultMappersSelfTest method testDecimalField.

/**
     * @throws Exception If failed.
     */
public void testDecimalField() throws Exception {
    BinaryObjectBuilder builder = builder("Class");
    builder.setField("decimalField", BigDecimal.TEN);
    BinaryObject po = builder.build();
    assertEquals(expectedHashCode("Class"), po.type().typeId());
    assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
    assertEquals(BigDecimal.TEN, po.<BigDecimal>field("decimalField"));
}
Also used : BinaryObject(org.apache.ignite.binary.BinaryObject) BinaryObjectBuilder(org.apache.ignite.binary.BinaryObjectBuilder)

Example 15 with BinaryObjectBuilder

use of org.apache.ignite.binary.BinaryObjectBuilder in project ignite by apache.

the class BinaryObjectBuilderDefaultMappersSelfTest method testBooleanField.

/**
     * @throws Exception If failed.
     */
public void testBooleanField() throws Exception {
    BinaryObjectBuilder builder = builder("Class");
    builder.setField("booleanField", true);
    BinaryObject po = builder.build();
    assertEquals(expectedHashCode("Class"), po.type().typeId());
    assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
    assertTrue(po.<Boolean>field("booleanField"));
}
Also used : BinaryObject(org.apache.ignite.binary.BinaryObject) BinaryObjectBuilder(org.apache.ignite.binary.BinaryObjectBuilder)

Aggregations

BinaryObjectBuilder (org.apache.ignite.binary.BinaryObjectBuilder)77 BinaryObject (org.apache.ignite.binary.BinaryObject)60 Ignite (org.apache.ignite.Ignite)11 IgniteBinary (org.apache.ignite.IgniteBinary)7 GridBinaryTestClasses (org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses)7 Date (java.util.Date)4 BinaryType (org.apache.ignite.binary.BinaryType)4 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 LinkedHashMap (java.util.LinkedHashMap)3 GridAbsPredicate (org.apache.ignite.internal.util.lang.GridAbsPredicate)3 Field (java.lang.reflect.Field)2 SQLException (java.sql.SQLException)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Map (java.util.Map)2 UUID (java.util.UUID)2 IgniteCache (org.apache.ignite.IgniteCache)2 BinaryObjectException (org.apache.ignite.binary.BinaryObjectException)2 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)2