2013-12-10 19:36:50 +00:00
|
|
|
/* ========================================================================
|
|
|
|
* PlantUML : a free UML diagram generator
|
|
|
|
* ========================================================================
|
|
|
|
*
|
2022-03-07 19:33:46 +00:00
|
|
|
* (C) Copyright 2009-2023, Arnaud Roques
|
2013-12-10 19:36:50 +00:00
|
|
|
*
|
2016-03-06 16:47:34 +00:00
|
|
|
* Project Info: http://plantuml.com
|
2013-12-10 19:36:50 +00:00
|
|
|
*
|
2017-03-15 19:13:31 +00:00
|
|
|
* If you like this project or if you find it useful, you can support us at:
|
|
|
|
*
|
|
|
|
* http://plantuml.com/patreon (only 1$ per month!)
|
|
|
|
* http://plantuml.com/paypal
|
|
|
|
*
|
2013-12-10 19:36:50 +00:00
|
|
|
* This file is part of PlantUML.
|
|
|
|
*
|
|
|
|
* PlantUML is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* PlantUML distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
|
|
|
* License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
|
|
|
* USA.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Original Author: Arnaud Roques
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
package net.sourceforge.plantuml.cucadiagram.entity;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Collection;
|
|
|
|
import java.util.Collections;
|
2020-02-18 21:24:31 +00:00
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.HashSet;
|
2013-12-10 19:36:50 +00:00
|
|
|
import java.util.LinkedHashMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
2020-01-12 22:13:17 +00:00
|
|
|
import java.util.Map.Entry;
|
2021-05-09 21:14:40 +00:00
|
|
|
import java.util.Objects;
|
2013-12-10 19:36:50 +00:00
|
|
|
import java.util.Set;
|
|
|
|
|
2020-02-18 21:24:31 +00:00
|
|
|
import net.sourceforge.plantuml.ISkinParam;
|
|
|
|
import net.sourceforge.plantuml.creole.CreoleMode;
|
2013-12-10 19:36:50 +00:00
|
|
|
import net.sourceforge.plantuml.cucadiagram.Bodier;
|
2022-03-01 18:11:51 +00:00
|
|
|
import net.sourceforge.plantuml.cucadiagram.BodierJSon;
|
2020-04-05 15:13:04 +00:00
|
|
|
import net.sourceforge.plantuml.cucadiagram.BodierMap;
|
2020-12-14 18:31:06 +00:00
|
|
|
import net.sourceforge.plantuml.cucadiagram.BodyFactory;
|
2013-12-10 19:36:50 +00:00
|
|
|
import net.sourceforge.plantuml.cucadiagram.Code;
|
2020-01-12 22:13:17 +00:00
|
|
|
import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
|
2013-12-10 19:36:50 +00:00
|
|
|
import net.sourceforge.plantuml.cucadiagram.Display;
|
|
|
|
import net.sourceforge.plantuml.cucadiagram.GroupRoot;
|
|
|
|
import net.sourceforge.plantuml.cucadiagram.GroupType;
|
2018-03-09 21:37:34 +00:00
|
|
|
import net.sourceforge.plantuml.cucadiagram.HideOrShow2;
|
2013-12-10 19:36:50 +00:00
|
|
|
import net.sourceforge.plantuml.cucadiagram.IEntity;
|
|
|
|
import net.sourceforge.plantuml.cucadiagram.IGroup;
|
|
|
|
import net.sourceforge.plantuml.cucadiagram.ILeaf;
|
2019-12-10 21:45:49 +00:00
|
|
|
import net.sourceforge.plantuml.cucadiagram.Ident;
|
2013-12-10 19:36:50 +00:00
|
|
|
import net.sourceforge.plantuml.cucadiagram.LeafType;
|
|
|
|
import net.sourceforge.plantuml.cucadiagram.Link;
|
2020-02-18 21:24:31 +00:00
|
|
|
import net.sourceforge.plantuml.cucadiagram.SuperGroup;
|
|
|
|
import net.sourceforge.plantuml.graphic.USymbol;
|
2013-12-10 19:36:50 +00:00
|
|
|
import net.sourceforge.plantuml.skin.VisibilityModifier;
|
|
|
|
|
2019-12-10 21:45:49 +00:00
|
|
|
public final class EntityFactory {
|
|
|
|
|
2020-01-12 22:13:17 +00:00
|
|
|
private final Map<String, ILeaf> leafsByCode;
|
|
|
|
private final Map<String, IGroup> groupsByCode;
|
2019-12-10 21:45:49 +00:00
|
|
|
|
2020-01-12 22:13:17 +00:00
|
|
|
/* private */final Map<Ident, ILeaf> leafs2 = new LinkedHashMap<Ident, ILeaf>();
|
|
|
|
/* private */final Map<Ident, IGroup> groups2 = new LinkedHashMap<Ident, IGroup>();
|
2013-12-10 19:36:50 +00:00
|
|
|
|
2021-05-14 08:42:57 +00:00
|
|
|
private final List<Link> links = new ArrayList<>();
|
2019-12-10 21:45:49 +00:00
|
|
|
|
2015-04-07 18:18:37 +00:00
|
|
|
private int rawLayout;
|
2013-12-10 19:36:50 +00:00
|
|
|
|
|
|
|
private final IGroup rootGroup = new GroupRoot(this);
|
2020-02-18 21:24:31 +00:00
|
|
|
private final SuperGroup rootSuperGroup = new SuperGroup(rootGroup);
|
2020-04-05 15:13:04 +00:00
|
|
|
|
2018-03-09 21:37:34 +00:00
|
|
|
private final List<HideOrShow2> hides2;
|
|
|
|
private final List<HideOrShow2> removed;
|
2020-01-12 22:13:17 +00:00
|
|
|
/* private */ final public CucaDiagram namespaceSeparator;
|
2020-02-18 21:24:31 +00:00
|
|
|
// private final boolean mergeIntricated;
|
|
|
|
private Map<IGroup, ILeaf> emptyGroupsAsNode = new HashMap<IGroup, ILeaf>();
|
|
|
|
|
|
|
|
public ILeaf getLeafForEmptyGroup(IGroup g) {
|
|
|
|
return emptyGroupsAsNode.get(g);
|
|
|
|
}
|
|
|
|
|
|
|
|
public SuperGroup getRootSuperGroup() {
|
|
|
|
return rootSuperGroup;
|
|
|
|
}
|
|
|
|
|
|
|
|
private Set<SuperGroup> superGroups = null;
|
|
|
|
final Map<IGroup, SuperGroup> groupToSuper = new LinkedHashMap<IGroup, SuperGroup>();
|
|
|
|
|
|
|
|
public Set<SuperGroup> getAllSuperGroups() {
|
|
|
|
return Collections.unmodifiableSet(superGroups);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void buildSuperGroups() {
|
2021-05-14 08:42:57 +00:00
|
|
|
superGroups = new HashSet<>();
|
2020-02-18 21:24:31 +00:00
|
|
|
for (IGroup g : groups2.values()) {
|
|
|
|
final SuperGroup sg = new SuperGroup(g);
|
|
|
|
superGroups.add(sg);
|
|
|
|
groupToSuper.put(g, sg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public ILeaf createLeafForEmptyGroup(IGroup g, ISkinParam skinParam) {
|
|
|
|
final ILeaf folder = this.createLeaf(g.getIdent(), g.getCode(), g.getDisplay(), LeafType.EMPTY_PACKAGE,
|
|
|
|
g.getParentContainer(), null, this.namespaceSeparator.getNamespaceSeparator());
|
|
|
|
((EntityImpl) folder).setOriginalGroup(g);
|
|
|
|
final USymbol symbol = g.getUSymbol();
|
|
|
|
folder.setUSymbol(symbol);
|
|
|
|
folder.setStereotype(g.getStereotype());
|
2021-11-15 18:27:27 +00:00
|
|
|
folder.setColors(g.getColors());
|
2022-09-14 18:12:03 +00:00
|
|
|
if (g.getUrl99() != null)
|
2020-02-18 21:24:31 +00:00
|
|
|
folder.addUrl(g.getUrl99());
|
2022-09-14 18:12:03 +00:00
|
|
|
|
2022-04-10 19:24:55 +00:00
|
|
|
// if (UseStyle.useBetaStyle()) {
|
|
|
|
// // System.err.println("Backcolor ?");
|
|
|
|
// } else {
|
|
|
|
// if (g.getColors().getColor(ColorType.BACK) == null) {
|
|
|
|
// final ColorParam param = symbol == null ? ColorParam.packageBackground : symbol.getColorParamBack();
|
|
|
|
// final HColor c1 = skinParam.getHtmlColor(param, g.getStereotype(), false);
|
|
|
|
// folder.setSpecificColorTOBEREMOVED(ColorType.BACK, c1 == null ? skinParam.getBackgroundColor() : c1);
|
|
|
|
// } else {
|
|
|
|
// folder.setSpecificColorTOBEREMOVED(ColorType.BACK, g.getColors().getColor(ColorType.BACK));
|
|
|
|
// }
|
|
|
|
// }
|
2020-02-18 21:24:31 +00:00
|
|
|
emptyGroupsAsNode.put(g, folder);
|
|
|
|
return folder;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Display getIntricatedDisplay(Ident ident) {
|
2021-05-14 08:42:57 +00:00
|
|
|
final Set<Ident> known = new HashSet<>(groups2.keySet());
|
2020-02-18 21:24:31 +00:00
|
|
|
known.removeAll(hiddenBecauseOfIntrication);
|
|
|
|
String sep = namespaceSeparator.getNamespaceSeparator();
|
2022-09-14 18:12:03 +00:00
|
|
|
if (sep == null)
|
2020-02-18 21:24:31 +00:00
|
|
|
sep = ".";
|
2022-09-14 18:12:03 +00:00
|
|
|
|
|
|
|
for (int check = ident.size() - 1; check > 0; check--)
|
|
|
|
if (known.contains(ident.getPrefix(check)))
|
|
|
|
// if (hiddenBecauseOfIntrication.contains(ident.getPrefix(check)) == false)
|
2020-02-18 21:24:31 +00:00
|
|
|
return Display.getWithNewlines(ident.getSuffix(check).toString(sep))
|
|
|
|
.withCreoleMode(CreoleMode.SIMPLE_LINE);
|
2022-09-14 18:12:03 +00:00
|
|
|
|
2020-02-18 21:24:31 +00:00
|
|
|
return Display.getWithNewlines(ident.toString(sep)).withCreoleMode(CreoleMode.SIMPLE_LINE);
|
|
|
|
}
|
|
|
|
|
2021-05-14 08:42:57 +00:00
|
|
|
private final Collection<Ident> hiddenBecauseOfIntrication = new ArrayList<>();
|
2020-02-18 21:24:31 +00:00
|
|
|
|
|
|
|
public IGroup isIntricated(IGroup parent) {
|
|
|
|
final int leafs = parent.getLeafsDirect().size();
|
|
|
|
final Collection<IGroup> children = parent.getChildren();
|
|
|
|
if (leafs == 0 && children.size() == 1) {
|
|
|
|
final IGroup g = children.iterator().next();
|
2022-09-14 18:12:03 +00:00
|
|
|
if (g.getLeafsDirect().size() == 0 && g.getChildren().size() == 0 && g.getGroupType() == GroupType.PACKAGE)
|
2020-02-18 21:24:31 +00:00
|
|
|
return null;
|
2022-09-14 18:12:03 +00:00
|
|
|
|
|
|
|
for (Link link : this.getLinks())
|
|
|
|
if (link.contains(parent))
|
2020-02-18 21:24:31 +00:00
|
|
|
return null;
|
2022-09-14 18:12:03 +00:00
|
|
|
|
2020-02-18 21:24:31 +00:00
|
|
|
((EntityImpl) g).setIntricated(true);
|
|
|
|
hiddenBecauseOfIntrication.add(parent.getIdent());
|
|
|
|
return g;
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
2015-04-07 18:18:37 +00:00
|
|
|
|
2020-01-12 22:13:17 +00:00
|
|
|
public EntityFactory(List<HideOrShow2> hides2, List<HideOrShow2> removed, CucaDiagram namespaceSeparator) {
|
2018-03-09 21:37:34 +00:00
|
|
|
this.hides2 = hides2;
|
|
|
|
this.removed = removed;
|
2020-01-12 22:13:17 +00:00
|
|
|
this.namespaceSeparator = namespaceSeparator;
|
2020-02-18 21:24:31 +00:00
|
|
|
// this.mergeIntricated = namespaceSeparator.mergeIntricated();
|
2020-01-12 22:13:17 +00:00
|
|
|
|
|
|
|
// if (OptionFlags.V1972(namespaceSeparator)) {
|
|
|
|
// this.leafsByCode = null;
|
|
|
|
// this.groupsByCode = null;
|
|
|
|
// } else {
|
|
|
|
this.leafsByCode = new LinkedHashMap<String, ILeaf>();
|
|
|
|
this.groupsByCode = new LinkedHashMap<String, IGroup>();
|
|
|
|
// }
|
2015-04-07 18:18:37 +00:00
|
|
|
}
|
|
|
|
|
2016-03-06 16:47:34 +00:00
|
|
|
public boolean isHidden(ILeaf leaf) {
|
2018-03-09 21:37:34 +00:00
|
|
|
boolean hidden = false;
|
2022-09-14 18:12:03 +00:00
|
|
|
for (HideOrShow2 hide : hides2)
|
2018-03-09 21:37:34 +00:00
|
|
|
hidden = hide.apply(hidden, leaf);
|
2022-09-14 18:12:03 +00:00
|
|
|
|
2018-03-09 21:37:34 +00:00
|
|
|
return hidden;
|
|
|
|
}
|
2016-03-06 16:47:34 +00:00
|
|
|
|
2018-03-09 21:37:34 +00:00
|
|
|
public boolean isRemoved(ILeaf leaf) {
|
|
|
|
boolean result = false;
|
2022-09-14 18:12:03 +00:00
|
|
|
for (HideOrShow2 hide : removed)
|
2018-03-09 21:37:34 +00:00
|
|
|
result = hide.apply(result, leaf);
|
2022-09-14 18:12:03 +00:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isRemovedIgnoreUnlinked(ILeaf leaf) {
|
|
|
|
boolean result = false;
|
|
|
|
for (HideOrShow2 hide : removed)
|
|
|
|
if (hide.isAboutUnlinked() == false)
|
|
|
|
result = hide.apply(result, leaf);
|
|
|
|
|
2018-03-09 21:37:34 +00:00
|
|
|
return result;
|
2015-04-07 18:18:37 +00:00
|
|
|
}
|
2013-12-10 19:36:50 +00:00
|
|
|
|
2019-12-10 21:45:49 +00:00
|
|
|
public void thisIsGoingToBeALeaf(Ident ident) {
|
|
|
|
}
|
|
|
|
|
|
|
|
public void thisIsNotArealGroup(Ident ident) {
|
|
|
|
}
|
|
|
|
|
|
|
|
public ILeaf createLeaf(Ident ident, Code code, Display display, LeafType entityType, IGroup parentContainer,
|
2015-04-07 18:18:37 +00:00
|
|
|
Set<VisibilityModifier> hides, String namespaceSeparator) {
|
2021-10-20 16:33:09 +00:00
|
|
|
final Bodier bodier;
|
|
|
|
if (Objects.requireNonNull(entityType) == LeafType.MAP)
|
|
|
|
bodier = new BodierMap();
|
2022-03-01 18:11:51 +00:00
|
|
|
else if (Objects.requireNonNull(entityType) == LeafType.JSON)
|
|
|
|
bodier = new BodierJSon();
|
2021-10-20 16:33:09 +00:00
|
|
|
else
|
|
|
|
bodier = BodyFactory.createLeaf(entityType, hides);
|
|
|
|
|
2019-12-10 21:45:49 +00:00
|
|
|
final EntityImpl result = new EntityImpl(ident, code, this, bodier, parentContainer, entityType,
|
2015-04-07 18:18:37 +00:00
|
|
|
namespaceSeparator, rawLayout);
|
2018-04-06 20:36:30 +00:00
|
|
|
bodier.setLeaf(result);
|
2013-12-10 19:36:50 +00:00
|
|
|
result.setDisplay(display);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2019-12-10 21:45:49 +00:00
|
|
|
public IGroup createGroup(Ident ident, Code code, Display display, Code namespace, GroupType groupType,
|
|
|
|
IGroup parentContainer, Set<VisibilityModifier> hides, String namespaceSeparator) {
|
2021-05-09 21:14:40 +00:00
|
|
|
Objects.requireNonNull(groupType);
|
2022-09-14 18:12:03 +00:00
|
|
|
for (Entry<Ident, IGroup> ent : groups2.entrySet())
|
|
|
|
if (ent.getKey().equals(ident))
|
2020-06-14 20:35:42 +00:00
|
|
|
return ent.getValue();
|
2022-09-14 18:12:03 +00:00
|
|
|
|
2020-12-14 18:31:06 +00:00
|
|
|
final Bodier bodier = BodyFactory.createGroup(hides);
|
2019-12-10 21:45:49 +00:00
|
|
|
final EntityImpl result = new EntityImpl(ident, code, this, bodier, parentContainer, groupType, namespace,
|
2015-04-07 18:18:37 +00:00
|
|
|
namespaceSeparator, rawLayout);
|
2022-09-14 18:12:03 +00:00
|
|
|
if (Display.isNull(display) == false)
|
2013-12-10 19:36:50 +00:00
|
|
|
result.setDisplay(display);
|
2022-09-14 18:12:03 +00:00
|
|
|
|
2019-12-10 21:45:49 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void addLeaf(ILeaf entity) {
|
2020-01-12 22:13:17 +00:00
|
|
|
if (namespaceSeparator.V1972() == false)
|
|
|
|
leafsByCode.put(entity.getCodeGetName(), entity);
|
2019-12-10 21:45:49 +00:00
|
|
|
leafs2.put(entity.getIdent(), entity);
|
2020-01-12 22:13:17 +00:00
|
|
|
if (namespaceSeparator.V1972())
|
|
|
|
ensureParentIsCreated(entity.getIdent());
|
2019-12-10 21:45:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void addGroup(IGroup group) {
|
2020-01-12 22:13:17 +00:00
|
|
|
if (namespaceSeparator.V1972() == false)
|
|
|
|
groupsByCode.put(group.getCodeGetName(), group);
|
2019-12-10 21:45:49 +00:00
|
|
|
groups2.put(group.getIdent(), group);
|
2020-01-12 22:13:17 +00:00
|
|
|
if (namespaceSeparator.V1972())
|
|
|
|
ensureParentIsCreated(group.getIdent());
|
|
|
|
}
|
|
|
|
|
|
|
|
private void ensureParentIsCreated(Ident ident) {
|
|
|
|
if (groups2.get(ident.parent()) != null)
|
|
|
|
return;
|
|
|
|
getParentContainer(ident, null);
|
2019-12-10 21:45:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void removeGroup(String name) {
|
2020-01-12 22:13:17 +00:00
|
|
|
if (namespaceSeparator.V1972())
|
|
|
|
throw new UnsupportedOperationException();
|
2021-05-09 21:14:40 +00:00
|
|
|
final IEntity removed = Objects.requireNonNull(groupsByCode.remove(name));
|
2019-12-10 21:45:49 +00:00
|
|
|
final IEntity removed2 = groups2.remove(removed.getIdent());
|
|
|
|
if (removed != removed2) {
|
|
|
|
bigError();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-12 22:13:17 +00:00
|
|
|
void removeGroup(Ident ident) {
|
2021-05-14 08:42:57 +00:00
|
|
|
Objects.requireNonNull(groups2.remove(Objects.requireNonNull(ident)));
|
2020-01-12 22:13:17 +00:00
|
|
|
}
|
|
|
|
|
2019-12-10 21:45:49 +00:00
|
|
|
public static void bigError() {
|
2020-01-12 22:13:17 +00:00
|
|
|
// Thread.dumpStack();
|
2019-12-10 21:45:49 +00:00
|
|
|
// System.exit(0);
|
|
|
|
// throw new IllegalArgumentException();
|
|
|
|
}
|
|
|
|
|
|
|
|
void removeLeaf(String name) {
|
2020-01-12 22:13:17 +00:00
|
|
|
if (namespaceSeparator.V1972())
|
|
|
|
throw new UnsupportedOperationException();
|
2021-05-14 08:42:57 +00:00
|
|
|
final IEntity removed = Objects.requireNonNull(leafsByCode.remove(Objects.requireNonNull(name)));
|
2019-12-10 21:45:49 +00:00
|
|
|
final IEntity removed2 = leafs2.remove(removed.getIdent());
|
|
|
|
if (removed != removed2) {
|
|
|
|
bigError();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-12 22:13:17 +00:00
|
|
|
void removeLeaf(Ident ident) {
|
2021-05-14 08:42:57 +00:00
|
|
|
final IEntity removed = leafs2.remove(Objects.requireNonNull(ident));
|
2020-01-12 22:13:17 +00:00
|
|
|
if (removed == null) {
|
|
|
|
System.err.println("leafs2=" + leafs2.keySet());
|
|
|
|
throw new IllegalArgumentException(ident.toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void removeLeaf1972(ILeaf leaf) {
|
|
|
|
final boolean removed = leafs2.values().remove(leaf);
|
|
|
|
if (removed == false) {
|
|
|
|
System.err.println("leafs2=" + leafs2.keySet());
|
|
|
|
throw new IllegalArgumentException(leaf.toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-10 21:45:49 +00:00
|
|
|
public IGroup muteToGroup(String name, Code namespace, GroupType type, IGroup parent) {
|
2020-01-12 22:13:17 +00:00
|
|
|
if (namespaceSeparator.V1972())
|
|
|
|
throw new UnsupportedOperationException();
|
2019-12-10 21:45:49 +00:00
|
|
|
final ILeaf leaf = leafsByCode.get(name);
|
|
|
|
((EntityImpl) leaf).muteToGroup(namespace, type, parent);
|
|
|
|
final IGroup result = (IGroup) leaf;
|
|
|
|
removeLeaf(name);
|
2013-12-10 19:36:50 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-01-12 22:13:17 +00:00
|
|
|
public IGroup muteToGroup1972(Ident ident, Code namespace, GroupType type, IGroup parent) {
|
|
|
|
if (!namespaceSeparator.V1972())
|
|
|
|
throw new UnsupportedOperationException();
|
|
|
|
final ILeaf leaf;
|
|
|
|
if (namespaceSeparator.getNamespaceSeparator() == null)
|
|
|
|
leaf = getLeafVerySmart(ident);
|
|
|
|
else
|
|
|
|
leaf = leafs2.get(ident);
|
|
|
|
((EntityImpl) leaf).muteToGroup(namespace, type, parent);
|
|
|
|
final IGroup result = (IGroup) leaf;
|
|
|
|
removeLeaf1972(leaf);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-10 19:36:50 +00:00
|
|
|
public IGroup getRootGroup() {
|
|
|
|
return rootGroup;
|
|
|
|
}
|
|
|
|
|
2020-01-12 22:13:17 +00:00
|
|
|
public final ILeaf getLeafStrict(Ident ident) {
|
2019-12-10 21:45:49 +00:00
|
|
|
return leafs2.get(ident);
|
2018-03-09 21:37:34 +00:00
|
|
|
}
|
|
|
|
|
2020-01-12 22:13:17 +00:00
|
|
|
public final ILeaf getLeafSmart(Ident ident) {
|
|
|
|
if (!namespaceSeparator.V1972())
|
|
|
|
throw new UnsupportedOperationException();
|
|
|
|
final ILeaf result = leafs2.get(ident);
|
2022-09-14 18:12:03 +00:00
|
|
|
if (result == null && ident.size() == 1)
|
|
|
|
for (Entry<Ident, ILeaf> ent : leafs2.entrySet())
|
|
|
|
if (ent.getKey().getLast().equals(ident.getLast()))
|
2020-01-12 22:13:17 +00:00
|
|
|
return ent.getValue();
|
2022-09-14 18:12:03 +00:00
|
|
|
|
2020-01-12 22:13:17 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final ILeaf getLeafVerySmart(Ident ident) {
|
|
|
|
if (!namespaceSeparator.V1972())
|
|
|
|
throw new UnsupportedOperationException();
|
|
|
|
final ILeaf result = leafs2.get(ident);
|
2022-09-14 18:12:03 +00:00
|
|
|
if (result == null)
|
|
|
|
for (Entry<Ident, ILeaf> ent : leafs2.entrySet())
|
|
|
|
if (ent.getKey().getLast().equals(ident.getLast()))
|
2020-01-12 22:13:17 +00:00
|
|
|
return ent.getValue();
|
2022-09-14 18:12:03 +00:00
|
|
|
|
2020-01-12 22:13:17 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Ident buildFullyQualified(Ident currentPath, Ident id) {
|
2022-09-14 18:12:03 +00:00
|
|
|
if (currentPath.equals(id) == false)
|
|
|
|
if (leafs2.containsKey(id) || groups2.containsKey(id))
|
2020-01-12 22:13:17 +00:00
|
|
|
return id;
|
2022-09-14 18:12:03 +00:00
|
|
|
|
|
|
|
if (id.size() > 1)
|
2020-01-12 22:13:17 +00:00
|
|
|
return id;
|
2022-09-14 18:12:03 +00:00
|
|
|
|
2020-01-12 22:13:17 +00:00
|
|
|
return currentPath.add(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
public final IGroup getGroupStrict(Ident ident) {
|
2022-09-14 18:12:03 +00:00
|
|
|
if (namespaceSeparator.getNamespaceSeparator() == null)
|
2020-01-12 22:13:17 +00:00
|
|
|
return getGroupVerySmart(ident);
|
2022-09-14 18:12:03 +00:00
|
|
|
|
2020-01-12 22:13:17 +00:00
|
|
|
final IGroup result = groups2.get(ident);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final IGroup getGroupVerySmart(Ident ident) {
|
|
|
|
final IGroup result = groups2.get(ident);
|
2022-09-14 18:12:03 +00:00
|
|
|
if (result == null)
|
|
|
|
for (Entry<Ident, IGroup> ent : groups2.entrySet())
|
|
|
|
if (ent.getKey().getLast().equals(ident.getLast()))
|
2020-01-12 22:13:17 +00:00
|
|
|
return ent.getValue();
|
2022-09-14 18:12:03 +00:00
|
|
|
|
2020-01-12 22:13:17 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2019-12-10 21:45:49 +00:00
|
|
|
public final ILeaf getLeaf(Code code) {
|
2020-01-12 22:13:17 +00:00
|
|
|
if (namespaceSeparator.V1972())
|
|
|
|
throw new UnsupportedOperationException();
|
2019-12-10 21:45:49 +00:00
|
|
|
final ILeaf result = leafsByCode.get(code.getName());
|
2022-09-14 18:12:03 +00:00
|
|
|
if (result != null && result != leafs2.get(result.getIdent()))
|
2019-12-10 21:45:49 +00:00
|
|
|
bigError();
|
2022-09-14 18:12:03 +00:00
|
|
|
|
2019-12-10 21:45:49 +00:00
|
|
|
return result;
|
2013-12-10 19:36:50 +00:00
|
|
|
}
|
|
|
|
|
2019-12-10 21:45:49 +00:00
|
|
|
public final IGroup getGroup(Code code) {
|
2020-01-12 22:13:17 +00:00
|
|
|
if (namespaceSeparator.V1972())
|
|
|
|
throw new UnsupportedOperationException();
|
2019-12-10 21:45:49 +00:00
|
|
|
final IGroup result = groupsByCode.get(code.getName());
|
2022-09-14 18:12:03 +00:00
|
|
|
if (result != null && result != groups2.get(result.getIdent()))
|
2019-12-10 21:45:49 +00:00
|
|
|
bigError();
|
2022-09-14 18:12:03 +00:00
|
|
|
|
2019-12-10 21:45:49 +00:00
|
|
|
return result;
|
2013-12-10 19:36:50 +00:00
|
|
|
}
|
|
|
|
|
2019-12-10 21:45:49 +00:00
|
|
|
public final Collection<ILeaf> leafs() {
|
2020-01-12 22:13:17 +00:00
|
|
|
if (namespaceSeparator.V1972())
|
|
|
|
return leafs2();
|
2019-12-10 21:45:49 +00:00
|
|
|
final Collection<ILeaf> result = Collections.unmodifiableCollection(leafsByCode.values());
|
2022-09-14 18:12:03 +00:00
|
|
|
if (new ArrayList<>(result).equals(new ArrayList<>(leafs2())) == false)
|
2019-12-10 21:45:49 +00:00
|
|
|
bigError();
|
2022-09-14 18:12:03 +00:00
|
|
|
|
2019-12-10 21:45:49 +00:00
|
|
|
return result;
|
2013-12-10 19:36:50 +00:00
|
|
|
}
|
|
|
|
|
2019-12-10 21:45:49 +00:00
|
|
|
public final Collection<IGroup> groups() {
|
2020-01-12 22:13:17 +00:00
|
|
|
if (namespaceSeparator.V1972())
|
|
|
|
return groups2();
|
2019-12-10 21:45:49 +00:00
|
|
|
final Collection<IGroup> result = Collections.unmodifiableCollection(groupsByCode.values());
|
2022-09-14 18:12:03 +00:00
|
|
|
if (new ArrayList<>(result).equals(new ArrayList<>(groups2())) == false)
|
2019-12-10 21:45:49 +00:00
|
|
|
bigError();
|
2022-09-14 18:12:03 +00:00
|
|
|
|
2019-12-10 21:45:49 +00:00
|
|
|
return result;
|
2013-12-10 19:36:50 +00:00
|
|
|
}
|
|
|
|
|
2019-12-10 21:45:49 +00:00
|
|
|
public final Collection<IGroup> groups2() {
|
|
|
|
final Collection<IGroup> result = Collections.unmodifiableCollection(groups2.values());
|
|
|
|
return Collections.unmodifiableCollection(result);
|
2013-12-10 19:36:50 +00:00
|
|
|
}
|
|
|
|
|
2019-12-10 21:45:49 +00:00
|
|
|
public final Collection<ILeaf> leafs2() {
|
|
|
|
final Collection<ILeaf> result = Collections.unmodifiableCollection(leafs2.values());
|
|
|
|
return Collections.unmodifiableCollection(result);
|
2018-03-09 21:37:34 +00:00
|
|
|
}
|
|
|
|
|
2019-12-10 21:45:49 +00:00
|
|
|
public void incRawLayout() {
|
|
|
|
rawLayout++;
|
2013-12-10 19:36:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public final List<Link> getLinks() {
|
|
|
|
return Collections.unmodifiableList(links);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void addLink(Link link) {
|
2022-09-14 18:12:03 +00:00
|
|
|
if (link.isSingle() && containsSimilarLink(link))
|
2018-11-26 18:46:22 +00:00
|
|
|
return;
|
2022-09-14 18:12:03 +00:00
|
|
|
|
2013-12-10 19:36:50 +00:00
|
|
|
links.add(link);
|
|
|
|
}
|
|
|
|
|
2018-11-26 18:46:22 +00:00
|
|
|
private boolean containsSimilarLink(Link other) {
|
2022-09-14 18:12:03 +00:00
|
|
|
for (Link link : links)
|
|
|
|
if (other.sameConnections(link))
|
2018-11-26 18:46:22 +00:00
|
|
|
return true;
|
2022-09-14 18:12:03 +00:00
|
|
|
|
2018-11-26 18:46:22 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-12-10 19:36:50 +00:00
|
|
|
public void removeLink(Link link) {
|
|
|
|
final boolean ok = links.remove(link);
|
2022-09-14 18:12:03 +00:00
|
|
|
if (ok == false)
|
2013-12-10 19:36:50 +00:00
|
|
|
throw new IllegalArgumentException();
|
2022-09-14 18:12:03 +00:00
|
|
|
|
2013-12-10 19:36:50 +00:00
|
|
|
}
|
|
|
|
|
2019-12-10 21:45:49 +00:00
|
|
|
public IGroup getParentContainer(Ident ident, IGroup parentContainer) {
|
2020-01-12 22:13:17 +00:00
|
|
|
if (namespaceSeparator.V1972()) {
|
|
|
|
final Ident parent = ident.parent();
|
2022-09-14 18:12:03 +00:00
|
|
|
if (parent.isRoot())
|
2020-01-12 22:13:17 +00:00
|
|
|
return this.rootGroup;
|
2022-09-14 18:12:03 +00:00
|
|
|
|
2020-01-12 22:13:17 +00:00
|
|
|
IGroup result = getGroupStrict(parent);
|
2022-09-14 18:12:03 +00:00
|
|
|
if (result != null)
|
2020-01-12 22:13:17 +00:00
|
|
|
return result;
|
2022-09-14 18:12:03 +00:00
|
|
|
|
2020-02-18 21:24:31 +00:00
|
|
|
final Display display = Display.getWithNewlines(parent.getName());
|
|
|
|
result = createGroup(parent, parent, display, null, GroupType.PACKAGE, null,
|
|
|
|
Collections.<VisibilityModifier>emptySet(), namespaceSeparator.getNamespaceSeparator());
|
2020-01-12 22:13:17 +00:00
|
|
|
addGroup(result);
|
|
|
|
return result;
|
|
|
|
}
|
2021-05-09 21:14:40 +00:00
|
|
|
return Objects.requireNonNull(parentContainer);
|
2013-12-10 19:36:50 +00:00
|
|
|
}
|
|
|
|
|
2022-08-29 16:21:06 +00:00
|
|
|
public CucaDiagram getDiagram() {
|
|
|
|
return namespaceSeparator;
|
|
|
|
}
|
|
|
|
|
2013-12-10 19:36:50 +00:00
|
|
|
}
|