Skip to content
Snippets Groups Projects
Commit db03fca6 authored by Matej Lukes's avatar Matej Lukes
Browse files

null check added

parent 5f46883a
No related branches found
No related tags found
No related merge requests found
...@@ -22,7 +22,7 @@ public abstract class MeshComponent { ...@@ -22,7 +22,7 @@ public abstract class MeshComponent {
* @return true if newParent was successfully added, false otherwise * @return true if newParent was successfully added, false otherwise
*/ */
public boolean addParent(MeshComponent newParent){ public boolean addParent(MeshComponent newParent){
if (parents.contains(newParent)) if (newParent == null || parents.contains(newParent))
return false; return false;
parents.add(newParent); parents.add(newParent);
return true; return true;
......
...@@ -19,7 +19,7 @@ public class MeshComposite extends MeshComponent { ...@@ -19,7 +19,7 @@ public class MeshComposite extends MeshComponent {
*/ */
@Override @Override
public boolean addChild(MeshComponent newChild) { public boolean addChild(MeshComponent newChild) {
if (children.contains(newChild)) if (newChild == null || children.contains(newChild))
return false; return false;
children.add(newChild); children.add(newChild);
......
...@@ -6,6 +6,8 @@ public class MeshEdge extends MeshComposite { ...@@ -6,6 +6,8 @@ public class MeshEdge extends MeshComposite {
public MeshEdge(MeshPoint point1, MeshPoint point2){ public MeshEdge(MeshPoint point1, MeshPoint point2){
super(); super();
if (point1 == null || point2 == null)
throw new NullPointerException("point1 and point2 cannot be null");
super.addChild(point1); super.addChild(point1);
super.addChild(point2); super.addChild(point2);
} }
......
...@@ -16,6 +16,9 @@ public class MeshFacet extends MeshComposite { ...@@ -16,6 +16,9 @@ public class MeshFacet extends MeshComposite {
* @return point from pointPool if it is in pointPool, null otherwise * @return point from pointPool if it is in pointPool, null otherwise
*/ */
public MeshPoint getPoint(MeshPoint point) { public MeshPoint getPoint(MeshPoint point) {
if (point == null)
return null;
MeshPoint result = pointPool.get(point); MeshPoint result = pointPool.get(point);
if (result == null) { if (result == null) {
pointPool.put(point, point); pointPool.put(point, point);
...@@ -30,6 +33,9 @@ public class MeshFacet extends MeshComposite { ...@@ -30,6 +33,9 @@ public class MeshFacet extends MeshComposite {
* @return edge from edgePool if it is in edgePool, null otherwise * @return edge from edgePool if it is in edgePool, null otherwise
*/ */
public MeshEdge getEdge(MeshEdge edge) { public MeshEdge getEdge(MeshEdge edge) {
if (edge == null)
return null;
MeshEdge result = edgePool.get(edge); MeshEdge result = edgePool.get(edge);
if (result == null) { if (result == null) {
edgePool.put(edge, edge); edgePool.put(edge, edge);
......
...@@ -7,6 +7,9 @@ public class MeshPoint extends MeshLeaf { ...@@ -7,6 +7,9 @@ public class MeshPoint extends MeshLeaf {
private final Vector3d position, normal, texCoord; private final Vector3d position, normal, texCoord;
public MeshPoint(Vector3d position, Vector3d normal , Vector3d texCoord) { public MeshPoint(Vector3d position, Vector3d normal , Vector3d texCoord) {
if (position == null || normal == null || texCoord == null)
throw new NullPointerException("position, normal and texCoord cannot be null");
this.position = position; this.position = position;
this.normal = normal; this.normal = normal;
this.texCoord = texCoord; this.texCoord = texCoord;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment