mirror of https://github.com/FreeCol/freecol.git
clone -> cloneOption to avoid Object.clone() semantic confusion (findbugs).
This commit is contained in:
parent
09ed236c60
commit
f76a70340f
|
@ -204,7 +204,7 @@ public abstract class FreeColAction extends AbstractAction
|
|||
* Don't use this method.
|
||||
*/
|
||||
@Override
|
||||
public FreeColAction clone() throws CloneNotSupportedException {
|
||||
public FreeColAction cloneOption() throws CloneNotSupportedException {
|
||||
throw new CloneNotSupportedException("FreeColAction can not be cloned:" + this);
|
||||
}
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ public final class ListOptionUI<T> extends OptionUI<ListOption<T>>
|
|||
this.model = new DefaultListModel<>();
|
||||
for (AbstractOption<T> o : option.getValue()) {
|
||||
try {
|
||||
AbstractOption<T> c = o.clone();
|
||||
AbstractOption<T> c = o.cloneOption();
|
||||
this.model.addElement(c);
|
||||
} catch (CloneNotSupportedException e) {
|
||||
logger.log(Level.WARNING, "Can not clone " + o.getId(), e);
|
||||
|
@ -115,7 +115,7 @@ public final class ListOptionUI<T> extends OptionUI<ListOption<T>>
|
|||
|
||||
addButton.addActionListener((ActionEvent ae) -> {
|
||||
try {
|
||||
AbstractOption<T> ao = option.getTemplate().clone();
|
||||
AbstractOption<T> ao = option.getTemplate().cloneOption();
|
||||
if (gui.showEditOptionDialog(ao) && option.canAdd(ao)) {
|
||||
this.model.addElement(ao);
|
||||
this.list.setSelectedValue(ao, true);
|
||||
|
|
|
@ -138,7 +138,8 @@ public abstract class AbstractOption<T> extends FreeColSpecObject
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public abstract AbstractOption<T> clone() throws CloneNotSupportedException;
|
||||
public abstract AbstractOption<T> cloneOption()
|
||||
throws CloneNotSupportedException;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
|
|
|
@ -146,7 +146,7 @@ public class AbstractUnitOption extends AbstractOption<AbstractUnit> {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public AbstractUnitOption clone() {
|
||||
public AbstractUnitOption cloneOption() {
|
||||
final Specification spec = getSpecification();
|
||||
AbstractUnitOption result = new AbstractUnitOption(getId(), spec);
|
||||
result.setValues(this);
|
||||
|
@ -155,9 +155,9 @@ public class AbstractUnitOption extends AbstractOption<AbstractUnit> {
|
|||
value.getRoleId(), value.getNumber());
|
||||
result.setValue(au);
|
||||
}
|
||||
if (unitTypeOption != null) result.unitTypeOption = unitTypeOption.clone();
|
||||
if (roleOption != null) result.roleOption = roleOption.clone();
|
||||
if (numberOption != null) result.numberOption = numberOption.clone();
|
||||
if (unitTypeOption != null) result.unitTypeOption = unitTypeOption.cloneOption();
|
||||
if (roleOption != null) result.roleOption = roleOption.cloneOption();
|
||||
if (numberOption != null) result.numberOption = numberOption.cloneOption();
|
||||
result.nationType = nationType;
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -184,7 +184,7 @@ public class AudioMixerOption extends AbstractOption<AudioMixerOption.MixerWrapp
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public AudioMixerOption clone() {
|
||||
public AudioMixerOption cloneOption() {
|
||||
AudioMixerOption result = new AudioMixerOption(getSpecification());
|
||||
result.setValues(this);
|
||||
return result;
|
||||
|
|
|
@ -68,7 +68,7 @@ public class BooleanOption extends AbstractOption<Boolean> {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public BooleanOption clone() {
|
||||
public BooleanOption cloneOption() {
|
||||
BooleanOption result = new BooleanOption(getId(), getSpecification());
|
||||
result.setValues(this);
|
||||
return result;
|
||||
|
|
|
@ -82,7 +82,7 @@ public class FileOption extends AbstractOption<File> {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public FileOption clone() {
|
||||
public FileOption cloneOption() {
|
||||
FileOption result = new FileOption(getSpecification());
|
||||
result.setValues(this);
|
||||
result.setType(this.getType());
|
||||
|
|
|
@ -121,7 +121,7 @@ public class IntegerOption extends AbstractOption<Integer> {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public IntegerOption clone() {
|
||||
public IntegerOption cloneOption() {
|
||||
IntegerOption result = new IntegerOption(getId(), getSpecification());
|
||||
result.setValues(this);
|
||||
result.setMinimumValue(this.minimumValue);
|
||||
|
|
|
@ -236,7 +236,7 @@ public class LanguageOption extends AbstractOption<LanguageOption.Language> {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public LanguageOption clone() {
|
||||
public LanguageOption cloneOption() {
|
||||
LanguageOption result = new LanguageOption(getSpecification());
|
||||
result.setValues(this);
|
||||
return result;
|
||||
|
|
|
@ -59,7 +59,7 @@ public class ModListOption extends ListOption<FreeColModFile> {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ModListOption clone() {
|
||||
public ModListOption cloneOption() {
|
||||
ModListOption ret = new ModListOption(getId(), getSpecification());
|
||||
ret.setValues(this);
|
||||
ret.setListValues(this);
|
||||
|
|
|
@ -71,7 +71,7 @@ public class ModOption extends AbstractOption<FreeColModFile> {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ModOption clone() {
|
||||
public ModOption cloneOption() {
|
||||
ModOption result = new ModOption(getSpecification());
|
||||
result.setId(this.getId());
|
||||
result.value = this.value;
|
||||
|
|
|
@ -38,7 +38,7 @@ public interface Option<T> extends Cloneable, ObjectWithId {
|
|||
* @return A clone of this option.
|
||||
* @exception CloneNotSupportedException if we can not clone.
|
||||
*/
|
||||
public Option<T> clone() throws CloneNotSupportedException;
|
||||
public Option<T> cloneOption() throws CloneNotSupportedException;
|
||||
|
||||
/**
|
||||
* Gets the option group identifier for this option.
|
||||
|
|
|
@ -421,7 +421,7 @@ public class OptionGroup extends AbstractOption<OptionGroup>
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public OptionGroup clone() {
|
||||
public OptionGroup cloneOption() {
|
||||
OptionGroup result = new OptionGroup(this.getId(), getSpecification());
|
||||
result.editable = this.editable;
|
||||
result.setValues(this);
|
||||
|
|
|
@ -95,7 +95,7 @@ public class StringOption extends AbstractOption<String> {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public StringOption clone() {
|
||||
public StringOption cloneOption() {
|
||||
StringOption result = new StringOption(getId(), getSpecification());
|
||||
result.setValues(this);
|
||||
result.setChoices(this.choices);
|
||||
|
|
|
@ -68,7 +68,7 @@ public class TextOption extends AbstractOption<String> {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public TextOption clone() {
|
||||
public TextOption cloneOption() {
|
||||
TextOption result = new TextOption(getId(), getSpecification());
|
||||
result.setValues(this);
|
||||
return result;
|
||||
|
|
|
@ -56,7 +56,7 @@ public class UnitListOption extends ListOption<AbstractUnit> {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public UnitListOption clone() {
|
||||
public UnitListOption cloneOption() {
|
||||
UnitListOption ret = new UnitListOption(getId(), getSpecification());
|
||||
ret.setValues(this);
|
||||
ret.setListValues(this);
|
||||
|
|
|
@ -117,7 +117,7 @@ public class UnitTypeOption extends AbstractOption<UnitType> {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public UnitTypeOption clone() {
|
||||
public UnitTypeOption cloneOption() {
|
||||
UnitTypeOption ret = new UnitTypeOption(getId(), getSpecification());
|
||||
ret.value = this.value;
|
||||
ret.addNone = this.addNone;
|
||||
|
|
|
@ -49,7 +49,7 @@ public class OptionTest extends FreeColTestCase {
|
|||
public void testCloneIntegerOption() {
|
||||
IntegerOption money = spec().getOption(GameOptions.STARTING_MONEY,
|
||||
IntegerOption.class);
|
||||
IntegerOption money2 = money.clone();
|
||||
IntegerOption money2 = money.cloneOption();
|
||||
|
||||
assertFalse(money == money2);
|
||||
assertEquals(money.getId(), money2.getId());
|
||||
|
|
Loading…
Reference in New Issue