fromStruct static method

Implementation

static Danger<PropertyTable, PropertyTableException> fromStruct(PropertyTableStruct struct) {

    final log = Log(classLocation: PropertyTable, functionLocation: 'fromStruct');

    final permanentlyPropertyRosterResult = PropertyRoster.fromPermanentlyPropertyStruct(struct.permanentlyPropertyRoster);
    log.add(permanentlyPropertyRosterResult);
    if (permanentlyPropertyRosterResult is! Success<PropertyRoster<PermanentlyProperty>, PropertyException>) return Failure(permanentlyPropertyRosterResult.asException, log);

    final temporaryPropertyRosterResult = PropertyRoster.fromTemporaryPropertyStruct(struct.temporaryPropertyRoster);
    log.add(temporaryPropertyRosterResult);
    if (temporaryPropertyRosterResult is! Success<PropertyRoster<TemporaryProperty>, PropertyException>) return Failure(temporaryPropertyRosterResult.asException, log);

    final listPropertyRosterResult = PropertyRoster.fromListPropertyStruct(struct.listPropertyRoster);
    log.add(listPropertyRosterResult);
    if (listPropertyRosterResult is! Success<PropertyRoster<ListProperty>, PropertyException>) return Failure(listPropertyRosterResult.asException, log);

    final fragmentPropertyRosterResult = PropertyRoster.fromFragmentPropertyStruct(struct.fragmentPropertyRoster);
    log.add(fragmentPropertyRosterResult);
    if (fragmentPropertyRosterResult is! Success<PropertyRoster<FragmentProperty>, PropertyException>) return Failure(fragmentPropertyRosterResult.asException, log);

    final result = PropertyTable.result(
        permanentlyPropertyRosterResult.wrapped,
        temporaryPropertyRosterResult.wrapped,
        listPropertyRosterResult.wrapped,
        fragmentPropertyRosterResult.wrapped,
    );
    log.add(result);

    return Danger.fromDanger(result, log);

}