Hi i got a code to understand so here’s the enum code :
package com.unice.miage.igift.enumeration;
/**
*
* @author Root
*/
public enum BookEnum {
BOOK("BOOK"),
MAGAZINE("MAGAZINE");
private String bookText;
BookEnum(String bookText){
this.bookText = bookText;
}
public String getBookText() {
return bookText;
}
public void setBookText(String bookText) {
this.bookText = bookText;
}
}
i can’t find the objective of this enum
Thank you in advance
The “objective” of the enum probably isn’t in the declaration of the enum, it is probably in the usage of the enum.
From the limited info that is here, it is probably used to avoid “stringly-typed” code which would have used the string “BOOK” and “MAGAZINE” all over the place.
For example:
the new version of the method does not allow you to pass in non-existant book types, or arbitrarily cased strings that may or may not have worked in the “old code”