001package ball.game.crossword.entity;
002/*-
003 * ##########################################################################
004 * Game Applications and Utilities
005 * %%
006 * Copyright (C) 2010 - 2022 Allen D. Ball
007 * %%
008 * Licensed under the Apache License, Version 2.0 (the "License");
009 * you may not use this file except in compliance with the License.
010 * You may obtain a copy of the License at
011 *
012 *      http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing, software
015 * distributed under the License is distributed on an "AS IS" BASIS,
016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017 * See the License for the specific language governing permissions and
018 * limitations under the License.
019 * ##########################################################################
020 */
021import ball.game.crossword.Direction;
022import javax.persistence.Column;
023import javax.persistence.Entity;
024import javax.persistence.EnumType;
025import javax.persistence.Enumerated;
026import javax.persistence.Id;
027import javax.persistence.IdClass;
028import javax.persistence.Lob;
029import javax.persistence.ManyToOne;
030import javax.persistence.Table;
031import lombok.EqualsAndHashCode;
032import lombok.Getter;
033import lombok.NoArgsConstructor;
034import lombok.Setter;
035import lombok.ToString;
036
037import static javax.persistence.FetchType.LAZY;
038
039/**
040 * {@link Clue} {@link Entity}.
041 *
042 * {@bean.info}
043 *
044 * @author {@link.uri mailto:ball@hcf.dev Allen D. Ball}
045 */
046@Entity
047@Table(catalog = "crossword", name = "clue")
048@IdClass(Clue.PK.class)
049@NoArgsConstructor @EqualsAndHashCode(callSuper = false) @ToString
050public class Clue extends AbstractEntity {
051    @Id @ManyToOne(fetch = LAZY)
052    @Getter @Setter
053    private Crossword crossword = null;
054
055    @Id @Column(length = 6) @Enumerated(EnumType.STRING)
056    @Getter @Setter
057    private Direction direction = null;
058
059    @Id @Column
060    @Getter @Setter
061    private int index = -1;
062
063    @Column @Lob
064    @Getter @Setter
065    private String text = null;
066
067    @Column
068    @Getter @Setter
069    private String answer = null;
070
071    @NoArgsConstructor @EqualsAndHashCode(callSuper = false) @ToString
072    public static class PK {
073        @Getter @Setter private Crossword crossword = null;
074        @Getter @Setter private Direction direction = null;
075        @Getter @Setter private int index = -1;
076    }
077}