Skip to content

Commit

Permalink
Create com.epistimis.uddl.utils package
Browse files Browse the repository at this point in the history
This moves several preexisting utility classes and adds some new ones
Includes changes in import statements to account for change of package
  • Loading branch information
steve-hickman-epistimis committed Feb 16, 2024
1 parent 27a7956 commit b5a4185
Show file tree
Hide file tree
Showing 24 changed files with 171 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions com.epistimis.uddl/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
2 changes: 1 addition & 1 deletion com.epistimis.uddl/src/com/epistimis/uddl/UddlQNP.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ComposableElement extends UddlElement,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jdt.annotation.NonNull;

import com.epistimis.uddl.scoping.IndexUtilities;
import com.epistimis.uddl.util.IndexUtilities;
import com.epistimis.uddl.uddl.PlatformComposableElement;
import com.epistimis.uddl.uddl.PlatformComposition;
import com.epistimis.uddl.uddl.UddlElement;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.eclipse.emf.common.util.EList;
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.google.common.base.Optional;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jdt.annotation.NonNull;

import com.epistimis.uddl.scoping.IndexUtilities;
import com.epistimis.uddl.util.IndexUtilities;
import com.epistimis.uddl.uddl.UddlElement;

public abstract class UnrolledParticipant<ComposableElement extends UddlElement,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
//import com.epistimis.uddl.RealizedEntity;
//import com.epistimis.uddl.UnrolledAssociation;
//import com.epistimis.uddl.UnrolledDataType;
import com.epistimis.uddl.scoping.IndexUtilities;
import com.epistimis.uddl.util.IndexUtilities;
import com.epistimis.uddl.uddl.UddlElement;
import com.google.common.collect.Iterables;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.epistimis.uddl.scoping
package com.epistimis.uddl.util

import com.epistimis.uddl.exceptions.NameCollisionException
import com.epistimis.uddl.exceptions.NamedObjectNotFoundException
Expand Down Expand Up @@ -38,6 +38,8 @@ import org.eclipse.xtext.resource.IEObjectDescription
import org.eclipse.xtext.resource.impl.ResourceDescriptionsProvider
import static java.util.Objects.requireNonNull;
import java.util.HashMap
import com.epistimis.uddl.scoping.ECrossReferenceAdapterCrossReferenceProvider
import com.epistimis.uddl.scoping.ResourceSetRootEObjectProvider

//import org.eclipse.acceleo.query.validation.type.IType
//import org.eclipse.acceleo.query.validation.type.EClassifierType
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/**
*
*/
package com.epistimis.uddl;
package com.epistimis.uddl.util;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jdt.annotation.NonNull;

import com.epistimis.uddl.scoping.IndexUtilities;
import com.epistimis.uddl.util.IndexUtilities;
import com.google.inject.Inject;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.epistimis.uddl;
package com.epistimis.uddl.util;

import java.util.Collection;
import java.util.HashSet;
Expand Down
79 changes: 79 additions & 0 deletions com.epistimis.uddl/src/com/epistimis/uddl/util/Pair.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/**
*
*/
package com.epistimis.uddl.util;


/**
* An immutable Pair (because values can only be set in the constructor).
* @param <T>
* @param <U>
*/
public class Pair<T, U> {

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 <T>
* @param <U>
*/
public static class Mutable<T,U> extends Pair<T,U> {

/**
* @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; }

}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
66 changes: 66 additions & 0 deletions com.epistimis.uddl/src/com/epistimis/uddl/util/Triplet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/**
*
*/
package com.epistimis.uddl.util;



public class Triplet<T, U, V> {

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 + ")";
}

}

0 comments on commit b5a4185

Please sign in to comment.