blob: 4ec3c495e150b5ade7c69a4715c1dea188808d20 [file] [log] [blame]
/*****************************************************************************
* Copyright (c) 2019 CEA LIST.
*
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Xavier Le Pallec (for CEA LIST) xlepallec@lilo.org - Bug 558456
*
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.clazz.lf.classtextualedition.classcompartments;
import org.eclipse.papyrus.uml.diagram.clazz.lf.classtextualedition.Activator;
import org.eclipse.papyrus.uml.diagram.clazz.lf.classtextualedition.mapping.jsonstructures.JsonUmlClass;
import org.eclipse.papyrus.uml.diagram.common.editparts.ClassEditPart;
public class ExpanderFactory {
private static ExpanderFactory instance;
private static final Activator LOGGER = Activator.getDefault();
/**
* This method returns the instance (singleton) to use as a factory.
*
* @return instance/factory
*/
public static ExpanderFactory getInstance() {
if (instance == null) {
instance = new ExpanderFactory();
}
return instance;
}
private ExpanderFactory() {
}
/**
* The class Expanding needs 2 parameters to create an instance, see
* {@link ExpanderFactory#createExpanding(ClassEditPart, JsonUmlClass)}. Here the value of
* the UmlClass (textual definition of the class) is null, so to not consider
*
* @param classEditPart
* class(EditPart) to expand
* @return the instance of Expanding set with the previous parameters
*/
public ClassExpander createExpanding(ClassEditPart classEditPart) {
if (classEditPart == null) {
LOGGER.logNullParameter("classEditPart"); //$NON-NLS-1$
return null;
} else {
return new ClassExpander(classEditPart);
}
}
/**
* This method creates an instance of Expanding and uses two parameters: a class
* edit part and the textual definition of the class. That means that there is a
* textual definition of the class to consider.
*
* @param classEditPart
* the class to "expand".
* @param theClass
* the textual definition of the class
* @return the instance of Expanding set with the previous parameters
*/
public ClassExpander createExpanding(ClassEditPart classEditPart, JsonUmlClass theClass) {
if (classEditPart == null) {
LOGGER.logNullParameter("classEditPart"); //$NON-NLS-1$
return null;
} else if (theClass == null) {
LOGGER.logNullParameter("theClass"); //$NON-NLS-1$
return null;
} else {
return new ClassExpander(classEditPart, theClass);
}
}
}