'Set one kind of enum to another enum kind of enum in java
I have identical enums defined in both an entity class as well as in a response class. I want to set the value of an enum property in one of the classes to an enum property from the other class. Below is sample code. I am very new to Java and the IT industry.
@Getter
@Setter
public class ResponseClass{
enum Type{
USD, CSD, MXN, BRL;
};
private Type type;
}
@Entity
@Getter
@Setter
public class EntityClass{
enum Type{
USD, CSD, MXN, BRL;
};
@Column(name = "type")
private Type type;
}
public class Main{
public static void main(){
EntityClass entity= new EntityClass();
ResponseClass response = ...; //Got value for this variable from REST API
entity.setType(response.getType()); // I want to achive this
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
