View Javadoc

1   /*
2   Copyright 2010 James Pether Sörling Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 
3   	$Id
4   */
5   package com.hack23.cia.model.sweden.impl;
6   
7   import javax.persistence.DiscriminatorValue;
8   import javax.persistence.Entity;
9   import javax.persistence.Transient;
10  
11  import org.hibernate.annotations.Cache;
12  import org.hibernate.annotations.CacheConcurrencyStrategy;
13  
14  /***
15   * The Class BallotResult.
16   */
17  @Entity
18  @DiscriminatorValue("BallotResult")
19  @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
20  public class BallotResult extends AbstractBallotResult {
21  
22  	/*** The Constant serialVersionUID. */
23  	private static final long serialVersionUID = 1L;
24  
25  	/***
26  	 * Instantiates a new ballot result.
27  	 */
28  	public BallotResult() {
29  		super();
30  	}
31  	
32  	/***
33  	 * Checks if is losing vote.
34  	 *
35  	 * @param vote the vote
36  	 * @return true, if is losing vote
37  	 */
38  	@Transient
39  	public boolean isLosingVote(final Vote vote) {
40  		if (Vote.Position.Absent.equals(vote.getPosition())) {
41  			return false;
42  		} else {
43  			return !getWinningPosition().equals(vote.getPosition());
44  		}		
45  	}
46  }