1 package org.eclipse.aether.util.graph.transformer;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.ArrayList;
23 import java.util.Arrays;
24 import java.util.Collection;
25 import java.util.Collections;
26 import java.util.HashMap;
27 import java.util.HashSet;
28 import java.util.IdentityHashMap;
29 import java.util.Iterator;
30 import java.util.List;
31 import java.util.ListIterator;
32 import java.util.Map;
33
34 import org.eclipse.aether.RepositoryException;
35 import org.eclipse.aether.RepositorySystemSession;
36 import org.eclipse.aether.artifact.Artifact;
37 import org.eclipse.aether.collection.DependencyGraphTransformationContext;
38 import org.eclipse.aether.collection.DependencyGraphTransformer;
39 import org.eclipse.aether.graph.DefaultDependencyNode;
40 import org.eclipse.aether.graph.Dependency;
41 import org.eclipse.aether.graph.DependencyNode;
42 import org.eclipse.aether.util.ConfigUtils;
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64 public final class ConflictResolver
65 implements DependencyGraphTransformer
66 {
67
68
69
70
71
72 public static final String CONFIG_PROP_VERBOSE = "aether.conflictResolver.verbose";
73
74
75
76
77
78 public static final String NODE_DATA_WINNER = "conflict.winner";
79
80
81
82
83
84 public static final String NODE_DATA_ORIGINAL_SCOPE = "conflict.originalScope";
85
86
87
88
89
90 public static final String NODE_DATA_ORIGINAL_OPTIONALITY = "conflict.originalOptionality";
91
92 private final VersionSelector versionSelector;
93
94 private final ScopeSelector scopeSelector;
95
96 private final ScopeDeriver scopeDeriver;
97
98 private final OptionalitySelector optionalitySelector;
99
100
101
102
103
104
105
106
107
108 public ConflictResolver( VersionSelector versionSelector, ScopeSelector scopeSelector,
109 OptionalitySelector optionalitySelector, ScopeDeriver scopeDeriver )
110 {
111 if ( versionSelector == null )
112 {
113 throw new IllegalArgumentException( "version selector not specified" );
114 }
115 this.versionSelector = versionSelector;
116 if ( scopeSelector == null )
117 {
118 throw new IllegalArgumentException( "scope selector not specified" );
119 }
120 this.scopeSelector = scopeSelector;
121 if ( scopeDeriver == null )
122 {
123 throw new IllegalArgumentException( "scope deriver not specified" );
124 }
125 this.scopeDeriver = scopeDeriver;
126 if ( optionalitySelector == null )
127 {
128 throw new IllegalArgumentException( "optionality selector not specified" );
129 }
130 this.optionalitySelector = optionalitySelector;
131 }
132
133 public DependencyNode transformGraph( DependencyNode node, DependencyGraphTransformationContext context )
134 throws RepositoryException
135 {
136 List<?> sortedConflictIds = (List<?>) context.get( TransformationContextKeys.SORTED_CONFLICT_IDS );
137 if ( sortedConflictIds == null )
138 {
139 ConflictIdSorter sorter = new ConflictIdSorter();
140 sorter.transformGraph( node, context );
141
142 sortedConflictIds = (List<?>) context.get( TransformationContextKeys.SORTED_CONFLICT_IDS );
143 }
144
145 @SuppressWarnings( "unchecked" )
146 Map<String, Object> stats = (Map<String, Object>) context.get( TransformationContextKeys.STATS );
147 long time1 = System.currentTimeMillis();
148
149 @SuppressWarnings( "unchecked" )
150 Collection<Collection<?>> conflictIdCycles =
151 (Collection<Collection<?>>) context.get( TransformationContextKeys.CYCLIC_CONFLICT_IDS );
152 if ( conflictIdCycles == null )
153 {
154 throw new RepositoryException( "conflict id cycles have not been identified" );
155 }
156
157 Map<?, ?> conflictIds = (Map<?, ?>) context.get( TransformationContextKeys.CONFLICT_IDS );
158 if ( conflictIds == null )
159 {
160 throw new RepositoryException( "conflict groups have not been identified" );
161 }
162
163 Map<Object, Collection<Object>> cyclicPredecessors = new HashMap<Object, Collection<Object>>();
164 for ( Collection<?> cycle : conflictIdCycles )
165 {
166 for ( Object conflictId : cycle )
167 {
168 Collection<Object> predecessors = cyclicPredecessors.get( conflictId );
169 if ( predecessors == null )
170 {
171 predecessors = new HashSet<Object>();
172 cyclicPredecessors.put( conflictId, predecessors );
173 }
174 predecessors.addAll( cycle );
175 }
176 }
177
178 State state = new State( node, conflictIds, sortedConflictIds.size(), context );
179 for ( Iterator<?> it = sortedConflictIds.iterator(); it.hasNext(); )
180 {
181 Object conflictId = it.next();
182
183
184 state.prepare( conflictId, cyclicPredecessors.get( conflictId ) );
185
186
187 gatherConflictItems( node, state );
188
189
190 state.finish();
191
192
193 if ( !state.items.isEmpty() )
194 {
195 ConflictContext ctx = state.conflictCtx;
196 state.versionSelector.selectVersion( ctx );
197 if ( ctx.winner == null )
198 {
199 throw new RepositoryException( "conflict resolver did not select winner among " + state.items );
200 }
201 DependencyNode winner = ctx.winner.node;
202
203 state.scopeSelector.selectScope( ctx );
204 if ( state.verbose )
205 {
206 winner.setData( NODE_DATA_ORIGINAL_SCOPE, winner.getDependency().getScope() );
207 }
208 winner.setScope( ctx.scope );
209
210 state.optionalitySelector.selectOptionality( ctx );
211 if ( state.verbose )
212 {
213 winner.setData( NODE_DATA_ORIGINAL_OPTIONALITY, winner.getDependency().isOptional() );
214 }
215 winner.setOptional( ctx.optional );
216
217 removeLosers( state );
218 }
219
220
221 state.winner();
222
223
224 if ( !it.hasNext() && !conflictIdCycles.isEmpty() && state.conflictCtx.winner != null )
225 {
226 DependencyNode winner = state.conflictCtx.winner.node;
227 state.prepare( state, null );
228 gatherConflictItems( winner, state );
229 }
230 }
231
232 if ( stats != null )
233 {
234 long time2 = System.currentTimeMillis();
235 stats.put( "ConflictResolver.totalTime", time2 - time1 );
236 stats.put( "ConflictResolver.conflictItemCount", state.totalConflictItems );
237 }
238
239 return node;
240 }
241
242 private boolean gatherConflictItems( DependencyNode node, State state )
243 throws RepositoryException
244 {
245 Object conflictId = state.conflictIds.get( node );
246 if ( state.currentId.equals( conflictId ) )
247 {
248
249 state.add( node );
250
251 }
252 else if ( state.loser( node, conflictId ) )
253 {
254
255 return false;
256 }
257 else if ( state.push( node, conflictId ) )
258 {
259
260 for ( Iterator<DependencyNode> it = node.getChildren().iterator(); it.hasNext(); )
261 {
262 DependencyNode child = it.next();
263 if ( !gatherConflictItems( child, state ) )
264 {
265 it.remove();
266 }
267 }
268 state.pop();
269 }
270 return true;
271 }
272
273 private void removeLosers( State state )
274 {
275 ConflictItem winner = state.conflictCtx.winner;
276 List<DependencyNode> previousParent = null;
277 ListIterator<DependencyNode> childIt = null;
278 boolean conflictVisualized = false;
279 for ( ConflictItem item : state.items )
280 {
281 if ( item == winner )
282 {
283 continue;
284 }
285 if ( item.parent != previousParent )
286 {
287 childIt = item.parent.listIterator();
288 previousParent = item.parent;
289 conflictVisualized = false;
290 }
291 while ( childIt.hasNext() )
292 {
293 DependencyNode child = childIt.next();
294 if ( child == item.node )
295 {
296 if ( state.verbose && !conflictVisualized && item.parent != winner.parent )
297 {
298 conflictVisualized = true;
299 DependencyNode loser = new DefaultDependencyNode( child );
300 loser.setData( NODE_DATA_WINNER, winner.node );
301 loser.setData( NODE_DATA_ORIGINAL_SCOPE, loser.getDependency().getScope() );
302 loser.setData( NODE_DATA_ORIGINAL_OPTIONALITY, loser.getDependency().isOptional() );
303 loser.setScope( item.getScopes().iterator().next() );
304 loser.setChildren( Collections.<DependencyNode>emptyList() );
305 childIt.set( loser );
306 }
307 else
308 {
309 childIt.remove();
310 }
311 break;
312 }
313 }
314 }
315
316
317 }
318
319 static final class NodeInfo
320 {
321
322
323
324
325 int minDepth;
326
327
328
329
330
331
332 Object derivedScopes;
333
334
335
336
337
338
339 int derivedOptionalities;
340
341
342
343
344
345 List<ConflictItem> children;
346
347 static final int CHANGE_SCOPE = 0x01;
348
349 static final int CHANGE_OPTIONAL = 0x02;
350
351 private static final int OPT_FALSE = 0x01;
352
353 private static final int OPT_TRUE = 0x02;
354
355 NodeInfo( int depth, String derivedScope, boolean optional )
356 {
357 minDepth = depth;
358 derivedScopes = derivedScope;
359 derivedOptionalities = optional ? OPT_TRUE : OPT_FALSE;
360 }
361
362 @SuppressWarnings( "unchecked" )
363 int update( int depth, String derivedScope, boolean optional )
364 {
365 if ( depth < minDepth )
366 {
367 minDepth = depth;
368 }
369 int changes;
370 if ( derivedScopes.equals( derivedScope ) )
371 {
372 changes = 0;
373 }
374 else if ( derivedScopes instanceof Collection )
375 {
376 changes = ( (Collection<String>) derivedScopes ).add( derivedScope ) ? CHANGE_SCOPE : 0;
377 }
378 else
379 {
380 Collection<String> scopes = new HashSet<String>();
381 scopes.add( (String) derivedScopes );
382 scopes.add( derivedScope );
383 derivedScopes = scopes;
384 changes = CHANGE_SCOPE;
385 }
386 int bit = optional ? OPT_TRUE : OPT_FALSE;
387 if ( ( derivedOptionalities & bit ) == 0 )
388 {
389 derivedOptionalities |= bit;
390 changes |= CHANGE_OPTIONAL;
391 }
392 return changes;
393 }
394
395 void add( ConflictItem item )
396 {
397 if ( children == null )
398 {
399 children = new ArrayList<ConflictItem>( 1 );
400 }
401 children.add( item );
402 }
403
404 }
405
406 final class State
407 {
408
409
410
411
412 Object currentId;
413
414
415
416
417 int totalConflictItems;
418
419
420
421
422 final boolean verbose;
423
424
425
426
427
428 final Map<Object, DependencyNode> resolvedIds;
429
430
431
432
433
434
435 final Collection<Object> potentialAncestorIds;
436
437
438
439
440 final Map<?, ?> conflictIds;
441
442
443
444
445 final List<ConflictItem> items;
446
447
448
449
450
451 final Map<List<DependencyNode>, NodeInfo> infos;
452
453
454
455
456
457 final Map<List<DependencyNode>, Object> stack;
458
459
460
461
462 final List<DependencyNode> parentNodes;
463
464
465
466
467 final List<String> parentScopes;
468
469
470
471
472 final List<Boolean> parentOptionals;
473
474
475
476
477
478 final List<NodeInfo> parentInfos;
479
480
481
482
483
484 final ConflictContext conflictCtx;
485
486
487
488
489
490 final ScopeContext scopeCtx;
491
492
493
494
495 final VersionSelector versionSelector;
496
497
498
499
500 final ScopeSelector scopeSelector;
501
502
503
504
505 final ScopeDeriver scopeDeriver;
506
507
508
509
510 final OptionalitySelector optionalitySelector;
511
512 State( DependencyNode root, Map<?, ?> conflictIds, int conflictIdCount,
513 DependencyGraphTransformationContext context )
514 throws RepositoryException
515 {
516 this.conflictIds = conflictIds;
517 verbose = ConfigUtils.getBoolean( context.getSession(), false, CONFIG_PROP_VERBOSE );
518 potentialAncestorIds = new HashSet<Object>( conflictIdCount * 2 );
519 resolvedIds = new HashMap<Object, DependencyNode>( conflictIdCount * 2 );
520 items = new ArrayList<ConflictItem>( 256 );
521 infos = new IdentityHashMap<List<DependencyNode>, NodeInfo>( 64 );
522 stack = new IdentityHashMap<List<DependencyNode>, Object>( 64 );
523 parentNodes = new ArrayList<DependencyNode>( 64 );
524 parentScopes = new ArrayList<String>( 64 );
525 parentOptionals = new ArrayList<Boolean>( 64 );
526 parentInfos = new ArrayList<NodeInfo>( 64 );
527 conflictCtx = new ConflictContext( root, conflictIds, items );
528 scopeCtx = new ScopeContext( null, null );
529 versionSelector = ConflictResolver.this.versionSelector.getInstance( root, context );
530 scopeSelector = ConflictResolver.this.scopeSelector.getInstance( root, context );
531 scopeDeriver = ConflictResolver.this.scopeDeriver.getInstance( root, context );
532 optionalitySelector = ConflictResolver.this.optionalitySelector.getInstance( root, context );
533 }
534
535 void prepare( Object conflictId, Collection<Object> cyclicPredecessors )
536 {
537 currentId = conflictCtx.conflictId = conflictId;
538 conflictCtx.winner = null;
539 conflictCtx.scope = null;
540 conflictCtx.optional = null;
541 items.clear();
542 infos.clear();
543 if ( cyclicPredecessors != null )
544 {
545 potentialAncestorIds.addAll( cyclicPredecessors );
546 }
547 }
548
549 void finish()
550 {
551 List<DependencyNode> previousParent = null;
552 int previousDepth = 0;
553 totalConflictItems += items.size();
554 for ( int i = items.size() - 1; i >= 0; i-- )
555 {
556 ConflictItem item = items.get( i );
557 if ( item.parent == previousParent )
558 {
559 item.depth = previousDepth;
560 }
561 else if ( item.parent != null )
562 {
563 previousParent = item.parent;
564 NodeInfo info = infos.get( previousParent );
565 previousDepth = info.minDepth + 1;
566 item.depth = previousDepth;
567 }
568 }
569 potentialAncestorIds.add( currentId );
570 }
571
572 void winner()
573 {
574 resolvedIds.put( currentId, ( conflictCtx.winner != null ) ? conflictCtx.winner.node : null );
575 }
576
577 boolean loser( DependencyNode node, Object conflictId )
578 {
579 DependencyNode winner = resolvedIds.get( conflictId );
580 return winner != null && winner != node;
581 }
582
583 boolean push( DependencyNode node, Object conflictId )
584 throws RepositoryException
585 {
586 if ( conflictId == null )
587 {
588 if ( node.getDependency() != null )
589 {
590 if ( node.getData().get( NODE_DATA_WINNER ) != null )
591 {
592 return false;
593 }
594 throw new RepositoryException( "missing conflict id for node " + node );
595 }
596 }
597 else if ( !potentialAncestorIds.contains( conflictId ) )
598 {
599 return false;
600 }
601
602 List<DependencyNode> graphNode = node.getChildren();
603 if ( stack.put( graphNode, Boolean.TRUE ) != null )
604 {
605 return false;
606 }
607
608 int depth = depth();
609 String scope = deriveScope( node, conflictId );
610 boolean optional = deriveOptional( node, conflictId );
611 NodeInfo info = infos.get( graphNode );
612 if ( info == null )
613 {
614 info = new NodeInfo( depth, scope, optional );
615 infos.put( graphNode, info );
616 parentInfos.add( info );
617 parentNodes.add( node );
618 parentScopes.add( scope );
619 parentOptionals.add( optional );
620 }
621 else
622 {
623 int changes = info.update( depth, scope, optional );
624 if ( changes == 0 )
625 {
626 stack.remove( graphNode );
627 return false;
628 }
629 parentInfos.add( null );
630 parentNodes.add( node );
631 parentScopes.add( scope );
632 parentOptionals.add( optional );
633 if ( info.children != null )
634 {
635 if ( ( changes & NodeInfo.CHANGE_SCOPE ) != 0 )
636 {
637 for ( int i = info.children.size() - 1; i >= 0; i-- )
638 {
639 ConflictItem item = info.children.get( i );
640 String childScope = deriveScope( item.node, null );
641 item.addScope( childScope );
642 }
643 }
644 if ( ( changes & NodeInfo.CHANGE_OPTIONAL ) != 0 )
645 {
646 for ( int i = info.children.size() - 1; i >= 0; i-- )
647 {
648 ConflictItem item = info.children.get( i );
649 boolean childOptional = deriveOptional( item.node, null );
650 item.addOptional( childOptional );
651 }
652 }
653 }
654 }
655
656 return true;
657 }
658
659 void pop()
660 {
661 int last = parentInfos.size() - 1;
662 parentInfos.remove( last );
663 parentScopes.remove( last );
664 parentOptionals.remove( last );
665 DependencyNode node = parentNodes.remove( last );
666 stack.remove( node.getChildren() );
667 }
668
669 void add( DependencyNode node )
670 throws RepositoryException
671 {
672 DependencyNode parent = parent();
673 if ( parent == null )
674 {
675 ConflictItem item = newConflictItem( parent, node );
676 items.add( item );
677 }
678 else
679 {
680 NodeInfo info = parentInfos.get( parentInfos.size() - 1 );
681 if ( info != null )
682 {
683 ConflictItem item = newConflictItem( parent, node );
684 info.add( item );
685 items.add( item );
686 }
687 }
688 }
689
690 private ConflictItem newConflictItem( DependencyNode parent, DependencyNode node )
691 throws RepositoryException
692 {
693 return new ConflictItem( parent, node, deriveScope( node, null ), deriveOptional( node, null ) );
694 }
695
696 private int depth()
697 {
698 return parentNodes.size();
699 }
700
701 private DependencyNode parent()
702 {
703 int size = parentNodes.size();
704 return ( size <= 0 ) ? null : parentNodes.get( size - 1 );
705 }
706
707 private String deriveScope( DependencyNode node, Object conflictId )
708 throws RepositoryException
709 {
710 if ( ( node.getManagedBits() & DependencyNode.MANAGED_SCOPE ) != 0
711 || ( conflictId != null && resolvedIds.containsKey( conflictId ) ) )
712 {
713 return scope( node.getDependency() );
714 }
715
716 int depth = parentNodes.size();
717 scopes( depth, node.getDependency() );
718 if ( depth > 0 )
719 {
720 scopeDeriver.deriveScope( scopeCtx );
721 }
722 return scopeCtx.derivedScope;
723 }
724
725 private void scopes( int parent, Dependency child )
726 {
727 scopeCtx.parentScope = ( parent > 0 ) ? parentScopes.get( parent - 1 ) : null;
728 scopeCtx.derivedScope = scopeCtx.childScope = scope( child );
729 }
730
731 private String scope( Dependency dependency )
732 {
733 return ( dependency != null ) ? dependency.getScope() : null;
734 }
735
736 private boolean deriveOptional( DependencyNode node, Object conflictId )
737 {
738 Dependency dep = node.getDependency();
739 boolean optional = ( dep != null ) ? dep.isOptional() : false;
740 if ( optional || ( node.getManagedBits() & DependencyNode.MANAGED_OPTIONAL ) != 0
741 || ( conflictId != null && resolvedIds.containsKey( conflictId ) ) )
742 {
743 return optional;
744 }
745 int depth = parentNodes.size();
746 return ( depth > 0 ) ? parentOptionals.get( depth - 1 ) : false;
747 }
748
749 }
750
751
752
753
754
755
756
757
758 public static final class ScopeContext
759 {
760
761 String parentScope;
762
763 String childScope;
764
765 String derivedScope;
766
767
768
769
770
771
772
773
774
775 public ScopeContext( String parentScope, String childScope )
776 {
777 this.parentScope = ( parentScope != null ) ? parentScope : "";
778 derivedScope = this.childScope = ( childScope != null ) ? childScope : "";
779 }
780
781
782
783
784
785
786
787 public String getParentScope()
788 {
789 return parentScope;
790 }
791
792
793
794
795
796
797
798 public String getChildScope()
799 {
800 return childScope;
801 }
802
803
804
805
806
807
808
809 public String getDerivedScope()
810 {
811 return derivedScope;
812 }
813
814
815
816
817
818
819 public void setDerivedScope( String derivedScope )
820 {
821 this.derivedScope = ( derivedScope != null ) ? derivedScope : "";
822 }
823
824 }
825
826
827
828
829
830
831
832 public static final class ConflictItem
833 {
834
835
836 final List<DependencyNode> parent;
837
838
839 final Artifact artifact;
840
841 final DependencyNode node;
842
843 int depth;
844
845
846 Object scopes;
847
848
849 int optionalities;
850
851
852
853
854 public static final int OPTIONAL_FALSE = 0x01;
855
856
857
858
859 public static final int OPTIONAL_TRUE = 0x02;
860
861 ConflictItem( DependencyNode parent, DependencyNode node, String scope, boolean optional )
862 {
863 if ( parent != null )
864 {
865 this.parent = parent.getChildren();
866 this.artifact = parent.getArtifact();
867 }
868 else
869 {
870 this.parent = null;
871 this.artifact = null;
872 }
873 this.node = node;
874 this.scopes = scope;
875 this.optionalities = optional ? OPTIONAL_TRUE : OPTIONAL_FALSE;
876 }
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891 public ConflictItem( DependencyNode parent, DependencyNode node, int depth, int optionalities, String... scopes )
892 {
893 this.parent = ( parent != null ) ? parent.getChildren() : null;
894 this.artifact = ( parent != null ) ? parent.getArtifact() : null;
895 this.node = node;
896 this.depth = depth;
897 this.optionalities = optionalities;
898 this.scopes = Arrays.asList( scopes );
899 }
900
901
902
903
904
905
906
907 public boolean isSibling( ConflictItem item )
908 {
909 return parent == item.parent;
910 }
911
912
913
914
915
916
917 public DependencyNode getNode()
918 {
919 return node;
920 }
921
922
923
924
925
926
927 public Dependency getDependency()
928 {
929 return node.getDependency();
930 }
931
932
933
934
935
936
937
938
939 public int getDepth()
940 {
941 return depth;
942 }
943
944
945
946
947
948
949
950
951 @SuppressWarnings( "unchecked" )
952 public Collection<String> getScopes()
953 {
954 if ( scopes instanceof String )
955 {
956 return Collections.singleton( (String) scopes );
957 }
958 return (Collection<String>) scopes;
959 }
960
961 @SuppressWarnings( "unchecked" )
962 void addScope( String scope )
963 {
964 if ( scopes instanceof Collection )
965 {
966 ( (Collection<String>) scopes ).add( scope );
967 }
968 else if ( !scopes.equals( scope ) )
969 {
970 Collection<Object> set = new HashSet<Object>();
971 set.add( scopes );
972 set.add( scope );
973 scopes = set;
974 }
975 }
976
977
978
979
980
981
982
983
984
985 public int getOptionalities()
986 {
987 return optionalities;
988 }
989
990 void addOptional( boolean optional )
991 {
992 optionalities |= optional ? OPTIONAL_TRUE : OPTIONAL_FALSE;
993 }
994
995 @Override
996 public String toString()
997 {
998 return node + " @ " + depth + " < " + artifact;
999 }
1000
1001 }
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011 public static final class ConflictContext
1012 {
1013
1014 final DependencyNode root;
1015
1016 final Map<?, ?> conflictIds;
1017
1018 final Collection<ConflictItem> items;
1019
1020 Object conflictId;
1021
1022 ConflictItem winner;
1023
1024 String scope;
1025
1026 Boolean optional;
1027
1028 ConflictContext( DependencyNode root, Map<?, ?> conflictIds, Collection<ConflictItem> items )
1029 {
1030 this.root = root;
1031 this.conflictIds = conflictIds;
1032 this.items = Collections.unmodifiableCollection( items );
1033 }
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046 public ConflictContext( DependencyNode root, Object conflictId, Map<DependencyNode, Object> conflictIds,
1047 Collection<ConflictItem> items )
1048 {
1049 this( root, conflictIds, items );
1050 this.conflictId = conflictId;
1051 }
1052
1053
1054
1055
1056
1057
1058 public DependencyNode getRoot()
1059 {
1060 return root;
1061 }
1062
1063
1064
1065
1066
1067
1068
1069 public boolean isIncluded( DependencyNode node )
1070 {
1071 return conflictId.equals( conflictIds.get( node ) );
1072 }
1073
1074
1075
1076
1077
1078
1079 public Collection<ConflictItem> getItems()
1080 {
1081 return items;
1082 }
1083
1084
1085
1086
1087
1088
1089 public ConflictItem getWinner()
1090 {
1091 return winner;
1092 }
1093
1094
1095
1096
1097
1098
1099 public void setWinner( ConflictItem winner )
1100 {
1101 this.winner = winner;
1102 }
1103
1104
1105
1106
1107
1108
1109 public String getScope()
1110 {
1111 return scope;
1112 }
1113
1114
1115
1116
1117
1118
1119 public void setScope( String scope )
1120 {
1121 this.scope = scope;
1122 }
1123
1124
1125
1126
1127
1128
1129 public Boolean getOptional()
1130 {
1131 return optional;
1132 }
1133
1134
1135
1136
1137
1138
1139 public void setOptional( Boolean optional )
1140 {
1141 this.optional = optional;
1142 }
1143
1144 @Override
1145 public String toString()
1146 {
1147 return winner + " @ " + scope + " < " + items;
1148 }
1149
1150 }
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160 public abstract static class VersionSelector
1161 {
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177 public VersionSelector getInstance( DependencyNode root, DependencyGraphTransformationContext context )
1178 throws RepositoryException
1179 {
1180 return this;
1181 }
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192 public abstract void selectVersion( ConflictContext context )
1193 throws RepositoryException;
1194
1195 }
1196
1197
1198
1199
1200
1201
1202
1203
1204 public abstract static class ScopeSelector
1205 {
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221 public ScopeSelector getInstance( DependencyNode root, DependencyGraphTransformationContext context )
1222 throws RepositoryException
1223 {
1224 return this;
1225 }
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236 public abstract void selectScope( ConflictContext context )
1237 throws RepositoryException;
1238
1239 }
1240
1241
1242
1243
1244
1245
1246
1247 public abstract static class ScopeDeriver
1248 {
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264 public ScopeDeriver getInstance( DependencyNode root, DependencyGraphTransformationContext context )
1265 throws RepositoryException
1266 {
1267 return this;
1268 }
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278 public abstract void deriveScope( ScopeContext context )
1279 throws RepositoryException;
1280
1281 }
1282
1283
1284
1285
1286
1287
1288
1289
1290 public abstract static class OptionalitySelector
1291 {
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307 public OptionalitySelector getInstance( DependencyNode root, DependencyGraphTransformationContext context )
1308 throws RepositoryException
1309 {
1310 return this;
1311 }
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322 public abstract void selectOptionality( ConflictContext context )
1323 throws RepositoryException;
1324
1325 }
1326
1327 }