net.sourceforge.plantuml.mda.MDADiagramImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of plantuml-mit Show documentation
Show all versions of plantuml-mit Show documentation
PlantUML is a component that allows to quickly write diagrams from text.
// THIS FILE HAS BEEN GENERATED BY A PREPROCESSOR.
package net.sourceforge.plantuml.mda;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import net.sourceforge.plantuml.BlockUml;
import net.sourceforge.plantuml.SourceStringReader;
import net.sourceforge.plantuml.abel.Entity;
import net.sourceforge.plantuml.abel.EntityFactory;
import net.sourceforge.plantuml.api.mda.option2.MDADiagram;
import net.sourceforge.plantuml.api.mda.option2.MDAPackage;
import net.sourceforge.plantuml.classdiagram.ClassDiagram;
import net.sourceforge.plantuml.core.Diagram;
public class MDADiagramImpl implements MDADiagram {
// ::remove folder when __CORE__
public static MDADiagram create(String uml) {
List blocks = new SourceStringReader(uml).getBlocks();
if (blocks.size() == 0) {
uml = "@startuml\n" + uml + "\n@enduml";
blocks = new SourceStringReader(uml).getBlocks();
if (blocks.size() == 0) {
return null;
}
}
final BlockUml block = blocks.get(0);
final Diagram diagram = block.getDiagram();
if (diagram instanceof ClassDiagram) {
return new MDADiagramImpl((ClassDiagram) diagram);
}
return null;
}
private final Collection packages = new ArrayList<>();
private MDADiagramImpl(ClassDiagram classDiagram) {
final EntityFactory entityFactory = classDiagram.getEntityFactory();
packages.add(new MDAPackageImpl(entityFactory.getRootGroup()));
for (Entity group : entityFactory.groups()) {
packages.add(new MDAPackageImpl(group));
}
}
public Collection getPackages() {
return Collections.unmodifiableCollection(packages);
}
}