View Javadoc
1   /*
2    * Licensed under the GPL License. You may not use this file except in compliance with the License.
3    * You may obtain a copy of the License at
4    *
5    *   https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
6    *
7    * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
8    * WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
9    * PURPOSE.
10   */
11  package psiprobe.model;
12  
13  /**
14   * This POJO represents a group of datasources. It provides methods for adding values to aggregated
15   * totals of the group. The class is a part of the ListAllJdbcResourceGroupsController model.
16   */
17  public class DataSourceInfoGroup extends DataSourceInfo {
18  
19    /** The data source count. */
20    private int dataSourceCount;
21  
22    /**
23     * Instantiates a new data source info group.
24     */
25    public DataSourceInfoGroup() {
26      this.setJdbcUrl(null);
27      this.setBusyConnections(0);
28      this.setEstablishedConnections(0);
29      this.setMaxConnections(0);
30    }
31  
32    /**
33     * Instantiates a new data source info group.
34     *
35     * @param dataSourceInfo the data source info
36     *
37     * @return the data source info group
38     */
39    public DataSourceInfoGroup builder(DataSourceInfo dataSourceInfo) {
40      this.setJdbcUrl(dataSourceInfo.getJdbcUrl());
41      this.setBusyConnections(dataSourceInfo.getBusyConnections());
42      this.setEstablishedConnections(dataSourceInfo.getEstablishedConnections());
43      this.setMaxConnections(dataSourceInfo.getMaxConnections());
44      this.setDataSourceCount(1);
45      return this;
46    }
47  
48    /**
49     * Gets the data source count.
50     *
51     * @return the data source count
52     */
53    public int getDataSourceCount() {
54      return dataSourceCount;
55    }
56  
57    /**
58     * Sets the data source count.
59     *
60     * @param dataSourceCount the new data source count
61     */
62    public void setDataSourceCount(int dataSourceCount) {
63      this.dataSourceCount = dataSourceCount;
64    }
65  
66    /**
67     * Adds the busy connections.
68     *
69     * @param busyConnectionsDelta the busy connections delta
70     */
71    public void addBusyConnections(int busyConnectionsDelta) {
72      setBusyConnections(getBusyConnections() + busyConnectionsDelta);
73    }
74  
75    /**
76     * Adds the established connections.
77     *
78     * @param establishedConnectionsDelta the established connections delta
79     */
80    public void addEstablishedConnections(int establishedConnectionsDelta) {
81      setEstablishedConnections(getEstablishedConnections() + establishedConnectionsDelta);
82    }
83  
84    /**
85     * Adds the max connections.
86     *
87     * @param maxConnectionsDelta the max connections delta
88     */
89    public void addMaxConnections(int maxConnectionsDelta) {
90      setMaxConnections(getMaxConnections() + maxConnectionsDelta);
91    }
92  
93    /**
94     * Adds the data source count.
95     *
96     * @param dataSourceCountDelta the data source count delta
97     */
98    public void addDataSourceCount(int dataSourceCountDelta) {
99      setDataSourceCount(getDataSourceCount() + dataSourceCountDelta);
100   }
101 
102   /**
103    * Adds the data source info.
104    *
105    * @param dataSourceInfoDelta the data source info delta
106    */
107   public void addDataSourceInfo(DataSourceInfo dataSourceInfoDelta) {
108     addBusyConnections(dataSourceInfoDelta.getBusyConnections());
109     addEstablishedConnections(dataSourceInfoDelta.getEstablishedConnections());
110     addMaxConnections(dataSourceInfoDelta.getMaxConnections());
111     addDataSourceCount(1);
112   }
113 
114 }