Skip to content

Commit

Permalink
Add Clone method to internal data objects.
Browse files Browse the repository at this point in the history
  • Loading branch information
BONNe committed Oct 6, 2020
1 parent 25787f8 commit 5eb9a1d
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,30 @@ public void setGeneratorTiers(Set<String> generatorTiers)
}


// ---------------------------------------------------------------------
// Section: Clone
// ---------------------------------------------------------------------


/**
* Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object.
* @return a clone of this instance.
*/
@Override
public GeneratorBundleObject clone()
{
GeneratorBundleObject clone = new GeneratorBundleObject();

clone.setUniqueId(this.uniqueId);
clone.setFriendlyName(this.friendlyName);
clone.setGeneratorIcon(this.generatorIcon.clone());
clone.setDescription(new ArrayList<>(this.description));
clone.setGeneratorTiers(new HashSet<>(this.generatorTiers));

return clone;
}


// ---------------------------------------------------------------------
// Section: Variables
// ---------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,43 @@ public void setActivationCost(double activationCost)
this.activationCost = activationCost;
}


// ---------------------------------------------------------------------
// Section: Methods
// ---------------------------------------------------------------------


/**
* Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object.
* @return a clone of this instance.
*/
@Override
public GeneratorTierObject clone()
{
GeneratorTierObject clone = new GeneratorTierObject();

clone.setUniqueId(this.uniqueId);
clone.setFriendlyName(this.friendlyName);
clone.setGeneratorIcon(this.generatorIcon.clone());
clone.setDescription(new ArrayList<>(this.description));
clone.setGeneratorType(this.generatorType);
clone.setDefaultGenerator(this.defaultGenerator);
clone.setPriority(this.priority);
clone.setRequiredMinIslandLevel(this.requiredMinIslandLevel);
clone.setRequiredBiomes(new HashSet<>(this.requiredBiomes));
clone.setRequiredPermissions(new HashSet<>(this.requiredPermissions));
clone.setGeneratorTierCost(this.generatorTierCost);
clone.setActivationCost(this.activationCost);
clone.setDeployed(this.deployed);
clone.setBlockChanceMap(new TreeMap<>(this.blockChanceMap));
clone.setTreasureChanceMap(new TreeMap<>(this.treasureChanceMap));
clone.setTreasureChance(this.treasureChance);
clone.setMaxTreasureAmount(this.maxTreasureAmount);

return clone;
}


// ---------------------------------------------------------------------
// Section: Enums
// ---------------------------------------------------------------------
Expand Down

0 comments on commit 5eb9a1d

Please sign in to comment.