ClassReflection<O> class abstract

Base for Class reflection.

Inheritance
Implemented types
Available Extensions

Constructors

ClassReflection(Type classType, String className, [O? object])

Properties

asTypeReflection TypeReflection<O>
Returns reflectedType as a TypeReflection.
no setterinherited
canCreateInstanceWithoutArguments bool
Returns true if createInstance can return an instantiated instance without any constructor argument.
no setter
classAnnotations List<Object>
Returns a const List of class annotations.
no setteroverride
className String
The reflected class name (without minification).
final
classType Type
The reflected class Type.
final
constructorsNames List<String>
Returns a const List of constructors names.
no setter
fieldsJsonNameAliases Map<String, String>
Returns a Map with the fields names aliases.
no setter
fieldsJsonNameAliasesReverse Map<String, String>
A reverse Map (value, key) of fieldsJsonNameAliases.
no setter
fieldsNames List<String>
Returns a const List of fields names.
no setteroverride
fieldsWithJsonFieldHidden List<FieldReflection<O, dynamic>>
Returns the fields with a JsonField.hidden.
no setter
fieldsWithJsonFieldVisible List<FieldReflection<O, dynamic>>
Returns the fields with a JsonField.visible.
no setter
fieldsWithJsonNameAlias List<FieldReflection<O, dynamic>>
Returns the fields with a valid JsonFieldAlias.
no setter
hasDefaultConstructor bool
Returns true if the class has a default constructor.
no setter
hasEmptyConstructor bool
Returns true if the class has an empty constructor.
no setter
hasFieldWithoutSetter bool
Returns true if some field doesn't have a setter (ignoring hashCode).
no setter
hasFinalField bool
Returns true if some field is final (ignoring hashCode).
no setter
hashCode int
The hash code for this object.
no setterinherited
hasJsonConstructor bool
Returns true if some constructor has a JsonConstructor annotation.
no setter
hasJsonConstructorMandatory bool
Returns true if some constructor has a JsonConstructor.mandatory annotation.
no setter
hasJsonFieldHidden bool
Returns true if any field uses a JsonField.hidden.
no setter
hasJsonFieldVisible bool
Returns true if any field uses a JsonField.visible.
no setter
hasJsonNameAlias bool
Returns true if any field or constructor parameter uses a JsonFieldAlias.
no setter
hasMethodToJson bool
no setter
hasNoRequiredArgsConstructor bool
Returns true if the class has a constructor without required arguments.
no setter
hasObject bool
Returns true if this instances has an associated object (O).
no setteroverride
jsonConstructors List<ConstructorReflection<O>>
no setter
jsonConstructorsMandatory List<ConstructorReflection<O>>
no setter
languageVersion Version
Returns the Dart language Version of the reflected code.
no setteroverride
methodsNames List<String>
Returns a const List of methods names.
no setter
object → O?
final
reflectedType Type
The reflected type by this implementation.
no setteroverride
reflectionFactoryVersion Version
Returns reflection_factory Version used to generate this reflection code.
no setteroverride
reflectionLevel int
The reflection level (complexity).
no setteroverride
reflectionName String
The reflected type name by this implementation. See reflectedType.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
staticFieldsNames List<String>
Returns a const List of static fields names.
no setter
staticMethodsNames List<String>
Returns a const List of static methods names.
no setter
supperTypes List<Type>
Returns a list of supper types.
no setter
typeInfo TypeInfo
Returns reflectedType as a TypeInfo.
no setterinherited

Methods

