Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for @NotNull annotation #277

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions ashley/src/com/badlogic/ashley/core/Engine.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.badlogic.ashley.utils.ImmutableArray;
import com.badlogic.gdx.utils.reflect.ClassReflection;
import com.badlogic.gdx.utils.reflect.ReflectionException;
import org.jetbrains.annotations.NotNull;

/**
* The heart of the Entity framework. It is responsible for keeping track of {@link Entity} and
Expand Down Expand Up @@ -269,7 +270,7 @@ protected void removeEntityInternal(Entity entity) {

private class ComponentListener implements Listener<Entity> {
@Override
public void receive(Signal<Entity> signal, Entity object) {
public void receive(@NotNull Signal<Entity> signal, @NotNull Entity object) {
familyManager.updateFamilyMembership(object);
}
}
Expand All @@ -288,12 +289,12 @@ public void systemRemoved (EntitySystem system) {

private class EngineEntityListener implements EntityListener {
@Override
public void entityAdded (Entity entity) {
public void entityAdded (@NotNull Entity entity) {
addEntityInternal(entity);
}

@Override
public void entityRemoved (Entity entity) {
public void entityRemoved (@NotNull Entity entity) {
removeEntityInternal(entity);
}
}
Expand Down
6 changes: 4 additions & 2 deletions ashley/src/com/badlogic/ashley/core/EntityListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package com.badlogic.ashley.core;

import org.jetbrains.annotations.NotNull;

/**
* Gets notified of {@link Entity} related events.
* @author David Saltares
Expand All @@ -26,12 +28,12 @@ public interface EntityListener {
* {@link Engine#addEntityListener(EntityListener)} and {@link Engine#addEntityListener(Family, EntityListener)}
* @param entity
*/
public void entityAdded (Entity entity);
public void entityAdded (@NotNull Entity entity);

/**
* Called whenever an {@link Entity} is removed from {@link Engine} or a specific {@link Family} See
* {@link Engine#addEntityListener(EntityListener)} and {@link Engine#addEntityListener(Family, EntityListener)}
* @param entity
*/
public void entityRemoved (Entity entity);
public void entityRemoved (@NotNull Entity entity);
}
7 changes: 4 additions & 3 deletions ashley/src/com/badlogic/ashley/core/Family.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import com.badlogic.gdx.utils.Bits;
import com.badlogic.gdx.utils.ObjectMap;
import org.jetbrains.annotations.NotNull;

