001/*
002 * Copyright c 2018 Rusi Popov, MDA Tools.net All rights reserved.
003 *
004 * This program and the accompanying materials are made available under the terms of the
005 * Eclipse Public License v2.0 which accompanies this distribution, and is available at
006 * http://www.eclipse.org/legal/epl-v20.html
007 */
008package net.mdatools.modelant.core.operation.model.match;
009
010import javax.jmi.reflect.RefObject;
011import javax.jmi.reflect.RefPackage;
012
013import net.mdatools.modelant.core.api.Selector;
014import net.mdatools.modelant.core.api.match.ConsideredEqual;
015import net.mdatools.modelant.core.selector.SelectByQualifiedName;
016
017/**
018 * A pair of correspondent classes in the metamodels to compare, that should be considered equal
019 * Used as <metaclass> element in the plugin's configuration.
020 * @author Rusi Popov (popovr@mdatools.net)
021 */
022public class Equal implements ConsideredEqual {
023
024  /**
025   * Qualified name of the source class in the metamodel
026   * @parameter
027   * @required
028   */
029  private String source;
030
031  /**
032   * Qualified name of the target class in the metamodel
033   * @parameter
034   * @required
035   */
036  private String target;
037
038  /**
039   * Instantiate the Equal class initialized. Useful for internal purposes, like testing.
040   * @param source
041   * @param target
042   */
043  public Equal(String source, String target) {
044    this.source = source;
045    this.target = target;
046  }
047
048
049  /**
050   * Used by MAVEN - it will take care to initialize the fields before instance's use.
051   */
052  public Equal() {
053  }
054
055
056  /**
057   * @see net.mdatools.modelant.core.api.match.ConsideredEqual#selectNew()
058   */
059  public Selector<RefPackage, RefObject> selectNew() {
060    return new SelectByQualifiedName(target);
061  }
062
063
064  /**
065   * @see net.mdatools.modelant.core.api.match.ConsideredEqual#selectOld()
066   */
067  public Selector<RefPackage, RefObject> selectOld() {
068    return new SelectByQualifiedName(source);
069  }
070}