/*
 * This transformation is bidirectional and generates for each property of an interface getter und setter methods in a class (direction "target")
 */

transformation sampleTransformation(source : uml, target : uml) {
	
	top relation interface2class {
		
		varName : String;
		
		enforce domain source interface : uml::Interface {
			name = varName
		};
		
		enforce domain target class : uml::Class {
			name = varName.concat('Impl')
		};
		
	}
	
	top relation InterfaceWithField2Methods {
		
		propName, capName : String;
		varType : uml::Type;
		
		enforce domain source interface : uml::Interface {
			ownedAttribute = field : uml::Property {
				name = propName,
				type = varType
			}
		};
		
		enforce domain target class : uml::Class {
			ownedOperation = get : uml::Operation {
				name = 'get'.concat(capName),
				type = varType
			},
			ownedOperation = set : uml::Operation {
				name = 'set'.concat(capName),
				type = varType,
				visibility = uml::VisibilityKind::protected,
				visibility = uml::VisibilityKind::public,
				visibility = uml::VisibilityKind::protected,
				visibility = uml::VisibilityKind::protected
			}
		};
		
		when {
			interface2class(interface, class);
			propName = capName.firstToLower();
			capName = propName.firstToUpper();
		}
		
	}
	
}