/**
* Represents a group of {@link Component}s. It is used to describe what {@link Entity} objects an {@link EntitySystem} should
Expand Down Expand Up @@ -74,7 +75,7 @@ public boolean matches (Entity entity) {
* @return A Builder singleton instance to get a family
*/
@SafeVarargs
public static final Builder all (Class<? extends Component>... componentTypes) {
public static final Builder all(@NotNull Class<? extends Component>... componentTypes) {
return builder.reset().all(componentTypes);
}

Expand All @@ -83,7 +84,7 @@ public static final Builder all (Class<? extends Component>... componentTypes) {
* @return A Builder singleton instance to get a family
*/
@SafeVarargs
public static final Builder one (Class<? extends Component>... componentTypes) {
public static final Builder one(@NotNull Class<? extends Component>... componentTypes) {
return builder.reset().one(componentTypes);
}

Expand All @@ -92,7 +93,7 @@ public static final Builder one (Class<? extends Component>... componentTypes) {
* @return A Builder singleton instance to get a family
*/
@SafeVarargs
public static final Builder exclude (Class<? extends Component>... componentTypes) {
public static final Builder exclude(@NotNull Class<? extends Component>... componentTypes) {
return builder.reset().exclude(componentTypes);
}

Expand Down
4 changes: 3 additions & 1 deletion ashley/src/com/badlogic/ashley/signals/Listener.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package com.badlogic.ashley.signals;

import org.jetbrains.annotations.NotNull;

/**
* A simple Listener interface used to listen to a {@link Signal}.
* @author Stefan Bachmann
Expand All @@ -25,5 +27,5 @@ public interface Listener<T> {
* @param signal The Signal that triggered event
* @param object The object passed on dispatch
*/
public void receive (Signal<T> signal, T object);
public void receive (@NotNull Signal<T> signal, @NotNull T object);
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.badlogic.ashley.core.EntitySystem;
import com.badlogic.ashley.core.Family;
import com.badlogic.ashley.utils.ImmutableArray;
import org.jetbrains.annotations.NotNull;

/**
* A simple {@link EntitySystem} that processes a {@link Family} of entities not once per frame, but after a given interval.
Expand Down Expand Up @@ -79,5 +80,5 @@ public Family getFamily () {
* The user should place the entity processing logic here.
* @param entity
*/
protected abstract void processEntity (Entity entity);
protected abstract void processEntity (@NotNull Entity entity);
}
3 changes: 2 additions & 1 deletion ashley/src/com/badlogic/ashley/systems/IteratingSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.badlogic.ashley.core.EntitySystem;
import com.badlogic.ashley.core.Family;
import com.badlogic.ashley.utils.ImmutableArray;
import org.jetbrains.annotations.NotNull;

/**
* A simple EntitySystem that iterates over each entity and calls processEntity() for each entity every time the EntitySystem is
Expand Down Expand Up @@ -87,5 +88,5 @@ public Family getFamily () {
* @param entity The current Entity being processed
* @param deltaTime The delta time between the last and current frame
*/
protected abstract void processEntity (Entity entity, float deltaTime);
protected abstract void processEntity (@NotNull Entity entity, float deltaTime);
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import com.badlogic.ashley.core.Family;
import com.badlogic.ashley.utils.ImmutableArray;
import com.badlogic.gdx.utils.Array;
import org.jetbrains.annotations.NotNull;

import java.util.Comparator;

/**
Expand Down Expand Up @@ -99,13 +101,13 @@ public void removedFromEngine (Engine engine) {
}

@Override
public void entityAdded (Entity entity) {
public void entityAdded (@NotNull Entity entity) {
sortedEntities.add(entity);
shouldSort = true;
}

@Override
public void entityRemoved (Entity entity) {
public void entityRemoved (@NotNull Entity entity) {
sortedEntities.removeValue(entity, true);
shouldSort = true;
}
Expand Down Expand Up @@ -139,5 +141,5 @@ public Family getFamily () {
* @param entity The current Entity being processed
* @param deltaTime The delta time between the last and current frame
*/
protected abstract void processEntity (Entity entity, float deltaTime);
protected abstract void processEntity (@NotNull Entity entity, float deltaTime);
}
2 changes: 1 addition & 1 deletion ashley/src/com/badlogic/ashley/utils/ImmutableArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public T[] toArray () {
return array.toArray();
}

public <V> V[] toArray (Class<?> type) {
public <V> V[] toArray (Class<V> type) {
return array.toArray(type);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.badlogic.ashley.core;

import static org.junit.Assert.*;

import org.junit.Test;

import com.badlogic.ashley.core.ComponentOperationHandler.BooleanInformer;
import com.badlogic.ashley.signals.Listener;
import com.badlogic.ashley.signals.Signal;
import org.junit.Test;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public class ComponentOperationHandlerTests {

Expand Down
14 changes: 8 additions & 6 deletions ashley/tests/com/badlogic/ashley/core/EngineTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@

package com.badlogic.ashley.core;

import static org.junit.Assert.*;

import com.badlogic.gdx.utils.reflect.ReflectionException;
import org.junit.Test;

import com.badlogic.ashley.systems.IteratingSystem;
import com.badlogic.ashley.utils.ImmutableArray;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.Bits;
import com.badlogic.gdx.utils.GdxRuntimeException;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

@SuppressWarnings("unchecked")
public class EngineTests {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@

package com.badlogic.ashley.core;

import static org.mockito.Mockito.*;

import org.junit.Test;
import org.mockito.InOrder;

import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;

public class EntityListenerTests {

@Test
Expand Down
9 changes: 5 additions & 4 deletions ashley/tests/com/badlogic/ashley/core/EntityManagerTests.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package com.badlogic.ashley.core;

import static org.junit.Assert.*;

import org.junit.Test;

import com.badlogic.ashley.utils.ImmutableArray;
import com.badlogic.gdx.utils.Array;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;

public class EntityManagerTests {

Expand Down
16 changes: 8 additions & 8 deletions ashley/tests/com/badlogic/ashley/core/EntityTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@

package com.badlogic.ashley.core;

import static org.junit.Assert.*;

import java.util.HashSet;
import java.util.Set;

import org.junit.Test;

import com.badlogic.ashley.signals.Listener;
import com.badlogic.ashley.signals.Signal;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.Bits;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

public class EntityTests {

Expand Down
8 changes: 5 additions & 3 deletions ashley/tests/com/badlogic/ashley/core/FamilyManagerTests.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.badlogic.ashley.core;
import static org.junit.Assert.*;

import org.junit.Test;

import com.badlogic.ashley.utils.ImmutableArray;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.GdxRuntimeException;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;


public class FamilyManagerTests {
Expand Down
12 changes: 8 additions & 4 deletions ashley/tests/com/badlogic/ashley/core/PooledEngineTests.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@

package com.badlogic.ashley.core;

import static org.junit.Assert.*;

import org.junit.Test;

import com.badlogic.ashley.signals.Listener;
import com.badlogic.ashley.signals.Signal;
import com.badlogic.ashley.utils.ImmutableArray;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.Pool.Poolable;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

public class PooledEngineTests {
private float deltaTime = 0.16f;
Expand Down
8 changes: 3 additions & 5 deletions ashley/tests/com/badlogic/ashley/signals/SignalTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@

package com.badlogic.ashley.signals;

import static org.junit.Assert.*;

import com.badlogic.gdx.utils.Array;
import org.junit.Test;

import com.badlogic.ashley.signals.Listener;
import com.badlogic.ashley.signals.Signal;
import com.badlogic.gdx.utils.Array;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

public class SignalTests {

Expand Down
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ subprojects {

ext {
projectGroup = "ashley"
gdxVersion = "1.9.9"
annotationsVersion = "16.0.2"
gdxVersion = "1.9.10"
jUnitVersion = "4.12"
mockitoVersion = "1.10.19"
}
Expand All @@ -33,6 +34,7 @@ project(":ashley") {

dependencies {
api "com.badlogicgames.gdx:gdx:$gdxVersion"
compileOnly "org.jetbrains:annotations:$annotationsVersion"
testImplementation "junit:junit:$jUnitVersion"
testImplementation "org.mockito:mockito-core:$mockitoVersion"
}
Expand Down