Skip to content

Commit

Permalink
refactor: rename Component::copy to Component::copyFrom
Browse files Browse the repository at this point in the history
  • Loading branch information
jdrueckert committed Aug 10, 2021
1 parent 70d9b1c commit e451d5a
Show file tree
Hide file tree
Showing 21 changed files with 33 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ public interface Component<T extends Component> {
* Copies the values from another component. This is expected to be of the same type.
* @param other The component to copy
*/
void copy(T other);
void copyFrom(T other);
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
public abstract class EmptyComponent<T extends EmptyComponent> implements Component<T> {

@Override
public void copy(T other) {
public void copyFrom(T other) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import com.google.common.base.CaseFormat;
import com.google.common.base.Converter;
import com.google.common.collect.Lists;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -35,7 +34,6 @@
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.BiConsumer;
import java.util.function.Function;
Expand Down Expand Up @@ -66,7 +64,7 @@ public <T extends Component<T>> ComponentType<T> createComponentType(Class<T> ty
if (copyConstructor == null) {
copyConstructor = (T from) -> {
T result = emptyConstructor.get();
result.copy(from);
result.copyFrom(from);
return result;
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public boolean has(int entityId) {
public boolean get(int entityId, T into) {
T value = store[entityId];
if (value != null) {
into.copy(store[entityId]);
into.copyFrom(store[entityId]);
return true;
}
return false;
Expand All @@ -78,7 +78,7 @@ public boolean set(int entityId, T component) {
store[entityId] = type.createCopy(component);
return true;
} else {
store[entityId].copy(component);
store[entityId].copyFrom(component);
return false;
}
}
Expand Down Expand Up @@ -126,7 +126,7 @@ public boolean next() {

@Override
public void getComponent(Component<T> component) {
component.copy(store[index]);
component.copyFrom(store[index]);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public boolean get(int entityId, T into) {
if (source == null) {
return false;
}
into.copy(source);
into.copyFrom(source);
return true;
}

Expand All @@ -70,7 +70,7 @@ public boolean set(int entityId, T component) {
store.put(entityId, type.createCopy(component));
return true;
} else {
stored.copy(component);
stored.copyFrom(component);
return false;
}
}
Expand Down Expand Up @@ -119,7 +119,7 @@ public int getEntityId() {

@Override
public void getComponent(Component<T> component) {
component.copy(iterator.value());
component.copyFrom(iterator.value());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void setEntityRecipe(ResourceUrn entityRecipe) {
}

@Override
public void copy(GeneratedFromRecipeComponent other) {
public void copyFrom(GeneratedFromRecipeComponent other) {
this.entityRecipe = other.entityRecipe;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class ArrayContainingComponent implements Component<ArrayContainingCompon
public List<String> strings = new ArrayList<>();

@Override
public void copy(ArrayContainingComponent other) {
public void copyFrom(ArrayContainingComponent other) {
strings.clear();
strings.addAll(other.strings);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public BasicComponent() {
}

public BasicComponent(BasicComponent other) {
copy(other);
copyFrom(other);
logger.info("Copy constructor called");
}

Expand Down Expand Up @@ -78,7 +78,7 @@ public void setCount(int count) {
this.count = count;
}

public void copy(BasicComponent other) {
public void copyFrom(BasicComponent other) {
this.name = other.name;
this.description = other.description;
this.count = other.count;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class PublicAttributeComponent implements Component<PublicAttributeCompon
public String name = "";

@Override
public void copy(PublicAttributeComponent other) {
public void copyFrom(PublicAttributeComponent other) {
this.name = other.name;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public Reference() {
}

public Reference(Reference other) {
copy(other);
copyFrom(other);
}

public EntityRef getReference() {
Expand All @@ -59,7 +59,7 @@ public void setReferences(List<EntityRef> references) {
this.references.addAll(references);
}

public void copy(Reference other) {
public void copyFrom(Reference other) {
setReferences(other.references);
this.reference = other.reference;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public Sample() {
}

public Sample(Sample other) {
copy(other);
copyFrom(other);
}

public String getName() {
Expand All @@ -49,7 +49,7 @@ public void setDescription(String description) {
this.description = description;
}

public void copy(Sample other) {
public void copyFrom(Sample other) {
this.name = other.name;
this.description = other.description;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public Second() {
}

public Second(Second other) {
copy(other);
copyFrom(other);
}

public String getName() {
Expand All @@ -55,7 +55,7 @@ public void setDescription(String description) {
this.dirty = true;
}

public void copy(Second other) {
public void copyFrom(Second other) {
this.name = other.name;
this.description = other.description;
this.dirty = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public void setStringProperty(CharSequence charSequence) {
}

@Override
public void copy(MismatchedPropertiesComponent other) {
public void copyFrom(MismatchedPropertiesComponent other) {
this.stringProperty = other.stringProperty;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class ArrayContainingComponent implements Component<ArrayContainingCompon
public List<String> strings = new ArrayList<>();

@Override
public void copy(ArrayContainingComponent other) {
public void copyFrom(ArrayContainingComponent other) {
strings.clear();
strings.addAll(other.strings);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public BasicComponent() {
}

public BasicComponent(BasicComponent other) {
copy(other);
copyFrom(other);
logger.info("Copy constructor called");
}

Expand Down Expand Up @@ -78,7 +78,7 @@ public void setCount(int count) {
this.count = count;
}

public void copy(BasicComponent other) {
public void copyFrom(BasicComponent other) {
this.name = other.name;
this.description = other.description;
this.count = other.count;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ public Empty() {
}

public Empty(Empty other) {
copy(other);
copyFrom(other);
}

public void copy(Empty other) {
public void copyFrom(Empty other) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class PublicAttributeComponent implements Component<PublicAttributeCompon
public String name = "";

@Override
public void copy(PublicAttributeComponent other) {
public void copyFrom(PublicAttributeComponent other) {
this.name = other.name;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public Sample() {
}

public Sample(Sample other) {
copy(other);
copyFrom(other);
}

public String getName() {
Expand All @@ -48,7 +48,7 @@ public void setDescription(String description) {
this.description = description;
}

public void copy(Sample other) {
public void copyFrom(Sample other) {
this.name = other.name;
this.description = other.description;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public Second() {
}

public Second(Second other) {
copy(other);
copyFrom(other);
}

public String getName() {
Expand All @@ -51,7 +51,7 @@ public void setDescription(String description) {
this.description = description;
}

public void copy(Second other) {
public void copyFrom(Second other) {
this.name = other.name;
this.description = other.description;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public void setStringProperty(CharSequence charSequence) {
}

@Override
public void copy(MismatchedPropertiesComponent other) {
public void copyFrom(MismatchedPropertiesComponent other) {
this.stringProperty = other.stringProperty;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public MyComponent(MyComponent other) {
}

@Override
public void copy(MyComponent other) {
public void copyFrom(MyComponent other) {
this.name = other.name;
}
}

0 comments on commit e451d5a

Please sign in to comment.