Ignore:
Timestamp:
2016-11-26T21:28:20+01:00 (2 years ago)
Author:
Don-vip
Message:

refactor conflict classes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/command/conflict/RelationMemberConflictResolverCommand.java

    r10413 r11318  
    1111
    1212import org.openstreetmap.josm.Main;
     13import org.openstreetmap.josm.data.conflict.Conflict;
    1314import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1415import org.openstreetmap.josm.data.osm.Relation;
     
    1920/**
    2021 * Represents the resolution of conflicts in the member list of two {@link Relation}s.
    21  *
     22 * @since 1631
    2223 */
    2324public class RelationMemberConflictResolverCommand extends ConflictResolveCommand {
    24     /** my relation */
    25     private final Relation my;
    26     /** their relation */
    27     private final Relation their;
    28     /** the list of merged nodes. This becomes the list of news of my way after the
    29      *  command is executed
    30      */
     25    /** the conflict to resolve */
     26    private final Conflict<Relation> conflict;
     27    /** the list of merged nodes. This becomes the list of news of my way after the command is executed */
    3128    private final List<RelationMember> mergedMembers;
    3229
    3330    /**
    34      *
    35      * @param my my relation
    36      * @param their their relation
     31     * Constructs a new {@code RelationMemberConflictResolverCommand}.
     32     * @param conflict the conflict to resolve
    3733     * @param mergedMembers the list of merged relation members
    3834     */
    39     public RelationMemberConflictResolverCommand(Relation my, Relation their, List<RelationMember> mergedMembers) {
    40         this.my = my;
    41         this.their = their;
     35    @SuppressWarnings("unchecked")
     36    public RelationMemberConflictResolverCommand(Conflict<? extends OsmPrimitive> conflict, List<RelationMember> mergedMembers) {
     37        this.conflict = (Conflict<Relation>) conflict;
    4238        this.mergedMembers = mergedMembers;
    4339    }
     
    4541    @Override
    4642    public String getDescriptionText() {
    47         return tr("Resolve conflicts in member list of relation {0}", my.getId());
     43        return tr("Resolve conflicts in member list of relation {0}", conflict.getMy().getId());
    4844    }
    4945
     
    6157        // replace the list of members of 'my' relation by the list of merged members
    6258        //
    63         my.setMembers(mergedMembers);
     59        conflict.getMy().setMembers(mergedMembers);
    6460
    6561        return true;
     
    6965    public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted,
    7066            Collection<OsmPrimitive> added) {
    71         modified.add(my);
     67        modified.add(conflict.getMy());
    7268    }
    7369
     
    9288        // restore a conflict if necessary
    9389        //
    94         if (!editLayer.getConflicts().hasConflictForMy(my)) {
    95             editLayer.getConflicts().add(my, their);
     90        if (!editLayer.getConflicts().hasConflictForMy(conflict.getMy())) {
     91            editLayer.getConflicts().add(conflict);
    9692        }
    9793    }
     
    9995    @Override
    10096    public int hashCode() {
    101         return Objects.hash(super.hashCode(), my, their, mergedMembers);
     97        return Objects.hash(super.hashCode(), conflict, mergedMembers);
    10298    }
    10399
     
    108104        if (!super.equals(obj)) return false;
    109105        RelationMemberConflictResolverCommand that = (RelationMemberConflictResolverCommand) obj;
    110         return Objects.equals(my, that.my) &&
    111                 Objects.equals(their, that.their) &&
    112                 Objects.equals(mergedMembers, that.mergedMembers);
     106        return Objects.equals(conflict, that.conflict) &&
     107               Objects.equals(mergedMembers, that.mergedMembers);
    113108    }
    114109}
Note: See TracChangeset for help on using the changeset viewer.