View Javadoc
1   /*
2    * This file is part of Waarp Project (named also Waarp or GG).
3    *
4    *  Copyright (c) 2019, Waarp SAS, and individual contributors by the @author
5    *  tags. See the COPYRIGHT.txt in the distribution for a full listing of
6    * individual contributors.
7    *
8    *  All Waarp Project is free software: you can redistribute it and/or
9    * modify it under the terms of the GNU General Public License as published by
10   * the Free Software Foundation, either version 3 of the License, or (at your
11   * option) any later version.
12   *
13   * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY
14   * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15   * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16   *
17   *  You should have received a copy of the GNU General Public License along with
18   * Waarp . If not, see <http://www.gnu.org/licenses/>.
19   */
20  
21  package org.waarp.openr66.pojo;
22  
23  import com.fasterxml.jackson.annotation.JsonIgnore;
24  import com.fasterxml.jackson.annotation.JsonProperty;
25  import org.waarp.common.database.exception.WaarpDatabaseSqlException;
26  
27  import java.sql.Types;
28  
29  import static org.waarp.common.database.data.AbstractDbData.*;
30  
31  /**
32   * Limit data object
33   */
34  public class Limit {
35  
36    @JsonProperty("HOSTID")
37    private String hostid;
38  
39    @JsonProperty("READGLOBALLIMIT")
40    private long readGlobalLimit;
41  
42    @JsonProperty("WRITEGLOBALLIMIT")
43    private long writeGlobalLimit;
44  
45    @JsonProperty("READSESSIONLIMIT")
46    private long readSessionLimit;
47  
48    @JsonProperty("WRITESESSIONLIMIT")
49    private long writeSessionLimit;
50  
51    @JsonProperty("DELAYLIMIT")
52    private long delayLimit;
53  
54    @JsonProperty("UPDATEDINFO")
55    private UpdatedInfo updatedInfo = UpdatedInfo.UNKNOWN;
56  
57    /**
58     * Empty constructor
59     */
60    public Limit() {
61      // Nothing
62    }
63  
64    public Limit(final String hostid, final long delayLimit,
65                 final long readGlobalLimit, final long writeGlobalLimit,
66                 final long readSessionLimit, final long writeSessionLimit,
67                 final UpdatedInfo updatedInfo) throws WaarpDatabaseSqlException {
68      this(hostid, delayLimit, readGlobalLimit, writeGlobalLimit,
69           readSessionLimit, writeSessionLimit);
70      this.updatedInfo = updatedInfo;
71    }
72  
73    public Limit(final String hostid, final long delayLimit,
74                 final long readGlobalLimit, final long writeGlobalLimit,
75                 final long readSessionLimit, final long writeSessionLimit)
76        throws WaarpDatabaseSqlException {
77      this.hostid = hostid;
78      this.delayLimit = delayLimit;
79      this.readGlobalLimit = readGlobalLimit;
80      this.writeGlobalLimit = writeGlobalLimit;
81      this.readSessionLimit = readSessionLimit;
82      this.writeSessionLimit = writeSessionLimit;
83      checkValues();
84    }
85  
86    public Limit(final String hostid, final long delayLimit)
87        throws WaarpDatabaseSqlException {
88      this(hostid, delayLimit, 0, 0, 0, 0);
89    }
90  
91    @JsonIgnore
92    public final void checkValues() throws WaarpDatabaseSqlException {
93      validateLength(Types.NVARCHAR, hostid);
94    }
95  
96    public final String getHostid() {
97      return hostid;
98    }
99  
100   public final void setHostid(final String hostid) {
101     this.hostid = hostid;
102   }
103 
104   public final long getReadGlobalLimit() {
105     return readGlobalLimit;
106   }
107 
108   public final void setReadGlobalLimit(final long readGlobalLimit) {
109     this.readGlobalLimit = readGlobalLimit;
110   }
111 
112   public final long getWriteGlobalLimit() {
113     return writeGlobalLimit;
114   }
115 
116   public final void setWriteGlobalLimit(final long writeGlobalLimit) {
117     this.writeGlobalLimit = writeGlobalLimit;
118   }
119 
120   public final long getReadSessionLimit() {
121     return readSessionLimit;
122   }
123 
124   public final void setReadSessionLimit(final long readSessionLimit) {
125     this.readSessionLimit = readSessionLimit;
126   }
127 
128   public final long getWriteSessionLimit() {
129     return writeSessionLimit;
130   }
131 
132   public final void setWriteSessionLimit(final long writeSessionLimit) {
133     this.writeSessionLimit = writeSessionLimit;
134   }
135 
136   public final long getDelayLimit() {
137     return delayLimit;
138   }
139 
140   public final void setDelayLimit(final long delayLimit) {
141     this.delayLimit = delayLimit;
142   }
143 
144   public final UpdatedInfo getUpdatedInfo() {
145     return updatedInfo;
146   }
147 
148   public final void setUpdatedInfo(final UpdatedInfo info) {
149     updatedInfo = info;
150   }
151 }