allConstructors() List<ConstructorReflection<O>>
Returns a List with all constructors ConstructorReflection.
allFields([O? obj]) List<FieldReflection<O, dynamic>>
Returns a List with all fields FieldReflection.
allMethods([O? obj]) List<MethodReflection<O, dynamic>>
Returns a List with all methods MethodReflection.
allStaticFields() List<StaticFieldReflection<O, dynamic>>
Returns a List with all static fields FieldReflection.
allStaticMethods() List<StaticMethodReflection<O, dynamic>>
Returns a List with all static methods MethodReflection.
callCasted<R>(R function<O>(ClassReflection<O> classReflection)) → R
Calls function with correct casting for ClassReflection.
override
callMethodToJson([O? obj]) Object?
canSetFields(List<String> fields) bool
Returns true if all fields can be set using setField.
castCollection(dynamic o, TypeInfo typeInfo, {bool nullable = false}) Object?
Cast o to a collection represented by typeInfo.
inherited
castIterable(Iterable itr, Type type, {bool nullable = false}) Iterable?
Cast itr to reflectedType if type == reflectedType or return null.
inherited
castList(List list, Type type, {bool nullable = false}) List?
Cast list to reflectedType if type == reflectedType or return null.
inherited
castMap(Map map, TypeInfo typeInfo, {bool nullable = false}) Map?
Cast map keys & values to reflectedType if type == reflectedType or return null.
inherited
castMapKeys(Map map, TypeInfo typeInfo, {bool nullable = false}) Map?
Cast map keys to reflectedType if type == reflectedType or return null.
inherited
castMapValues(Map map, TypeInfo typeInfo, {bool nullable = false}) Map?
Cast map values to reflectedType if type == reflectedType or return null.
inherited
castSet(Set set, Type type, {bool nullable = false}) Set?
Cast set to reflectedType if type == reflectedType or return null.
inherited
compareTo(ClassReflection other) int
Compares this object to another object.
override
constructor(String constructorName) ConstructorReflection<O>?
Returns a ConstructorReflection for constructorName.
createInstance() → O?
Creates an instances calling createInstanceWithDefaultConstructor or createInstanceWithEmptyConstructor or createInstanceWithNoRequiredArgsConstructor.
createInstanceFromMap(Map<String, Object?> map, {FieldNameResolver? fieldNameResolver, FieldValueResolver? fieldValueResolver}) → O?
createInstanceWithBestConstructor(Map<String, Object?> map, {FieldNameResolver? fieldNameResolver, FieldValueResolver? fieldValueResolver, bool? allowEmptyConstructors, bool? allowOptionalOnlyConstructors}) → O?
Creates an instance with the constructor returned by getBestConstructorForMap, using map entries as parameters.
createInstanceWithConstructor(ConstructorReflection<O> constructor, Map<String, Object?> map, {FieldNameResolver? fieldNameResolver, FieldValueResolver? fieldValueResolver, OnConstructorInvocationError? onInvocationError}) → O?
Creates an instance with constructor using map entries as parameters.
createInstanceWithConstructorByName(String constructorName, Map<String, dynamic> map, {FieldNameResolver? fieldNameResolver, FieldValueResolver? fieldValueResolver}) → O?
Creates an instance with the constructor with constructorName using map entries as parameters.
createInstanceWithConstructors(List<ConstructorReflection<O>> constructors, Map<String, Object?> map, {FieldNameResolver? fieldNameResolver, FieldValueResolver? fieldValueResolver}) → O?
Creates an instance with one of the constructors, using map entries as parameters.
createInstanceWithDefaultConstructor() → O?
Creates an instance using the default constructor (if present), other wise returns null.
createInstanceWithEmptyConstructor() → O?
Creates an instance using an empty constructor (if present), other wise returns null.
createInstanceWithNoRequiredArgsConstructor() → O?
Creates an instance using a constructor without required arguments (if present), other wise returns null.
disposeCache() → void
Dispose internal caches.
entityFields([O? obj]) List<FieldReflection<O, dynamic>>
fieldsWhere FieldReflection.isEntityField.
entityFieldsNamesWhere(bool test(FieldReflection<O, dynamic> f), [O? obj, bool jsonName = false]) Iterable<String>
Returns a List of fields names that matches test.
field<T>(String fieldName, [O? obj]) FieldReflection<O, T>?
Returns a FieldReflection for fieldName, with the optional associated obj.
fieldResolver<T>(String fieldName) ElementResolver<FieldReflection<O, T>>
Returns a ElementResolver for a FieldReflection for a field with fieldName.
fieldsNamesWhere(bool test(FieldReflection<O, dynamic> f), [O? obj, bool jsonName = false]) Iterable<String>
Returns a List of fields names that matches test.
fieldsWhere(bool test(FieldReflection<O, dynamic> f), [O? obj]) Iterable<FieldReflection<O, dynamic>>
Returns a List of fields FieldReflection that matches test.
fromJson(Object? json, {JsonDecoder? jsonDecoder, bool duplicatedEntitiesAsID = true, bool? autoResetEntityCache}) → O
Returns a class instance from json.
override
fromJsonEncoded(String jsonEncoded) → O
Returns a class instance from jsonEncoded.
override
getBestConstructorFor({Iterable<String> requiredParameters = const <String>[], Iterable<String> optionalParameters = const <String>[], Iterable<String> nullableParameters = const <String>[], Iterable<String> presentParameters = const <String>[], bool jsonName = false}) ConstructorReflection<O>?
Returns the best ConstructorReflection for requiredParameters, optionalParameters, nullableParameters and presentParameters.
getBestConstructorForMap(Map<String, Object?> map, {FieldNameResolver? fieldNameResolver, FieldValueResolver? fieldValueResolver, bool allowEmptyConstructors = true, bool allowOptionalOnlyConstructors = true}) ConstructorReflection<O>?
Returns the best constructor to instantiate with map entries.
getBestConstructorsFor({Iterable<String> requiredParameters = const <String>[], Iterable<String> optionalParameters = const <String>[], Iterable<String> nullableParameters = const <String>[], Iterable<String> presentParameters = const <String>[], bool allowEmptyConstructors = true, bool allowOptionalOnlyConstructors = true, bool jsonName = false}) List<ConstructorReflection<O>>
Returns a List of the best ConstructorReflection for requiredParameters, optionalParameters, nullableParameters and presentParameters.
getBestConstructorsForMap(Map<String, Object?> map, {FieldNameResolver? fieldNameResolver, FieldValueResolver? fieldValueResolver, bool allowEmptyConstructors = true, bool allowOptionalOnlyConstructors = true}) List<ConstructorReflection<O>>
Returns an unmodifiable List of the best constructors to instantiate with map entries.
getField<T>(String fieldName, [O? obj]) → T?
Returns the field value for fieldName.
getFieldsValues(O? obj, {bool withHashCode = false}) Map<String, dynamic>
Returns a Map with allFields values.
getJsonFieldsVisibleValues(O? obj, {bool withHashCode = false}) Map<String, dynamic>
Returns a Map with allFields values without JsonField.hidden.
getStaticField<T>(String fieldName) → T?
Returns the static field value for fieldName.
getStaticInstance() ClassReflection<O>
Returns the staticInstance of the generated ClassReflection.
invokeMethod<R>(String methodName, Iterable<Object?>? positionalArguments, [Map<Symbol, Object?>? namedArguments]) → R?
Invokes the method for methodName.
invokeMethodWith<R>(String methodName, O object, Iterable<Object?>? positionalArguments, [Map<Symbol, Object?>? namedArguments]) → R?
Invokes the method for methodName with the associated object.
invokeStaticMethod<R>(String methodName, Iterable<Object?>? positionalArguments, [Map<Symbol, Object?>? namedArguments]) → R?
Invokes the static method for methodName.
method<R>(String methodName, [O? obj]) MethodReflection<O, R>?
Returns a MethodReflection for methodName, with the optional associated obj.
methodResolver<R>(String methodName) ElementResolver<MethodReflection<O, R>>
Returns a ElementResolver for a MethodReflection for a method with methodName.
methodsWhere(bool test(MethodReflection<O, dynamic> f), [O? obj]) Iterable<MethodReflection<O, dynamic>>
Returns a List of methods MethodReflection that matches test.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
register() → void
Called automatically when instantiated. Registers this reflection into ReflectionFactory.
override
setField<T>(String fieldName, T value, [O? obj]) → void
Sets the field value for fieldName.
setStaticField<T>(String fieldName, T value) → void
Sets the static field value for fieldName.
setupInternalsOf(ClassReflection o) → void
Setups the internal fields of o instance using already computed fields of this. Used by withObject.
setupInternalsWith(ClassReflection o) → void
Setups the internal fields of this instance using already computed fields of o. Used by withObject.
siblingClassReflectionFor<T>({T? obj, Type? type}) ClassReflection<T>?
Returns a siblingsClassReflection for type, obj or T.
siblingReflectionFor<T>({T? obj, Type? type}) Reflection<T>?
Returns a Reflection for type, obj or T.
inherited
siblingsClassReflection() List<ClassReflection>
Returns a List of siblings ClassReflection (declared in the same code unit).
siblingsReflection() List<Reflection>
Returns a List of siblings Reflection (declared in the same code unit).
inherited
staticField<T>(String fieldName) StaticFieldReflection<O, T>?
Returns a static FieldReflection for fieldName.
staticFieldResolver<T>(String fieldName) ElementResolver<StaticFieldReflection<O, T>>
Returns a ElementResolver for a FieldReflection for a static field with fieldName.
staticFieldsWhere(bool test(StaticFieldReflection<O, dynamic> f)) Iterable<StaticFieldReflection<O, dynamic>>
Returns a List of static fields FieldReflection that matches test.
staticMethod<R>(String methodName) StaticMethodReflection<O, R>?
Returns a static MethodReflection for methodName.
staticMethodResolver<R>(String methodName) ElementResolver<StaticMethodReflection<O, R>>
Returns a ElementResolver for a MethodReflection for a static method with methodName.
staticMethodsWhere(bool test(StaticMethodReflection<O, dynamic> f)) Iterable<StaticMethodReflection<O, dynamic>>
Returns a List of static methods MethodReflection that matches test.
toJson([O? obj, JsonEncoder? jsonEncoder, bool duplicatedEntitiesAsID = false, bool? autoResetEntityCache]) Object?
Returns a JSON. If the class implements toJson calls it.
override
toJsonEncoded({O? obj, JsonEncoder? jsonEncoder, bool pretty = false, bool duplicatedEntitiesAsID = false}) String
Returns a JSON encoded. See toJson.
override
toJsonFromFields({O? obj, JsonEncoder? jsonEncoder, bool duplicatedEntitiesAsID = false, bool? autoResetEntityCache}) Map<String, dynamic>
Returns a JSON Map from fieldsNames, calling getField for each one.
toJsonMap({O? obj, JsonEncoder? jsonEncoder, bool duplicatedEntitiesAsID = false, bool? autoResetEntityCache}) Map<String, dynamic>?
Returns a JSON Map. If the class implements toJson calls it.
override
toMapFromFields([O? obj]) Map<String, dynamic>
Returns a Map from fieldsNames, calling getField for each one. See toJsonFromFields if you need a JSON Map (with valid JSON values).
toString() String
A string representation of this object.
override
withObject([O? obj]) ClassReflection<O>
Returns a new instances with obj as the associated object (O).
override
withoutObjectInstance() ClassReflection<O>
Returns a new instances without an object instance.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited