Skip to content

Commit

Permalink
Update .expected files
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsenko committed Jun 27, 2024
1 parent 1c429ae commit a332fc8
Show file tree
Hide file tree
Showing 20 changed files with 163 additions and 285 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ class Person extends _Person with RealmEntity, RealmObjectBase, RealmObject {

static EJsonValue _toEJson(Person value) => value.toEJson();
static Person _fromEJson(EJsonValue ejson) {
if (ejson is! Map<String, dynamic>) return raiseInvalidEJson(ejson);
return switch (ejson) {
{
'name': EJsonValue name,
'age': EJsonValue age,
} =>
Person(
name: fromEJson(name),
age: fromEJson(age),
age: fromEJson(ejson['age']),
),
_ => raiseInvalidEJson(ejson),
};
Expand Down
42 changes: 15 additions & 27 deletions packages/realm_generator/test/good_test_data/all_types.expected
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,11 @@ class Foo extends _Foo with RealmEntity, RealmObjectBase, RealmObject {

static EJsonValue _toEJson(Foo value) => value.toEJson();
static Foo _fromEJson(EJsonValue ejson) {
return switch (ejson) {
{
'x': EJsonValue x,
'bar': EJsonValue bar,
} =>
Foo(
x: fromEJson(x),
bar: fromEJson(bar),
),
_ => raiseInvalidEJson(ejson),
};
if (ejson is! Map<String, dynamic>) return raiseInvalidEJson(ejson);
return Foo(
x: fromEJson(ejson['x']),
bar: fromEJson(ejson['bar']),
);
}

static final schema = () {
Expand Down Expand Up @@ -269,23 +263,16 @@ class Bar extends _Bar with RealmEntity, RealmObjectBase, RealmObject {

static EJsonValue _toEJson(Bar value) => value.toEJson();
static Bar _fromEJson(EJsonValue ejson) {
if (ejson is! Map<String, dynamic>) return raiseInvalidEJson(ejson);
return switch (ejson) {
{
'name': EJsonValue name,
'aBool': EJsonValue aBool,
'another': EJsonValue another,
'data': EJsonValue data,
'tidspunkt': EJsonValue timestamp,
'aDouble': EJsonValue aDouble,
'foo': EJsonValue foo,
'objectId': EJsonValue objectId,
'uuid': EJsonValue uuid,
'list': EJsonValue list,
'set': EJsonValue set,
'map': EJsonValue map,
'anOptionalString': EJsonValue anOptionalString,
'any': EJsonValue any,
'manyAny': EJsonValue manyAny,
'decimal': EJsonValue decimal,
} =>
Bar(
Expand All @@ -297,14 +284,14 @@ class Bar extends _Bar with RealmEntity, RealmObjectBase, RealmObject {
fromEJson(objectId),
fromEJson(uuid),
fromEJson(decimal),
aDouble: fromEJson(aDouble),
foo: fromEJson(foo),
list: fromEJson(list),
set: fromEJson(set),
map: fromEJson(map),
anOptionalString: fromEJson(anOptionalString),
any: fromEJson(any),
manyAny: fromEJson(manyAny),
aDouble: fromEJson(ejson['aDouble']),
foo: fromEJson(ejson['foo']),
list: fromEJson(ejson['list']),
set: fromEJson(ejson['set']),
map: fromEJson(ejson['map']),
anOptionalString: fromEJson(ejson['anOptionalString']),
any: fromEJson(ejson['any']),
manyAny: fromEJson(ejson['manyAny']),
),
_ => raiseInvalidEJson(ejson),
};
Expand Down Expand Up @@ -426,6 +413,7 @@ class PrimitiveTypes extends _PrimitiveTypes

static EJsonValue _toEJson(PrimitiveTypes value) => value.toEJson();
static PrimitiveTypes _fromEJson(EJsonValue ejson) {
if (ejson is! Map<String, dynamic>) return raiseInvalidEJson(ejson);
return switch (ejson) {
{
'stringProp': EJsonValue stringProp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,11 @@ class MappedToo extends _MappedToo

static EJsonValue _toEJson(MappedToo value) => value.toEJson();
static MappedToo _fromEJson(EJsonValue ejson) {
return switch (ejson) {
{
'singleLink': EJsonValue singleLink,
'listLink': EJsonValue listLink,
} =>
MappedToo(
singleLink: fromEJson(singleLink),
listLink: fromEJson(listLink),
),
_ => raiseInvalidEJson(ejson),
};
if (ejson is! Map<String, dynamic>) return raiseInvalidEJson(ejson);
return MappedToo(
singleLink: fromEJson(ejson['singleLink']),
listLink: fromEJson(ejson['listLink']),
);
}

static final schema = () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,16 @@ class Asymmetric extends _Asymmetric

static EJsonValue _toEJson(Asymmetric value) => value.toEJson();
static Asymmetric _fromEJson(EJsonValue ejson) {
if (ejson is! Map<String, dynamic>) return raiseInvalidEJson(ejson);
return switch (ejson) {
{
'_id': EJsonValue id,
'children': EJsonValue children,
'father': EJsonValue father,
'mother': EJsonValue mother,
} =>
Asymmetric(
fromEJson(id),
children: fromEJson(children),
father: fromEJson(father),
mother: fromEJson(mother),
children: fromEJson(ejson['children']),
father: fromEJson(ejson['father']),
mother: fromEJson(ejson['mother']),
),
_ => raiseInvalidEJson(ejson),
};
Expand Down Expand Up @@ -150,6 +148,7 @@ class Embedded extends _Embedded

static EJsonValue _toEJson(Embedded value) => value.toEJson();
static Embedded _fromEJson(EJsonValue ejson) {
if (ejson is! Map<String, dynamic>) return raiseInvalidEJson(ejson);
return switch (ejson) {
{
'name': EJsonValue name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ class Foo extends _Foo with RealmEntity, RealmObjectBase, RealmObject {

static EJsonValue _toEJson(Foo value) => value.toEJson();
static Foo _fromEJson(EJsonValue ejson) {
if (ejson is! Map<String, dynamic>) return raiseInvalidEJson(ejson);
return switch (ejson) {
{
'requiredBinaryProp': EJsonValue requiredBinaryProp,
'nullableBinaryProp': EJsonValue nullableBinaryProp,
} =>
Foo(
fromEJson(requiredBinaryProp),
nullableBinaryProp: fromEJson(nullableBinaryProp),
nullableBinaryProp: fromEJson(ejson['nullableBinaryProp']),
),
_ => raiseInvalidEJson(ejson),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,49 +220,27 @@ class ConstInitializer extends _ConstInitializer

static EJsonValue _toEJson(ConstInitializer value) => value.toEJson();
static ConstInitializer _fromEJson(EJsonValue ejson) {
return switch (ejson) {
{
'zero': EJsonValue zero,
'minusOne': EJsonValue minusOne,
'fooOrOne': EJsonValue fooOrOne,
'parenthesis': EJsonValue parenthesis,
'minusMinusOne': EJsonValue minusMinusOne,
'add': EJsonValue add,
'identifier': EJsonValue identifier,
'infinity': EJsonValue infinity,
'nan': EJsonValue nan,
'negativeInfinity': EJsonValue negativeInfinity,
'fooEnv': EJsonValue fooEnv,
'fooLit': EJsonValue fooLit,
'constEmptyList': EJsonValue constEmptyList,
'constEmptyMap': EJsonValue constEmptyMap,
'constEmptySet': EJsonValue constEmptySet,
'emptyList': EJsonValue emptyList,
'emptyMao': EJsonValue emptyMao,
'emptySet': EJsonValue emptySet,
} =>
ConstInitializer(
zero: fromEJson(zero),
minusOne: fromEJson(minusOne),
fooOrOne: fromEJson(fooOrOne),
parenthesis: fromEJson(parenthesis),
minusMinusOne: fromEJson(minusMinusOne),
add: fromEJson(add),
identifier: fromEJson(identifier),
infinity: fromEJson(infinity),
nan: fromEJson(nan),
negativeInfinity: fromEJson(negativeInfinity),
fooEnv: fromEJson(fooEnv),
fooLit: fromEJson(fooLit),
constEmptyList: fromEJson(constEmptyList),
constEmptyMap: fromEJson(constEmptyMap),
constEmptySet: fromEJson(constEmptySet),
emptyList: fromEJson(emptyList),
emptyMao: fromEJson(emptyMao),
emptySet: fromEJson(emptySet),
),
_ => raiseInvalidEJson(ejson),
};
if (ejson is! Map<String, dynamic>) return raiseInvalidEJson(ejson);
return ConstInitializer(
zero: fromEJson(ejson['zero']),
minusOne: fromEJson(ejson['minusOne']),
fooOrOne: fromEJson(ejson['fooOrOne']),
parenthesis: fromEJson(ejson['parenthesis']),
minusMinusOne: fromEJson(ejson['minusMinusOne']),
add: fromEJson(ejson['add']),
identifier: fromEJson(ejson['identifier']),
infinity: fromEJson(ejson['infinity']),
nan: fromEJson(ejson['nan']),
negativeInfinity: fromEJson(ejson['negativeInfinity']),
fooEnv: fromEJson(ejson['fooEnv']),
fooLit: fromEJson(ejson['fooLit']),
constEmptyList: fromEJson(ejson['constEmptyList']),
constEmptyMap: fromEJson(ejson['constEmptyMap']),
constEmptySet: fromEJson(ejson['constEmptySet']),
emptyList: fromEJson(ejson['emptyList']),
emptyMao: fromEJson(ejson['emptyMao']),
emptySet: fromEJson(ejson['emptySet']),
);
}

static final schema = () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,11 @@ class Parent extends _Parent with RealmEntity, RealmObjectBase, RealmObject {

static EJsonValue _toEJson(Parent value) => value.toEJson();
static Parent _fromEJson(EJsonValue ejson) {
return switch (ejson) {
{
'single child': EJsonValue child,
'CHILDREN': EJsonValue children,
} =>
Parent(
child: fromEJson(child),
children: fromEJson(children),
),
_ => raiseInvalidEJson(ejson),
};
if (ejson is! Map<String, dynamic>) return raiseInvalidEJson(ejson);
return Parent(
child: fromEJson(ejson['single child']),
children: fromEJson(ejson['CHILDREN']),
);
}

static final schema = () {
Expand Down Expand Up @@ -136,16 +130,16 @@ class Child1 extends _Child1 with RealmEntity, RealmObjectBase, EmbeddedObject {

static EJsonValue _toEJson(Child1 value) => value.toEJson();
static Child1 _fromEJson(EJsonValue ejson) {
if (ejson is! Map<String, dynamic>) return raiseInvalidEJson(ejson);
return switch (ejson) {
{
'_value': EJsonValue value,
'_parent': EJsonValue linkToParent,
'indexedString': EJsonValue indexedString,
} =>
Child1(
fromEJson(value),
fromEJson(indexedString),
linkToParent: fromEJson(linkToParent),
linkToParent: fromEJson(ejson['_parent']),
),
_ => raiseInvalidEJson(ejson),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,11 @@ class Parent extends _Parent with RealmEntity, RealmObjectBase, RealmObject {

static EJsonValue _toEJson(Parent value) => value.toEJson();
static Parent _fromEJson(EJsonValue ejson) {
return switch (ejson) {
{
'child': EJsonValue child,
'children': EJsonValue children,
} =>
Parent(
child: fromEJson(child),
children: fromEJson(children),
),
_ => raiseInvalidEJson(ejson),
};
if (ejson is! Map<String, dynamic>) return raiseInvalidEJson(ejson);
return Parent(
child: fromEJson(ejson['child']),
children: fromEJson(ejson['children']),
);
}

static final schema = () {
Expand Down Expand Up @@ -143,18 +137,16 @@ class Child1 extends _Child1 with RealmEntity, RealmObjectBase, EmbeddedObject {

static EJsonValue _toEJson(Child1 value) => value.toEJson();
static Child1 _fromEJson(EJsonValue ejson) {
if (ejson is! Map<String, dynamic>) return raiseInvalidEJson(ejson);
return switch (ejson) {
{
'value': EJsonValue value,
'child': EJsonValue child,
'children': EJsonValue children,
'linkToParent': EJsonValue linkToParent,
} =>
Child1(
fromEJson(value),
child: fromEJson(child),
children: fromEJson(children),
linkToParent: fromEJson(linkToParent),
child: fromEJson(ejson['child']),
children: fromEJson(ejson['children']),
linkToParent: fromEJson(ejson['linkToParent']),
),
_ => raiseInvalidEJson(ejson),
};
Expand Down Expand Up @@ -336,6 +328,7 @@ class Child2 extends _Child2 with RealmEntity, RealmObjectBase, EmbeddedObject {

static EJsonValue _toEJson(Child2 value) => value.toEJson();
static Child2 _fromEJson(EJsonValue ejson) {
if (ejson is! Map<String, dynamic>) return raiseInvalidEJson(ejson);
return switch (ejson) {
{
'boolProp': EJsonValue boolProp,
Expand All @@ -345,13 +338,6 @@ class Child2 extends _Child2 with RealmEntity, RealmObjectBase, EmbeddedObject {
'dateProp': EJsonValue dateProp,
'objectIdProp': EJsonValue objectIdProp,
'uuidProp': EJsonValue uuidProp,
'nullableBoolProp': EJsonValue nullableBoolProp,
'nullableIntProp': EJsonValue nullableIntProp,
'nullableDoubleProp': EJsonValue nullableDoubleProp,
'nullableStringProp': EJsonValue nullableStringProp,
'nullableDateProp': EJsonValue nullableDateProp,
'nullableObjectIdProp': EJsonValue nullableObjectIdProp,
'nullableUuidProp': EJsonValue nullableUuidProp,
} =>
Child2(
fromEJson(boolProp),
Expand All @@ -361,13 +347,13 @@ class Child2 extends _Child2 with RealmEntity, RealmObjectBase, EmbeddedObject {
fromEJson(dateProp),
fromEJson(objectIdProp),
fromEJson(uuidProp),
nullableBoolProp: fromEJson(nullableBoolProp),
nullableIntProp: fromEJson(nullableIntProp),
nullableDoubleProp: fromEJson(nullableDoubleProp),
nullableStringProp: fromEJson(nullableStringProp),
nullableDateProp: fromEJson(nullableDateProp),
nullableObjectIdProp: fromEJson(nullableObjectIdProp),
nullableUuidProp: fromEJson(nullableUuidProp),
nullableBoolProp: fromEJson(ejson['nullableBoolProp']),
nullableIntProp: fromEJson(ejson['nullableIntProp']),
nullableDoubleProp: fromEJson(ejson['nullableDoubleProp']),
nullableStringProp: fromEJson(ejson['nullableStringProp']),
nullableDateProp: fromEJson(ejson['nullableDateProp']),
nullableObjectIdProp: fromEJson(ejson['nullableObjectIdProp']),
nullableUuidProp: fromEJson(ejson['nullableUuidProp']),
),
_ => raiseInvalidEJson(ejson),
};
Expand Down
Loading

0 comments on commit a332fc8

Please sign in to comment.