Project

General

Profile

« Previous | Next » 

Revision 30c019bf

Added by Katja Luther almost 13 years ago

delete clone method because there is no use case for it

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/name/HomotypicalGroup.java
581 581
		}
582 582
	}
583 583
	
584
	//*********************** CLONE ********************************************************/
585
	/** 
586
	 * Clones <i>this</i> homotypical group. This is a shortcut that enables to create
587
	 * a new instance that differs only slightly from <i>this</i> homotypical group by
588
	 * modifying only some of the attributes.<BR><BR>
589
	 * 
590
	 *  
591
	 * @see eu.etaxonomy.cdm.model.common.AnnotatableEntity#clone()
592
	 * @see java.lang.Object#clone()
593
	 */
594
	@Override
595
	public Object clone()  {
596
		try{
597
			HomotypicalGroup result = (HomotypicalGroup) super.clone();
598
			result.typifiedNames = new HashSet<TaxonNameBase>();
599
			HashMap<UUID,TaxonNameBase> names = new HashMap<UUID,TaxonNameBase>();
600
			TaxonNameBase basionym;
601
			TaxonNameBase basionymClone;
602
			UUID typifiedNameUuid;
603
			
604
			for (TaxonNameBase typifiedName:this.getTypifiedNames()){
605
				if (!names.containsKey(typifiedName.getUuid())){
606
					TaxonNameBase typifiedNameClone =(TaxonNameBase) typifiedName.clone();
607
					names.put(typifiedName.getUuid(), typifiedNameClone);
608
					typifiedNameClone.setHomotypicalGroup(result);
609
					basionym = typifiedName.getBasionym();
610
					if (basionym != null){
611
						if (names.containsKey(basionym.getUuid())){
612
							basionymClone = names.get(basionym.getUuid());
613
						}else{
614
							basionymClone = (TaxonNameBase)basionym.clone();
615
							names.put(basionym.getUuid(), basionymClone);
616
							result.addTypifiedName(basionymClone);
617
						}
618
						
619
						typifiedNameClone.addBasionym(basionymClone);
620
					}
621
					
622
					result.addTypifiedName(typifiedNameClone);
623
					
624
				} 
625
			}
626
			return result;
627
		}catch (CloneNotSupportedException e) {
628
			logger.warn("Object does not implement cloneable");
629
			e.printStackTrace();
630
			return null;
631
		}
632
		
633
	}
584
	
634 585
}

Also available in: Unified diff