ActorCodec#documentHasId()

ActorCodec class has a method checking if ID is set or no.
Body of this method is: return null == actor.getId();
Shouldn’t be null != actor.getId() ?
If actor has no ID the current statement return true

Hi @toudidel,

The methods that utilize documentHasId use it in the way that it is defined. Specifically this definition is justified due to the use of a ternary operator in generateIdIfAbsentFromDocument.

Are you getting an error when running the UsingPojoLesson.java ?

Best,

Yulia

I’m just asking because I created a new simple console application. It has one pojo class:

public class MyClass {

private Long id;

public Long getId() {
    return id;
}

public void setId(Long id) {
    this.id = id;
}

}

The main class is:

public class Main {

public static void main(String[] args) {
    MyClass myClass = new MyClass();
    System.out.println(String.format("%s", documentHasId(myClass)));
    myClass.setId(1L);
    System.out.println(String.format("%s", documentHasId(myClass)));
}

public static boolean documentHasId(MyClass actor) {
    return null == actor.getId();
}

}

and it returns results exactly opposed it should:

true
false

Hi @toudidel,

This is fair. The name of the method is not descriptive enough, we can rename it for the future offerings of the course.

Thank you for following up on this,

Kind regards,

Yulia