habuma / spring-in-action-5-samples

Home for example code from Spring in Action 5.
Apache License 2.0
1.21k stars 1.04k forks source link

JPA problem #122

Closed Tusharvaghasiya closed 1 year ago

Tusharvaghasiya commented 1 year ago

image

package tacos;

import javax.persistence.Entity;
import javax.persistence.Id;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Entity
@AllArgsConstructor
@NoArgsConstructor(access = AccessLevel.PRIVATE, force = true)
public class Ingredient {
    @Id
    private String id;
    private String name;
    private Type type;

    public enum Type {
        WRAP, PROTEIN, VEGGIES, CHEESE, SAUCE;

        public String getType() {
            switch (this) {
            case CHEESE:
                return "cheese";
            case PROTEIN:
                return "protein";
            case SAUCE:
                return "sauce";
            case VEGGIES:
                return "vaggies";
            case WRAP:
                return "wrap";
            default:
                return null;
            }
        }
    }
}