001package ball.game.crossword.entity;
002/*-
003 * ##########################################################################
004 * Game Applications and Utilities
005 * $Id: Grid.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/Grid.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.persistence.entity.AbstractEntity;
024import java.util.ArrayList;
025import java.util.List;
026import javax.persistence.Column;
027import javax.persistence.Entity;
028import javax.persistence.Id;
029import javax.persistence.IdClass;
030import javax.persistence.Lob;
031import javax.persistence.OneToMany;
032import javax.persistence.Table;
033import lombok.EqualsAndHashCode;
034import lombok.Getter;
035import lombok.NoArgsConstructor;
036import lombok.Setter;
037import lombok.ToString;
038
039import static javax.persistence.CascadeType.ALL;
040
041/**
042 * {@link Grid} {@link Entity}.
043 *
044 * {@bean.info}
045 *
046 * @author {@link.uri mailto:ball@hcf.dev Allen D. Ball}
047 * @version $Revision: 5285 $
048 */
049@Entity
050@Table(catalog = "crossword", name = "grid")
051@IdClass(Grid.PK.class)
052@NoArgsConstructor @EqualsAndHashCode(callSuper = false) @ToString
053public class Grid extends AbstractEntity {
054    @Id @Column(nullable = false)
055    @Getter @Setter
056    private int height = -1;
057
058    @Id @Column(nullable = false)
059    @Getter @Setter
060    private int width = -1;
061
062    @Id @Column @Lob
063    @Getter @Setter
064    private String string = null;
065
066    @OneToMany(mappedBy = "grid", cascade = ALL)
067    @Getter @Setter
068    private List<Crossword> crosswords = new ArrayList<>();
069
070    @NoArgsConstructor @EqualsAndHashCode(callSuper = false) @ToString
071    public static class PK {
072        @Getter @Setter private int height = -1;
073        @Getter @Setter private int width = -1;
074        @Getter @Setter private String string = null;
075    }
076}