fromJSON method

FuzzyVariable fromJSON(
  1. Map<String, dynamic> json
)

Restores this instance from the given JSON object.

Implementation

FuzzyVariable fromJSON(Map<String,dynamic> json ) {
	minRange = double.parse( json['minRange'] );
	maxRange = double.parse( json['maxRange'] );

	for ( int i = 0, l = json['fuzzySets'].length; i < l; i ++ ) {
		final fuzzySetJson = json['fuzzySets'][ i ];
		String type = fuzzySetJson['type'];

		switch ( type ) {
			case 'LeftShoulderFuzzySet':
				fuzzySets.add( LeftShoulderFuzzySet().fromJSON( fuzzySetJson ) );
				break;
			case 'RightShoulderFuzzySet':
				fuzzySets.add( RightShoulderFuzzySet().fromJSON( fuzzySetJson ) );
				break;
			case 'SingletonFuzzySet':
				fuzzySets.add( SingletonFuzzySet().fromJSON( fuzzySetJson ) );
				break;
			case 'TriangularFuzzySet':
				fuzzySets.add( TriangularFuzzySet().fromJSON( fuzzySetJson ) );
				break;
			default:
				yukaConsole.error( 'YUKA.FuzzyVariable: Unsupported fuzzy set type: ${fuzzySetJson['type']}');
		}
	}

	return this;
}