001    /**
002     * Copyright 2010-2013 The Kuali Foundation
003     *
004     * Licensed under the Educational Community License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.opensource.org/licenses/ecl2.php
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.kuali.common.jdbc.model;
017    
018    import java.util.Collections;
019    import java.util.List;
020    
021    import org.kuali.common.jdbc.suppliers.SqlSupplier;
022    import org.kuali.common.util.Assert;
023    import org.kuali.common.util.ListUtils;
024    
025    public final class SqlBucket implements Comparable<SqlBucket> {
026    
027            public static final long DEFAULT_COUNT = 0;
028            public static final long DEFAULT_SIZE = 0;
029            public static List<SqlSupplier> DEFAULT_SUPPLIERS = Collections.<SqlSupplier> emptyList();
030    
031            private final long count;
032            private final long size;
033            private final List<SqlSupplier> suppliers;
034    
035            public SqlBucket() {
036                    this(DEFAULT_COUNT, DEFAULT_SIZE, DEFAULT_SUPPLIERS);
037            }
038    
039            public SqlBucket(long count, long size, List<SqlSupplier> suppliers) {
040                    Assert.noNulls(suppliers);
041                    this.count = count;
042                    this.size = size;
043                    this.suppliers = ListUtils.newImmutableArrayList(suppliers);
044            }
045    
046            @Override
047            public int compareTo(SqlBucket other) {
048                    return Double.compare(size, other.getSize());
049            }
050    
051            public long getCount() {
052                    return count;
053            }
054    
055            public long getSize() {
056                    return size;
057            }
058    
059            public List<SqlSupplier> getSuppliers() {
060                    return suppliers;
061            }
062    }