package ru.ldeloff.hedgehogcloud.entity;

import com.sun.istack.NotNull;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.data.domain.Persistable;

import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;
import java.util.UUID;

@NoArgsConstructor
@Setter
@MappedSuperclass
@EqualsAndHashCode
public class BaseEntity implements Persistable<String> {
    @Id
    protected String id = UUID.randomUUID().toString();
    @Transient
    private Boolean justCreated = false;

    @Override
    public String getId() {
        return null;
    }

    @Override
    public boolean isNew() {
        return justCreated;
    }
}
