BrightSide Workbench Full Report + Source Code
ContractPreference.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2011 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 package org.turro.financials.entity;
19 
20 import javax.persistence.*;
21 import org.turro.util.CompareUtil;
22 import org.zkoss.lang.Strings;
23 
28 @Entity
29 public class ContractPreference implements java.io.Serializable, Comparable<ContractPreference> {
30 
31  @Id
32  @GeneratedValue(strategy=GenerationType.IDENTITY)
33  @Column(name="IDENTIFIER")
34  private long id;
35 
36  @ManyToOne
37  private ContractDefinition contractDefinition;
38 
39  private String name;
40 
41  private String asOperating, asTax, asRetention, asContact, asCash;
42 
43  public String getAsOperating() {
44  return asOperating;
45  }
46 
47  public void setAsOperating(String asOperating) {
48  this.asOperating = asOperating;
49  }
50 
51  public String getAsRetention() {
52  return asRetention;
53  }
54 
55  public void setAsRetention(String asRetention) {
56  this.asRetention = asRetention;
57  }
58 
59  public String getAsTax() {
60  return asTax;
61  }
62 
63  public void setAsTax(String asTax) {
64  this.asTax = asTax;
65  }
66 
68  return contractDefinition;
69  }
70 
71  public void setContractDefinition(ContractDefinition contractDefinition) {
72  this.contractDefinition = contractDefinition;
73  }
74 
75  public long getId() {
76  return id;
77  }
78 
79  public void setId(long id) {
80  this.id = id;
81  }
82 
83  public String getName() {
84  return name;
85  }
86 
87  public void setName(String name) {
88  this.name = name;
89  }
90 
91  public String getAsCash() {
92  return asCash;
93  }
94 
95  public void setAsCash(String asCash) {
96  this.asCash = asCash;
97  }
98 
99  public String getAsContact() {
100  return asContact;
101  }
102 
103  public void setAsContact(String asContact) {
104  this.asContact = asContact;
105  }
106 
107  /* Helpers */
108 
109  public boolean isEmpty() {
110  return contractDefinition == null || Strings.isEmpty(name);
111  }
112 
113  /* Format helpers */
114 
115  public String getAsOperating(Contract contract) {
116  return asOperating.replaceAll("%om", contract.getOperatingModifier().ordinal() + "");
117  }
118 
119  public String getAsRetention(Contract contract) {
120  return asRetention.replaceAll("%om", contract.getOperatingModifier().ordinal() + "");
121  }
122 
123  public String getAsTax(Contract contract) {
124  return asTax.replaceAll("%om", contract.getOperatingModifier().ordinal() + "");
125  }
126 
127  @Override
129  int result = CompareUtil.compare(name, o.name);
130  if(result == 0) {
131  result = CompareUtil.compare(id, o.id);
132  }
133  return result;
134  }
135 
136 }
void setContractDefinition(ContractDefinition contractDefinition)
OperatingModifier getOperatingModifier()
Definition: Contract.java:228