+ def private printPropertySetter(MethodSignature getter, String retrieveProperty, String propertyName) {
+ val ownGetter = implTemplate.findGetter(getter.name)
+ val ownGetterType = ownGetter.returnType
+ if (Types.strictTypeEquals(getter.returnType, ownGetterType)) {
+ return "this._" + propertyName + " = " + retrieveProperty
+ }
+ if (ownGetterType instanceof ParameterizedType) {
+ val itemType = ownGetterType.actualTypeArguments.get(0)
+ if (Types.isListType(ownGetterType)) {
+ val importedClass = importedClass(itemType)
+ if (importedClass !== null) {
+ return printPropertySetter(retrieveProperty, propertyName, "checkListFieldCastIdentity", importedClass)
+ }
+ return printPropertySetter(retrieveProperty, propertyName, "checkListFieldCast", itemType.importedName)
+ }
+ if (Types.isSetType(ownGetterType)) {
+ val importedClass = importedClass(itemType)
+ if (importedClass !== null) {
+ return printPropertySetter(retrieveProperty, propertyName, "checkSetFieldCastIdentity", importedClass)
+ }
+ return printPropertySetter(retrieveProperty, propertyName, "checkSetFieldCast", itemType.importedName)
+ }
+ if (Types.CLASS.equals(ownGetterType)) {
+ return printPropertySetter(retrieveProperty, propertyName, "checkFieldCastIdentity", itemType.identifier.importedName)
+ }
+ }
+ return printPropertySetter(retrieveProperty, propertyName, "checkFieldCast", ownGetterType.importedName)
+ }
+
+ def private printPropertySetter(String retrieveProperty, String propertyName, String checkerName, String className) '''
+ this._«propertyName» = «CODEHELPERS.importedName».«checkerName»(«className».class, "«propertyName»", «retrieveProperty»)'''
+
+ private def importedClass(Type type) {
+ if (type instanceof ParameterizedType) {
+ if (Types.CLASS.equals(type.rawType)) {
+ return type.actualTypeArguments.get(0).identifier.importedName
+ }
+ }
+ return null
+ }
+