001// license-header java merge-point
002//
003// Attention: Generated code! Do not modify by hand!
004// Generated by: hibernate/HibernateEntity.vsl in andromda-hibernate-cartridge.
005//
006package fr.ifremer.adagio.core.dao.administration.programStrategy;
007
008/*
009 * #%L
010 * SIH-Adagio :: Core
011 * $Id:$
012 * $HeadURL:$
013 * %%
014 * Copyright (C) 2012 - 2014 Ifremer
015 * %%
016 * This program is free software: you can redistribute it and/or modify
017 * it under the terms of the GNU Affero General Public License as published by
018 * the Free Software Foundation, either version 3 of the License, or
019 * (at your option) any later version.
020 * 
021 * This program is distributed in the hope that it will be useful,
022 * but WITHOUT ANY WARRANTY; without even the implied warranty of
023 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
024 * GNU General Public License for more details.
025 * 
026 * You should have received a copy of the GNU Affero General Public License
027 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
028 * #L%
029 */
030
031import java.io.Serializable;
032import java.util.Date;
033
034/**
035 * Interval de dates d'une stratégie applicable.
036 */
037// HibernateEntity.vsl annotations merge-point
038public abstract class AppliedPeriod
039    implements Serializable, Comparable<AppliedPeriod>
040{
041    /**
042     * The serial version UID of this class. Needed for serialization.
043     */
044    private static final long serialVersionUID = -3631266350072516223L;
045
046    private AppliedPeriodPK appliedPeriodPk;
047
048    /**
049     * Get the composite primary key identifier class
050     * @return appliedPeriodPk
051     */
052    public AppliedPeriodPK getAppliedPeriodPk()
053    {
054        return this.appliedPeriodPk;
055    }
056
057    /**
058     * Set the composite primary key identifier class
059     * @param appliedPeriodPkIn
060     */
061    public void setAppliedPeriodPk(AppliedPeriodPK appliedPeriodPkIn) {
062        this.appliedPeriodPk = appliedPeriodPkIn;
063    }
064
065    // Generate 2 attributes
066    /**
067     * 
068     * @return this.startDate Date
069     */
070    public Date getStartDate()
071    {
072        return this.getAppliedPeriodPk().getStartDate();
073    }
074
075    /**
076     * 
077     * @param startDateIn Date
078     */
079    public void setStartDate(Date startDateIn)
080    {
081        this.getAppliedPeriodPk().setStartDate(startDateIn);
082    }
083
084    private Date endDate;
085
086    /**
087     * 
088     * @return this.endDate Date
089     */
090    public Date getEndDate()
091    {
092        return this.endDate;
093    }
094
095    /**
096     * 
097     * @param endDateIn Date
098     */
099    public void setEndDate(Date endDateIn)
100    {
101        this.endDate = endDateIn;
102    }
103
104    // Generate 1 associations
105    private AppliedStrategy appliedStrategy;
106
107    /**
108     * Une stratégie applicable est la stratégie qui s'applique pour un lieu de surveillance donné
109     * durant
110     * un interval de dates défini.
111     * @return this.appliedStrategy AppliedStrategy
112     */
113    public AppliedStrategy getAppliedStrategy()
114    {
115        return this.appliedStrategy;
116    }
117
118    /**
119     * Une stratégie applicable est la stratégie qui s'applique pour un lieu de surveillance donné
120     * durant
121     * un interval de dates défini.
122     * @param appliedStrategyIn AppliedStrategy
123     */
124    public void setAppliedStrategy(AppliedStrategy appliedStrategyIn)
125    {
126        this.appliedStrategy = appliedStrategyIn;
127    }
128
129    /**
130     * Returns <code>true</code> if the argument is an AppliedPeriod instance and all identifiers for this entity
131     * equal the identifiers of the argument entity. Returns <code>false</code> otherwise.
132     */
133    @Override
134    public boolean equals(Object object)
135    {
136        if (this == object)
137        {
138            return true;
139        }
140        if (!(object instanceof AppliedPeriod))
141        {
142            return false;
143        }
144        final AppliedPeriod that = (AppliedPeriod)object;
145        if (this.appliedPeriodPk == null || that.appliedPeriodPk == null || !this.appliedPeriodPk.equals(that.appliedPeriodPk))
146        {
147            return false;
148        }
149        return true;
150    }
151
152    /**
153     * Returns a hash code based on this entity's identifiers.
154     */
155    @Override
156    public int hashCode()
157    {
158        int hashCode = 0;
159        hashCode = 29 * hashCode + (this.appliedPeriodPk == null ? 0 : this.appliedPeriodPk.hashCode());
160
161        return hashCode;
162    }
163
164    /**
165     * Constructs new instances of {@link AppliedPeriod}.
166     */
167    public static final class Factory
168    {
169        /**
170         * Constructs a new instance of {@link AppliedPeriod}.
171         * @return new AppliedPeriodImpl()
172         */
173        public static AppliedPeriod newInstance()
174        {
175            return new AppliedPeriodImpl();
176        }
177
178
179        /**
180         * Constructs a new instance of {@link AppliedPeriod}, taking all possible properties
181         * (except the identifier(s))as arguments.
182         * @param endDate Date
183         * @param appliedStrategy AppliedStrategy
184         * @return newInstance AppliedPeriod
185         */
186        public static AppliedPeriod newInstance(Date endDate, AppliedStrategy appliedStrategy)
187        {
188            final AppliedPeriod entity = new AppliedPeriodImpl();
189            entity.setEndDate(endDate);
190            entity.setAppliedStrategy(appliedStrategy);
191            return entity;
192        }
193    }
194
195    /**
196     * @see Comparable#compareTo
197     */
198    public int compareTo(AppliedPeriod o)
199    {
200        int cmp = 0;
201        if (this.getAppliedPeriodPk() != null)
202        {
203            cmp = this.getAppliedPeriodPk().compareTo(o.getAppliedPeriodPk());
204        }
205        else
206        {
207            if (this.getEndDate() != null)
208            {
209                cmp = (cmp != 0 ? cmp : this.getEndDate().compareTo(o.getEndDate()));
210            }
211        }
212        return cmp;
213    }
214// HibernateEntity.vsl merge-point
215// AppliedPeriod.java merge-point
216}