From b5a41851ae16ced03fb570bac67fb30a9e522bd0 Mon Sep 17 00:00:00 2001 From: Steve Hickman Date: Fri, 16 Feb 2024 07:34:46 -0800 Subject: [PATCH] Create com.epistimis.uddl.utils package This moves several preexisting utility classes and adds some new ones Includes changes in import statements to account for change of package --- .../uddl/tests/UddlParsingTest.xtend | 2 +- .../EntityRealizationProposalProcessor.java | 2 +- .../uddl/ui/contentassist/PropUtils.java | 2 +- .../contentassist/UddlProposalProvider.java | 2 +- com.epistimis.uddl/META-INF/MANIFEST.MF | 1 + .../com/epistimis/uddl/EntityProcessor.java | 2 +- .../epistimis/uddl/RealizationProcessor.java | 2 +- .../com/epistimis/uddl/TaxonomyProcessor.java | 3 +- .../src/com/epistimis/uddl/UddlQNP.java | 2 +- .../com/epistimis/uddl/UddlRuntimeModule.java | 2 +- .../ConceptualComposableElementExt.java | 2 +- .../uddl/extension/UddlElementExt.java | 2 +- .../uddl/scoping/UddlScopeProvider.java | 1 + .../uddl/unrolled/UnrolledAssociation.java | 2 +- .../uddl/unrolled/UnrolledComposition.java | 2 +- .../uddl/unrolled/UnrolledEntity.java | 2 +- .../uddl/unrolled/UnrolledParticipant.java | 2 +- .../uddl/unrolled/UnrollingFactory.java | 2 +- .../{scoping => util}/IndexUtilities.xtend | 4 +- .../uddl/{ => util}/NavigationUtilities.java | 4 +- .../uddl/{ => util}/NestedCollection.java | 2 +- .../src/com/epistimis/uddl/util/Pair.java | 79 +++++++++++++++++++ .../uddl/{ => util}/ResourceUtils.java | 2 +- .../src/com/epistimis/uddl/util/Triplet.java | 66 ++++++++++++++++ 24 files changed, 171 insertions(+), 21 deletions(-) rename com.epistimis.uddl/src/com/epistimis/uddl/{scoping => util}/IndexUtilities.xtend (99%) rename com.epistimis.uddl/src/com/epistimis/uddl/{ => util}/NavigationUtilities.java (96%) rename com.epistimis.uddl/src/com/epistimis/uddl/{ => util}/NestedCollection.java (98%) create mode 100644 com.epistimis.uddl/src/com/epistimis/uddl/util/Pair.java rename com.epistimis.uddl/src/com/epistimis/uddl/{ => util}/ResourceUtils.java (96%) create mode 100644 com.epistimis.uddl/src/com/epistimis/uddl/util/Triplet.java diff --git a/com.epistimis.uddl.tests/src/com/epistimis/uddl/tests/UddlParsingTest.xtend b/com.epistimis.uddl.tests/src/com/epistimis/uddl/tests/UddlParsingTest.xtend index 082e16d..fb8e341 100644 --- a/com.epistimis.uddl.tests/src/com/epistimis/uddl/tests/UddlParsingTest.xtend +++ b/com.epistimis.uddl.tests/src/com/epistimis/uddl/tests/UddlParsingTest.xtend @@ -6,7 +6,7 @@ */ package com.epistimis.uddl.tests -import com.epistimis.uddl.scoping.IndexUtilities +import com.epistimis.uddl.util.IndexUtilities import com.epistimis.uddl.uddl.DataModel import com.epistimis.uddl.uddl.UddlPackage import com.google.inject.Inject diff --git a/com.epistimis.uddl.ui/src/com/epistimis/uddl/ui/contentassist/EntityRealizationProposalProcessor.java b/com.epistimis.uddl.ui/src/com/epistimis/uddl/ui/contentassist/EntityRealizationProposalProcessor.java index caa8d81..7fabb82 100644 --- a/com.epistimis.uddl.ui/src/com/epistimis/uddl/ui/contentassist/EntityRealizationProposalProcessor.java +++ b/com.epistimis.uddl.ui/src/com/epistimis/uddl/ui/contentassist/EntityRealizationProposalProcessor.java @@ -23,7 +23,7 @@ import com.epistimis.uddl.EntityProcessor; import com.epistimis.uddl.RealizationProcessor; import com.epistimis.uddl.UddlQNP; -import com.epistimis.uddl.scoping.IndexUtilities; +import com.epistimis.uddl.util.IndexUtilities; import com.epistimis.uddl.uddl.UddlElement; import com.google.inject.Inject; diff --git a/com.epistimis.uddl.ui/src/com/epistimis/uddl/ui/contentassist/PropUtils.java b/com.epistimis.uddl.ui/src/com/epistimis/uddl/ui/contentassist/PropUtils.java index c69442e..54c5665 100644 --- a/com.epistimis.uddl.ui/src/com/epistimis/uddl/ui/contentassist/PropUtils.java +++ b/com.epistimis.uddl.ui/src/com/epistimis/uddl/ui/contentassist/PropUtils.java @@ -22,7 +22,7 @@ import org.eclipse.xtext.ui.editor.hover.IEObjectHover; import com.epistimis.uddl.UddlQNP; -import com.epistimis.uddl.scoping.IndexUtilities; +import com.epistimis.uddl.util.IndexUtilities; import com.google.inject.Inject; /** diff --git a/com.epistimis.uddl.ui/src/com/epistimis/uddl/ui/contentassist/UddlProposalProvider.java b/com.epistimis.uddl.ui/src/com/epistimis/uddl/ui/contentassist/UddlProposalProvider.java index 79f5e4e..82c0100 100644 --- a/com.epistimis.uddl.ui/src/com/epistimis/uddl/ui/contentassist/UddlProposalProvider.java +++ b/com.epistimis.uddl.ui/src/com/epistimis/uddl/ui/contentassist/UddlProposalProvider.java @@ -29,7 +29,7 @@ import com.epistimis.uddl.LogicalEntityProcessor; import com.epistimis.uddl.PlatformEntityProcessor; import com.epistimis.uddl.UddlQNP; -import com.epistimis.uddl.scoping.IndexUtilities; +import com.epistimis.uddl.util.IndexUtilities; import com.epistimis.uddl.uddl.LogicalComposition; import com.epistimis.uddl.uddl.LogicalEntity; import com.epistimis.uddl.uddl.LogicalMeasurement; diff --git a/com.epistimis.uddl/META-INF/MANIFEST.MF b/com.epistimis.uddl/META-INF/MANIFEST.MF index 0aaee85..a5e406b 100644 --- a/com.epistimis.uddl/META-INF/MANIFEST.MF +++ b/com.epistimis.uddl/META-INF/MANIFEST.MF @@ -40,5 +40,6 @@ Export-Package: com.epistimis.uddl, com.epistimis.uddl.uddl.impl, com.epistimis.uddl.uddl.util, com.epistimis.uddl.unrolled, + com.epistimis.uddl.util, com.epistimis.uddl.validation Import-Package: org.apache.log4j diff --git a/com.epistimis.uddl/src/com/epistimis/uddl/EntityProcessor.java b/com.epistimis.uddl/src/com/epistimis/uddl/EntityProcessor.java index 6792656..526a76e 100644 --- a/com.epistimis.uddl/src/com/epistimis/uddl/EntityProcessor.java +++ b/com.epistimis.uddl/src/com/epistimis/uddl/EntityProcessor.java @@ -30,7 +30,7 @@ //import com.epistimis.face.face.UopPortableComponent; import com.epistimis.uddl.exceptions.CharacteristicNotFoundException; -import com.epistimis.uddl.scoping.IndexUtilities; +import com.epistimis.uddl.util.IndexUtilities; import com.epistimis.uddl.uddl.UddlElement; import com.google.inject.Inject; diff --git a/com.epistimis.uddl/src/com/epistimis/uddl/RealizationProcessor.java b/com.epistimis.uddl/src/com/epistimis/uddl/RealizationProcessor.java index c4b5c4a..46f79df 100644 --- a/com.epistimis.uddl/src/com/epistimis/uddl/RealizationProcessor.java +++ b/com.epistimis.uddl/src/com/epistimis/uddl/RealizationProcessor.java @@ -19,7 +19,7 @@ import org.eclipse.xtext.naming.IQualifiedNameConverter; import org.eclipse.xtext.naming.IQualifiedNameProvider; -import com.epistimis.uddl.scoping.IndexUtilities; +import com.epistimis.uddl.util.IndexUtilities; import com.epistimis.uddl.uddl.UddlElement; import com.google.inject.Inject; diff --git a/com.epistimis.uddl/src/com/epistimis/uddl/TaxonomyProcessor.java b/com.epistimis.uddl/src/com/epistimis/uddl/TaxonomyProcessor.java index 877f1c1..29363c2 100644 --- a/com.epistimis.uddl/src/com/epistimis/uddl/TaxonomyProcessor.java +++ b/com.epistimis.uddl/src/com/epistimis/uddl/TaxonomyProcessor.java @@ -22,8 +22,9 @@ import com.epistimis.uddl.exceptions.NameCollisionException; import com.epistimis.uddl.exceptions.NamedObjectNotFoundException; -import com.epistimis.uddl.scoping.IndexUtilities; +import com.epistimis.uddl.util.IndexUtilities; import com.epistimis.uddl.uddl.Taxonomy; +import com.epistimis.uddl.util.NavigationUtilities; import com.google.inject.Inject; /** diff --git a/com.epistimis.uddl/src/com/epistimis/uddl/UddlQNP.java b/com.epistimis.uddl/src/com/epistimis/uddl/UddlQNP.java index 9db776b..c005e75 100644 --- a/com.epistimis.uddl/src/com/epistimis/uddl/UddlQNP.java +++ b/com.epistimis.uddl/src/com/epistimis/uddl/UddlQNP.java @@ -16,7 +16,7 @@ import org.eclipse.xtext.naming.QualifiedName; //import org.eclipse.xtext.xbase.scoping.XbaseQualifiedNameProvider; -import com.epistimis.uddl.scoping.IndexUtilities; +import com.epistimis.uddl.util.IndexUtilities; import com.epistimis.uddl.uddl.ConceptualCharacteristic; import com.epistimis.uddl.uddl.ConceptualCompositeQuery; import com.epistimis.uddl.uddl.ConceptualEntity; diff --git a/com.epistimis.uddl/src/com/epistimis/uddl/UddlRuntimeModule.java b/com.epistimis.uddl/src/com/epistimis/uddl/UddlRuntimeModule.java index 415dd06..15c9995 100644 --- a/com.epistimis.uddl/src/com/epistimis/uddl/UddlRuntimeModule.java +++ b/com.epistimis.uddl/src/com/epistimis/uddl/UddlRuntimeModule.java @@ -17,7 +17,7 @@ import com.epistimis.uddl.extension.ConceptualEntityExt; import com.epistimis.uddl.extension.ConceptualObservableExt; import com.epistimis.uddl.extension.UddlElementExt; -import com.epistimis.uddl.scoping.IndexUtilities; +import com.epistimis.uddl.util.IndexUtilities; import com.epistimis.uddl.scoping.UddlPackageProvider; import com.epistimis.uddl.scoping.UddlGlobalScopeProvider; import com.epistimis.uddl.scoping.UddlResourceDescriptionStrategy; diff --git a/com.epistimis.uddl/src/com/epistimis/uddl/extension/ConceptualComposableElementExt.java b/com.epistimis.uddl/src/com/epistimis/uddl/extension/ConceptualComposableElementExt.java index 834627f..917c004 100644 --- a/com.epistimis.uddl/src/com/epistimis/uddl/extension/ConceptualComposableElementExt.java +++ b/com.epistimis.uddl/src/com/epistimis/uddl/extension/ConceptualComposableElementExt.java @@ -7,7 +7,7 @@ import org.eclipse.emf.ecore.EObject; -import com.epistimis.uddl.scoping.IndexUtilities; +import com.epistimis.uddl.util.IndexUtilities; import com.epistimis.uddl.uddl.ConceptualComposableElement; import com.epistimis.uddl.uddl.ConceptualEntity; import com.epistimis.uddl.uddl.ConceptualObservable; diff --git a/com.epistimis.uddl/src/com/epistimis/uddl/extension/UddlElementExt.java b/com.epistimis.uddl/src/com/epistimis/uddl/extension/UddlElementExt.java index ac2d23e..673931a 100644 --- a/com.epistimis.uddl/src/com/epistimis/uddl/extension/UddlElementExt.java +++ b/com.epistimis.uddl/src/com/epistimis/uddl/extension/UddlElementExt.java @@ -8,7 +8,7 @@ import org.eclipse.emf.ecore.EObject; -import com.epistimis.uddl.scoping.IndexUtilities; +import com.epistimis.uddl.util.IndexUtilities; import com.epistimis.uddl.uddl.UddlElement; import com.epistimis.uddl.uddl.UddlPackage; import com.google.inject.Inject; diff --git a/com.epistimis.uddl/src/com/epistimis/uddl/scoping/UddlScopeProvider.java b/com.epistimis.uddl/src/com/epistimis/uddl/scoping/UddlScopeProvider.java index 2a5ef68..721a8e2 100644 --- a/com.epistimis.uddl/src/com/epistimis/uddl/scoping/UddlScopeProvider.java +++ b/com.epistimis.uddl/src/com/epistimis/uddl/scoping/UddlScopeProvider.java @@ -44,6 +44,7 @@ //import org.eclipse.emf.ecore.resource.Resource; import com.epistimis.uddl.uddl.UddlPackage; +import com.epistimis.uddl.util.IndexUtilities; import com.google.common.base.Objects; import com.google.inject.Inject; diff --git a/com.epistimis.uddl/src/com/epistimis/uddl/unrolled/UnrolledAssociation.java b/com.epistimis.uddl/src/com/epistimis/uddl/unrolled/UnrolledAssociation.java index c4a0af3..612cdc9 100644 --- a/com.epistimis.uddl/src/com/epistimis/uddl/unrolled/UnrolledAssociation.java +++ b/com.epistimis.uddl/src/com/epistimis/uddl/unrolled/UnrolledAssociation.java @@ -8,7 +8,7 @@ import org.eclipse.jdt.annotation.NonNull; import com.epistimis.uddl.uddl.UddlElement; -import com.epistimis.uddl.scoping.IndexUtilities; +import com.epistimis.uddl.util.IndexUtilities; public abstract class UnrolledAssociation + * @param + */ +public class Pair { + + protected T first; + + protected U second; + + public Pair(final T firstElement, final U secondElement) { + this.first = firstElement; + this.second = secondElement; + } + + public T getFirst() { + return first; + } + + public U getSecond() { + return second; + } + + + @Override + public boolean equals(Object other) { + if (other == null) + return false; + if (this == other) + return true; + if (this.getClass().equals(other.getClass())) { + Pair otherPair = (Pair) other; + boolean isEqual = (first == null) ? otherPair.getFirst() == null : first.equals(otherPair.getFirst()); + + if (!isEqual) + return false; + + return (second == null) ? otherPair.getSecond() == null : second.equals(otherPair.getSecond()); + } + return false; + } + + @Override + public int hashCode() { + return first == null ? 0 : first.hashCode() + 17 * (second == null ? 0 : second.hashCode()); + } + + @Override + public String toString() { + return "Pair(" + first + ", " + second + ")"; + } + + /** + * A mutable Pair - values can be reset + * @param + * @param + */ + public static class Mutable extends Pair { + + /** + * @param firstElement + * @param secondElement + */ + public Mutable(T firstElement, U secondElement) { + super(firstElement, secondElement); + // TODO Auto-generated constructor stub + } + public void setFirst(final T firstElement) { first = firstElement; } + public void setSecond(final U secondElement) { second = secondElement; } + + } +} diff --git a/com.epistimis.uddl/src/com/epistimis/uddl/ResourceUtils.java b/com.epistimis.uddl/src/com/epistimis/uddl/util/ResourceUtils.java similarity index 96% rename from com.epistimis.uddl/src/com/epistimis/uddl/ResourceUtils.java rename to com.epistimis.uddl/src/com/epistimis/uddl/util/ResourceUtils.java index 35791c7..16c7924 100644 --- a/com.epistimis.uddl/src/com/epistimis/uddl/ResourceUtils.java +++ b/com.epistimis.uddl/src/com/epistimis/uddl/util/ResourceUtils.java @@ -1,4 +1,4 @@ -package com.epistimis.uddl; +package com.epistimis.uddl.util; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.EObject; diff --git a/com.epistimis.uddl/src/com/epistimis/uddl/util/Triplet.java b/com.epistimis.uddl/src/com/epistimis/uddl/util/Triplet.java new file mode 100644 index 0000000..bd27f3b --- /dev/null +++ b/com.epistimis.uddl/src/com/epistimis/uddl/util/Triplet.java @@ -0,0 +1,66 @@ +/** + * + */ +package com.epistimis.uddl.util; + + + +public class Triplet { + + private final T first; + private final U second; + private final V third; + + public Triplet(final T firstElement, final U secondElement, final V thirdElement) { + this.first = firstElement; + this.second = secondElement; + this.third = thirdElement; + } + + public T getFirst() { + return first; + } + + public U getSecond() { + return second; + } + + public V getThird() { + return third; + } + + @Override + public boolean equals(Object other) { + if (other == null) + return false; + if (this == other) + return true; + if (this.getClass().equals(other.getClass())) { + Triplet otherTriplet = (Triplet) other; + boolean isEqual = (first == null) ? otherTriplet.getFirst() == null : first.equals(otherTriplet.getFirst()); + + if (!isEqual) + return false; + + isEqual = (second == null) ? otherTriplet.getSecond() == null : second.equals(otherTriplet.getSecond()); + + if (!isEqual) + return false; + + return (third == null) ? otherTriplet.getThird() == null : third.equals(otherTriplet.getThird()); + + } + return false; + } + + @Override + public int hashCode() { + return first == null ? 0 : first.hashCode() + 17 * (second == null ? 0 : second.hashCode()) + 347 * (third == null ? 0 : third.hashCode()); + } + + @Override + public String toString() { + return "Triplet(" + first + ", " + second + ", " + third + ")"; + } + +}