Skip to main content
summaryrefslogtreecommitdiffstats
blob: d336fd955d16f93c62c3e741c639cfaabc5cd281 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
/*******************************************************************************
 * Copyright (c) 2012, 2013 Obeo.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     Obeo - initial API and implementation
 *******************************************************************************/
package org.eclipse.emf.compare.postprocessor;

import com.google.common.collect.ImmutableList;

import java.util.regex.Pattern;

import org.eclipse.emf.common.util.Monitor;
import org.eclipse.emf.compare.Comparison;
import org.eclipse.emf.compare.scope.IComparisonScope;

/**
 * Implementations of this interface can be used in order to tell EMF Compare how to make post treatments at
 * each step of the comparison.
 * 
 * @author <a href="mailto:cedric.notot@obeo.fr">Cedric Notot</a>
 */
public interface IPostProcessor {

	/**
	 * This will be called by EMF Compare in order to execute the specified behavior after the match step,
	 * from a <code>comparison</code>.
	 * 
	 * @param comparison
	 *            The comparison after the match step.
	 * @param monitor
	 *            The monitor to report progress or to check for cancellation
	 * @since 3.0
	 */
	void postMatch(Comparison comparison, Monitor monitor);

	/**
	 * This will be called by EMF Compare in order to execute the specified behavior after the difference
	 * step, from a <code>comparison</code>.
	 * 
	 * @param comparison
	 *            The comparison after the difference step.
	 * @param monitor
	 *            The monitor to report progress or to check for cancellation
	 * @since 3.0
	 */
	void postDiff(Comparison comparison, Monitor monitor);

	/**
	 * This will be called by EMF Compare in order to execute the specified behavior after the requirements
	 * step, from a <code>comparison</code>.
	 * 
	 * @param comparison
	 *            The comparison after the requirements step.
	 * @param monitor
	 *            The monitor to report progress or to check for cancellation
	 * @since 3.0
	 */
	void postRequirements(Comparison comparison, Monitor monitor);

	/**
	 * This will be called by EMF Compare in order to execute the specified behavior after the equivalences
	 * step, from a <code>comparison</code>.
	 * 
	 * @param comparison
	 *            The comparison after the equivalences step.
	 * @param monitor
	 *            The monitor to report progress or to check for cancellation
	 * @since 3.0
	 */
	void postEquivalences(Comparison comparison, Monitor monitor);

	/**
	 * This will be called by EMF Compare in order to execute the specified behavior after the conflicts step,
	 * from a <code>comparison</code>.
	 * 
	 * @param comparison
	 *            The comparison after the conflicts step.
	 * @param monitor
	 *            The monitor to report progress or to check for cancellation
	 * @since 3.0
	 */
	void postConflicts(Comparison comparison, Monitor monitor);

	/**
	 * This will be called by EMF Compare in order to execute the specified behavior after a comparison, from
	 * a <code>comparison</code>.
	 * 
	 * @param comparison
	 *            The comparison after the all steps.
	 * @param monitor
	 *            The monitor to report progress or to check for cancellation
	 * @since 3.0
	 */
	void postComparison(Comparison comparison, Monitor monitor);

	/**
	 * Wrapper describing the given post processor.
	 * 
	 * @author <a href="mailto:mikael.barbero@obeo.fr">Mikael Barbero</a>
	 */
	interface Descriptor {
		/**
		 * Returns the wrapped post processor.
		 * 
		 * @return the wrapped post processor
		 */
		IPostProcessor getPostProcessor();

		/**
		 * Returns the pattern of namespace URI on which this post processor can be applied.
		 * 
		 * @return The namespace URI pattern.
		 */
		Pattern getNsURI();

		/**
		 * Returns the pattern of resource URI on which this post processor can be applied.
		 * 
		 * @return The resource URI.
		 */
		Pattern getResourceURI();

		/**
		 * Returns the class name of the instance that will be returned by {@link #getPostProcessor()}.
		 * 
		 * @return the class name of the instance that will be returned by {@link #getPostProcessor()}.
		 */
		String getInstanceClassName();

		/**
		 * Registry of post processor.
		 * 
		 * @author <a href="mailto:mikael.barbero@obeo.fr">Mikael Barbero</a>
		 */
		public interface Registry<K> {

			/**
			 * Adds a post processor to the registry.
			 * 
			 * @param key
			 *            key with which the specified descriptor is to be associated
			 * @param descriptor
			 *            Post Processor that is to be added to this registry.
			 * @return the previous descriptor associated with <tt>key</tt>, or <tt>null</tt> if there was no
			 *         mapping for <tt>key</tt>. (A <tt>null</tt> return can also indicate that the map
			 *         previously associated <tt>null</tt> with <tt>key</tt>, if the implementation supports
			 *         <tt>null</tt> values.)
			 */
			IPostProcessor.Descriptor put(K key, IPostProcessor.Descriptor descriptor);

			/**
			 * Removes all extensions from this registry.
			 * 
			 * @noreference This method is not intended to be referenced by clients.
			 */
			void clear();

			/**
			 * This will return a copy of the registered post processors list.
			 * 
			 * @return A copy of the registered post processors list.
			 */
			ImmutableList<IPostProcessor.Descriptor> getDescriptors();

			/**
			 * Removes a post processor from this registry.
			 * 
			 * @param key
			 *            key of the post processor descriptor that is to be removed from the registry.
			 * @return the previous value associated with <tt>key</tt>, or <tt>null</tt> if there was no
			 *         mapping for <tt>key</tt>.
			 */
			IPostProcessor.Descriptor remove(K key);

			/**
			 * Retrieve the post processors from a given <code>scope</code>. The scope provides the set of
			 * scanned namespaces and resource uris. If they match with the regex of some post processors,
			 * then tey are returned.
			 * 
			 * @param scope
			 *            The given scope.
			 * @return The associated post processors if any.
			 */
			ImmutableList<IPostProcessor> getPostProcessors(IComparisonScope scope);
		}
	}
}

Back to the top