Ptidej-v5.2-master/SAD/src/sad/designsmell/detection/repository/RefusedParentBequest/RefusedParentBequestDetection.java
/*******************************************************************************
 * Copyright (c) 2001-2014 Yann-Gal Guhneuc and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v2.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * 
 * Contributors:
 *     Yann-Gal Guhneuc and others, see in file; API and its implementation
 ******************************************************************************/
package sad.designsmell.detection.repository.RefusedParentBequest;

/**
 * This class implements the detection algorithms 
 * of the design smell RefusedParentBequest.
 * 
 * @author Autogenerated files
 * 
 */

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

import padl.kernel.IAbstractLevelModel;
import sad.codesmell.detection.repository.RefusedParentBequest.*;
import sad.kernel.ICodeSmell;
import sad.codesmell.detection.ICodeSmellDetection;
import sad.designsmell.detection.IDesignSmellDetection;
import sad.designsmell.detection.repository.AbstractDesignSmellDetection;
import sad.kernel.impl.DesignSmell;
import sad.util.OperatorsCodeSmells;
import sad.util.Relationships;

public class RefusedParentBequestDetection extends AbstractDesignSmellDetection implements IDesignSmellDetection {
	private final OperatorsCodeSmells operators;
	private final Relationships relations;

	public RefusedParentBequestDetection() {
		super();

		this.operators = OperatorsCodeSmells.getInstance();
		this.relations = Relationships.getInstance();
	}
	
	public String getName() {
		return "RefusedParentBequest";
	}

	public String getRuleCardFile() {
		return "../SAD Rules Creator/rsc/RefusedParentBequest.rules";
	}

	
public void detect(final IAbstractLevelModel anAbstractLevelModel) {
final Set candidateDesignSmells = new HashSet();

final ICodeSmellDetection csRareOverriding = new RareOverridingDetection();
csRareOverriding.detect(anAbstractLevelModel);
final Set setRareOverriding = ((RareOverridingDetection) csRareOverriding).getCodeSmells();

final ICodeSmellDetection csParentClassProvidesProtected = new ParentClassProvidesProtectedDetection();
csParentClassProvidesProtected.detect(anAbstractLevelModel);
final Set setParentClassProvidesProtected = ((ParentClassProvidesProtectedDetection) csParentClassProvidesProtected).getCodeSmells();

final Set setRefusedParentBequest = this.relations.checkAssociationOneToOne(4, setParentClassProvidesProtected,  setRareOverriding);

final Iterator iterSet = setRefusedParentBequest.iterator();
while(iterSet.hasNext()) {
final ICodeSmell aCodeSmell = (ICodeSmell) iterSet.next();
final DesignSmell designSmell = new DesignSmell(aCodeSmell);
designSmell.setName("RefusedParentBequest");
final String definition = "To defined";
designSmell.setDefinition(definition);
candidateDesignSmells.add(designSmell);
}
this.setSetOfDesignSmells(candidateDesignSmells);
}
}
