// ignore_for_file: avoid_catches_without_on_clauses, prefer_const_literals_to_create_immutables, prefer_single_quotes, inference_failure_on_untyped_parameter // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 // NOTE: This file is generated and may not follow lint rules defined in your app // Generated files can be excluded from analysis in analysis_options.yaml // For more info, see: https://dart.dev/guides/language/analysis-options#excluding-code-from-analysis import 'package:amplify_core/amplify_core.dart'; import 'package:meta/meta.dart'; // ignore_for_file: public_member_api_docs, annotate_overrides, dead_code, dead_codepublic_member_api_docs, depend_on_referenced_packages, file_names, library_private_types_in_public_api, no_leading_underscores_for_library_prefixes, no_leading_underscores_for_local_identifiers, non_constant_identifier_names, null_check_on_nullable_type_parameter, prefer_adjacent_string_concatenation, prefer_const_constructors, prefer_if_null_operators, prefer_interpolation_to_compose_strings, slash_for_doc_comments, sort_child_properties_last, unnecessary_const, unnecessary_constructor_name, unnecessary_late, unnecessary_new, unnecessary_null_aware_assignments, unnecessary_nullable_for_final_variable_declarations, unnecessary_string_interpolations, use_build_context_synchronously, field_initializer_not_assignable, argument_type_not_assignable import 'ModelProvider.dart'; /** This is an auto generated class representing the Comment type in your schema. */ @immutable class Comment extends Model { static const classType = const _CommentModelType(); final String id; final Post? _post; final String? _content; final TemporalDateTime? _createdAt; final TemporalDateTime? _updatedAt; @override getInstanceType() => classType; @override String getId() { return id; } Post? get post { return _post; } String get content { try { return _content!; } catch (e) { throw new AmplifyCodeGenModelException( AmplifyExceptionMessages .codeGenRequiredFieldForceCastExceptionMessage, recoverySuggestion: AmplifyExceptionMessages .codeGenRequiredFieldForceCastRecoverySuggestion, underlyingException: e.toString()); } } TemporalDateTime? get createdAt { return _createdAt; } TemporalDateTime? get updatedAt { return _updatedAt; } const Comment._internal( {required this.id, post, required content, createdAt, updatedAt}) : _post = post, _content = content, _createdAt = createdAt, _updatedAt = updatedAt; factory Comment({String? id, Post? post, required String content}) { return Comment._internal( id: id == null ? UUID.getUUID() : id, post: post, content: content); } bool equals(Object other) { return this == other; } @override bool operator ==(Object other) { if (identical(other, this)) return true; return other is Comment && id == other.id && _post == other._post && _content == other._content; } @override int get hashCode => toString().hashCode; @override String toString() { var buffer = new StringBuffer(); buffer.write("Comment {"); buffer.write("id=" + "$id" + ", "); buffer.write("post=" + (_post != null ? _post!.toString() : "null") + ", "); buffer.write("content=" + "$_content" + ", "); buffer.write("createdAt=" + (_createdAt != null ? _createdAt!.format() : "null") + ", "); buffer.write( "updatedAt=" + (_updatedAt != null ? _updatedAt!.format() : "null")); buffer.write("}"); return buffer.toString(); } Comment copyWith({String? id, Post? post, String? content}) { return Comment._internal( id: id ?? this.id, post: post ?? this.post, content: content ?? this.content); } Comment.fromJson(Map json) : id = json['id'], _post = json['post']?['serializedData'] != null ? Post.fromJson( new Map.from(json['post']['serializedData'])) : null, _content = json['content'], _createdAt = json['createdAt'] != null ? TemporalDateTime.fromString(json['createdAt']) : null, _updatedAt = json['updatedAt'] != null ? TemporalDateTime.fromString(json['updatedAt']) : null; Map toJson() => { 'id': id, 'post': _post?.toJson(), 'content': _content, 'createdAt': _createdAt?.format(), 'updatedAt': _updatedAt?.format() }; static final QueryField ID = QueryField(fieldName: "id"); static final QueryField POST = QueryField( fieldName: "post", fieldType: ModelFieldType(ModelFieldTypeEnum.model, ofModelName: (Post).toString())); static final QueryField CONTENT = QueryField(fieldName: "content"); static var schema = Model.defineSchema(define: (ModelSchemaDefinition modelSchemaDefinition) { modelSchemaDefinition.name = "Comment"; modelSchemaDefinition.pluralName = "Comments"; modelSchemaDefinition.authRules = [ AuthRule( authStrategy: AuthStrategy.PRIVATE, provider: AuthRuleProvider.IAM, operations: [ModelOperation.READ]), AuthRule( authStrategy: AuthStrategy.PRIVATE, provider: AuthRuleProvider.USERPOOLS, operations: [ModelOperation.READ]), AuthRule( authStrategy: AuthStrategy.OWNER, ownerField: "owner", identityClaim: "cognito:username", provider: AuthRuleProvider.USERPOOLS, operations: [ ModelOperation.CREATE, ModelOperation.READ, ModelOperation.UPDATE, ModelOperation.DELETE ]) ]; modelSchemaDefinition.addField(ModelFieldDefinition.id()); modelSchemaDefinition.addField(ModelFieldDefinition.belongsTo( key: Comment.POST, isRequired: false, // TODO(Jordan-Nelson): Remove `targetName` when API category has been // updated to support CPK changes. This was added manually. // ignore: deprecated_member_use targetName: "postID", ofModelName: (Post).toString())); modelSchemaDefinition.addField(ModelFieldDefinition.field( key: Comment.CONTENT, isRequired: true, ofType: ModelFieldType(ModelFieldTypeEnum.string))); modelSchemaDefinition.addField(ModelFieldDefinition.nonQueryField( fieldName: 'createdAt', isRequired: false, isReadOnly: true, ofType: ModelFieldType(ModelFieldTypeEnum.dateTime))); modelSchemaDefinition.addField(ModelFieldDefinition.nonQueryField( fieldName: 'updatedAt', isRequired: false, isReadOnly: true, ofType: ModelFieldType(ModelFieldTypeEnum.dateTime))); }); } class _CommentModelType extends ModelType { const _CommentModelType(); @override Comment fromJson(Map jsonData) { return Comment.fromJson(jsonData); } }