separate RelationTypeFactory from RelationType
This commit is contained in:
@ -8,5 +8,4 @@
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
</project>
|
||||
|
@ -11,31 +11,16 @@
|
||||
package com.minres.scviewer.database;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class RelationType implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 6394859077558971735L;
|
||||
|
||||
private static HashMap<String, RelationType> registry = new HashMap<>();
|
||||
|
||||
private String name;
|
||||
|
||||
public static RelationType create(String name){
|
||||
if(registry.containsKey(name)){
|
||||
return registry.get(name);
|
||||
}else{
|
||||
RelationType relType = new RelationType(name);
|
||||
registry.put(name, relType);
|
||||
return relType;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private RelationType(String name) {
|
||||
RelationType(String name) {
|
||||
super();
|
||||
this.name = name;
|
||||
}
|
||||
@ -59,6 +44,9 @@ public class RelationType implements Serializable {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return name.equals(obj);
|
||||
if(obj instanceof RelationType)
|
||||
return name.equals(((RelationType)obj).name);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,22 @@
|
||||
package com.minres.scviewer.database;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class RelationTypeFactory {
|
||||
|
||||
public static RelationType create(String name){
|
||||
if(registry.containsKey(name)){
|
||||
return registry.get(name);
|
||||
}else{
|
||||
RelationType relType = new RelationType(name);
|
||||
registry.put(name, relType);
|
||||
return relType;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private RelationTypeFactory() {}
|
||||
|
||||
private static HashMap<String, RelationType> registry = new HashMap<>();
|
||||
|
||||
}
|
@ -11,7 +11,6 @@
|
||||
package com.minres.scviewer.database.internal;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
@ -10,8 +10,6 @@
|
||||
*******************************************************************************/
|
||||
package com.minres.scviewer.database.tx;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.minres.scviewer.database.AssociationType;
|
||||
import com.minres.scviewer.database.DataType;
|
||||
|
||||
|
Reference in New Issue
Block a user