<?xml version="1.0" encoding="UTF-8"?>
<merge:options 
  indent="    "  
  braceStyle="standard"  
  redirect="Gen"
  xmlns:merge="http://www.eclipse.org/org/eclipse/emf/codegen/jmerge/Options">



<!-- PATTERNS -->
    <!--
    	Markup:  gen 
    	Applies: Member comments
    	Purpose: Recognized members (types, fields, ...) whose javadoc contains
			         @generated "... (...)" NL
    	-->
    <merge:dictionaryPattern
      name="generatedMembers" 
      select="Member/getComment" 
      match="\s*@\s*(gen)erated\s*(?:&quot;.*?&quot;)?\s*\n"/>

    <!--
    	Markup:  private 
    	Applies: Member comments
		Purpose: Recognize members marked as non-modifable via
		             @generated private "... (...)" NL
    	-->
    <merge:dictionaryPattern
      name="privateMembers" 
      select="Member/getComment" 
      match="\s*@\s*generated\s*(private)\s*(?:&quot;.*?&quot;)?\s*\n"/>

    <!-- 
    	Markup:  gen
    	Applies: Initializer Body
    	Purpose: Recognize initializers whose body contains
    	     		// @generated "... (...)" NL
    	Note:    This is necessary because JDOM doesn't associated Javadoc comments
		         with initializers
    	-->
    <merge:dictionaryPattern
      name="generatedInitializer"
      select="Initializer/getBody"
      match="//\s*@\s*(gen)erated\s*(?:&quot;.*?&quot;)?\s*\n"/>

    <!--
        Markup:  ordered 
        Applies: Field comment
		Purpose: Recognized field sorting marker 
		-->
    <merge:dictionaryPattern
      name="orderedMembers" 
      select="Field/getComment" 
      match="\s*@\s*(ordered)\s*\n"/>

    <!-- 
    	Markup:  generated.*user-code | gener
    	Applies: Method contents
    	Purpose: Recognize constructor (actually methods) with user editable sections in the body
    	Note:    The pattern must yield unique markups for the case where there is a user-code block
    	        and cases where there is not. In addition, the no user-code block case must have
    	        a markup that is distinct from other markups (^gen$ for general rules, ^generated$
    	        for no user-doc block. Unfortunately, JMerge doesn't let use be more explicit, but
    	          gen => node has a @generated tag
    	          gener => node is a method/constructor and has no user-code block
    	          generated => node java doc is @generated by has no user-doc block
    	        
    	--> 
    <merge:dictionaryPattern
      name="userCodeConstructor"
      select="Method/getContents"
      match="(?:\s*@\s*(generated\s*(?:&quot;.*?&quot;)?\s*\n.*?\s*//\s*begin-user-code).*?//\s*end-user-code\s*\n)|(?:\s*@\s*(gener)ated\s*(?:&quot;.*?&quot;)?\s*\n)" />

	<!--
		Markup:  user-doc.*generated  | generated.*user-doc | generated
		Applies: Member comment
		Purpose: Recognize javadoc comments that include both @generated and begin-user-doc/end-user-doc
				markers
    	Note:    The pattern must yield unique markups for the case where there is a user-doc block
    	        and cases where there is not. In addition, the no user-code block case must have
    	        a markup that is distinct from other markups (^gen$ for general rules, ^generated$
    	        for no user-doc block. Unfortunately, JMerge doesn't let use be more explicit, but
    	          gen => node has a @generated tag
    	          gener => node is a method/constructor and has no user-code block
    	          generated => node java doc is @generated but has no user-doc block
	-->
    <merge:dictionaryPattern
      name="userDocComment"
      select="Member/getComment"
      match="(?:\s*@\s*(generated\s*(?:&quot;.*?&quot;)?\s*\n.*?&lt;!--\s*begin-user-doc.*?\s*end-user-doc)\s*-->)|(?:&lt;!--\s*begin-(user-doc.*?\s*end-user-doc\s*-->.*?\s*@\s*generated)\s*(?:&quot;.*?&quot;)?\s*\n)|(?:\s*@\s*(generated)\s*(?:&quot;.*?&quot;)?\s*\n)" />

<!-- 
************ IMPORTANT NOTE ABOUT MATCHING Markups ************
	When JMerge uses sourceMarkup or targetMarkup patterns below, it treats ^ and $ as beginning of 
    line and end-of-line, respectively. 
    *** HOWEVER ***, some of the dictionary patterns above yeild multi-line markups (e.g. generated.*user-doc). 
    *** THEREFORE ***, in markup patterns below, you should consider whether your mean ^ or \A (beginning of input),
    and $ or \z (end of input).
    At the point of adding this comment, all of the patterns used \A and \z. You should probably do the same.
-->

  <merge:match
   markup="^gen$"
   get="Method/getName"
   signature="\s*((?:pre|post)Validate)?\w*\s*"/>
  <merge:match
   markup="^gen$"
   get="Method/getComment"
   signature="\s*@\s*uuid\s*(\S*)\s*\n"/>


<!-- PULL RULES 

	These rules transfer elements of the emitted code (JMerge calls this "source") into
	the existing code (JMerge calls this "target").
	
	Without a pull rules, JMerge will only transfer emitted elements that are not already in 
	the existing code.
	-->
	
	<!--
		Markup:  \Agen\z -> \Agenerated\z
		Applies: Member comments
		Purpose: Copy emitted comments to existing generated members who do
				not have begin-user-doc / end-user-doc comments.
	-->
    <merge:pull
      sourceMarkup="\Agen\z"
      sourceGet="Member/getComment"
      targetMarkup="\Agenerated\z"
      targetPut="Member/setComment"/>

	<!--
		Markup:  \Auser-doc.*generated\z|\Agenerated.*user-doc\z
		Purpose: Preserve existing comments between begin-user-doc / end-user-doc
				but update remainder of comment.
	-->
    <merge:pull 
      sourceMarkup="\Auser-doc.*generated\z|\Agenerated.*user-doc\z"
      sourceGet="Member/getComment"
      sourceTransfer="(\s*&lt;!--\s*begin-user-doc.*?end-user-doc\s*-->\s*)"
      targetMarkup="\Auser-doc.*generated\z|\Agenerated.*user-doc\z"
      targetPut="Member/setComment"/>

	<!--
		Markup: \Agen\z -> \Agen\z
		Applies: Member flags
		Purpose: Copy emitted member flags (public, private, static...) to existing
				generated members.
	-->
	<merge:pull
	  sourceMarkup="\Agen\z"
	  targetMarkup="\Agen\z"
	  sourceGet="Member/getFlags"
	  targetPut="Member/setFlags"/>
	  
	<!--
	   Markup:  \Agen\z -> \Agen\z
	   Applies: Field initializers
	   Purpose: Copy emitted initializers to existing fields.
	   -->
	<merge:pull
	  sourceMarkup="\Agen\z"
	  targetMarkup="\Agen\z"
	  sourceGet="Field/getInitializer"
	  targetPut="Field/setInitializer"/>
	  
	<!--
	   Markup:  \Agen\z -> \Agen\z
	   Applies: Field types
	   Purpose: Copy emitted Field types to existing fields.
	   -->
	<merge:pull
	  sourceMarkup="\Agen\z"
	  targetMarkup="\Agen\z"
	  sourceGet="Field/getType"
	  targetPut="Field/setType"/>
	  
	<!--
	   Markup:  \Agen\z -> \Agen\z
	   Applies: Method returntypes
	   Purpose: Copy emitted Method return types to existing methods.
	-->
	<merge:pull
	  sourceMarkup="\Agen\z"
	  targetMarkup="\Agen\z"
	  sourceGet="Method/getReturnType"
	  targetPut="Method/setReturnType"/>

	<!--
	   Markup:  \Agen\z -> \Agen\z
	   Applies: Method declared exceptions
	   Purpose: Copy emitted Method declared exceptions to existing methods.
	-->
	<merge:pull
	  sourceMarkup="\Agen\z"
	  targetMarkup="\Agen\z"
	  sourceGet="Method/getExceptions"
	  targetPut="Method/setExceptions"/>

	<!-- 
		Markup:  \Agen\z -> \Agener\z
		Applies: Method bodies
		Purpose: Copy entire method bodies from emitted code to existing methods
				that have generated tag, but no user-code block
		Note:	 See note for the Pattern "userCodeConstructor" for distinctions between
				\Agen\z, \Agener\z, and \Agenerated\z
	-->
	<merge:pull
	  sourceMarkup="\Agen\z"
	  targetMarkup="\Agener\z"
	  sourceGet="Method/getBody"
	  targetPut="Method/setBody"/>
	  
	<!--
		Markup:  \Agenerated.*user-code\z -> \Agenerated.*user-code\z
		Applies: Method bodies
		Purpose: Copy emitted method bodies to existing code, but preserving existing code
				within the begin-user-code / end-user-code blocks
	-->
	<merge:pull
	  sourceMarkup="\Agenerated.*user-code\z"
	  targetMarkup="\Agenerated.*user-code\z"
      sourceTransfer="(\s*//\s*begin-user-code.*?end-user-code\s*)\n"
	  sourceGet="Method/getBody"
	  targetPut="Method/setBody"/>
	  

	<!--
		Markup:  \Agen\z -> \Agen\z
		Applies  Type class (interface or class keyword)
		Purpose: Copy the emitted type (interface/class) to the existing type marked with @generated
	-->
	<!--
	<merge:pull
	  sourceMarkup="\Agen\z"
	  targetMarkup="\Agen\z"
	  sourceGet="Type/isClass"
	  targetPut="Type/setClass"/>
	-->
	
	<!--
		Markup:  \Agen\z -> \Agen\z
		Applies  Type supertype
		Purpose: Copy the emitted super type to the existing type marked with @generated
	-->
	<merge:pull
	  sourceMarkup="\Agen\z"
	  targetMarkup="\Agen\z"
	  sourceGet="Type/getSuperclass"
	  targetPut="Type/setSuperclass"/>
	  
	<!--
		Markup:  \Agen\z -> \Agen\z
		Applies: Type superInterfaces
		Purpose: Copy emitted super interfaces to existing types marked with @generated
	-->
	<merge:pull
	  sourceMarkup="\Agen\z"
	  targetMarkup="\Agen\z"
	  sourceGet="Type/getSuperInterfaces"
	  targetPut="Type/addSuperInterface"/>
		
	<!--
		Markup:  any
		Applies: Package name
		Purpose: Always update the existing package with the emitted package.
		Note:    This may be an acedemic exercise as a change in the package would result in a change
		         in file location, and we likely wouldn't be doing a re-apply.
	    ****** IMPORTANT ******
	    This rule is disabled for the following reasons:
	      1) its marginal value
	      2) JMerge dies a horrible death if it attempts to merge to/from a default package
	-->
	<!--  DISABLED <merge:pull
	  sourceGet="Package/getName"
	  targetPut="Package/setName"/> -->
	  
<!-- SWEEP RULES 

    These rules remove code from the target (so long as they have the identified markup)
    that were not present in the emitted source. (Presumably, these were once present in the
    emitted source.
    -->
    
    <!--
    	Markup:  gen
    	Purpose: Remove once generated methods that are no longer generated
    	-->
    <merge:sweep markup="\Agen\z" select="Field" action="rename" newName="DELETED_{0}"/>
    <merge:sweep markup="\Agen\z" select="Type" action="rename" newName="DELETED_{0}"/>
    <merge:sweep markup="\Agen\z" select="Method" action="rename" newName="DELETED_{0}"/>
    
    <!--
    	Markup:  private
    	Purpose: Remove once generated methods that are no longer generated
    	-->
    <merge:sweep markup="\Aprivate\z" select="Member" action="rename" newName="DELETED_{0}"/>


<!-- SORT RULES 
	
	These rules cause fields (with the identified markup) to be sorted in the target.
	-->
	
    <merge:sort markup="\Aordered\z" select="Member"/>

</merge:options>
