This commit is contained in:
2024-02-02 19:19:48 -06:00
parent 31f634c637
commit a48615c8f8
5 changed files with 328 additions and 187 deletions

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project-shared-configuration>
<!--
This file contains additional configuration written by modules in the NetBeans IDE.
The configuration is intended to be shared among all the users of project and
therefore it is assumed to be part of version control checkout.
Without this configuration present, some functionality in the IDE may be limited or fail altogether.
-->
<properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
<!--
Properties that influence various parts of the IDE, especially code formatting and the like.
You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
That way multiple projects can share the same settings (useful for formatting rules for example).
Any value defined here will override the pom.xml file value but is only applicable to the current project.
-->
<netbeans.hint.jdkPlatform>Graal_JDK_20</netbeans.hint.jdkPlatform>
</properties>
</project-shared-configuration>

View File

@@ -27,7 +27,7 @@ public class ManyToManyFactory {
createManyToMany()
{
return new ManyToMany<Many1, Many2>() {
private HashSet parents = new HashSet();
//private HashSet parents = new HashSet();
private Map<Object, Object> left = new HashMap();
private Map<Object, Object> right = new HashMap();
@@ -39,7 +39,9 @@ public class ManyToManyFactory {
}
/**
* Creates a Many to Many relationship between the parentLeft and the childrenRight. Example for ( Many1 a, Many2 1, 2, 3) it creates --> (a 1) ( a 2 ) ( a 3 ) and ( 1, a ), ( 2, a ), ( 3, a). No duplicate values of Many2 are allowed.
* Creates a Many to Many relationship between the parentLeft and the childrenRight.
* Example for ( Many1 a, Many2 1, 2, 3) it creates --> (a 1) ( a 2 ) ( a 3 ) and ( 1, a ), ( 2, a ), ( 3, a).
* No duplicate values of Many2 are allowed.
*
* @param parentLeft - exactly one Many1 object.
* @param childrenRight - one or more Many2 objects.
@@ -53,17 +55,13 @@ public class ManyToManyFactory {
public List<Many2> add(Many1 parentLeft, Many2... childrenRight)
{
List<Many2> returnList = new ArrayList<Many2>();
// Check to see if values already exist in this many to many object
if (this.left != parentLeft && this.left != null) {
returnList.add((Many2) this.left);
this.left = (Map<Object, Object>) parentLeft;
}
if (this.left != childrenRight && this.right != null) {
returnList.add((Many2) this.right);
this.left = (Map<Object, Object>) childrenRight;
left.put(parentLeft, Arrays.asList(childrenRight));
// Check for exceptions
if (!childrenRight.equals(parentLeft.getClass())) {
throw new ClassCastException();
}
left.put(parentLeft, new ArrayList<Many2>(Arrays.asList(childrenRight)));
return returnList;
}
@Override