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