View Javadoc
1   /**
2    * Copyright 2010-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.common.util.metainf.model;
17  
18  import org.apache.commons.lang3.StringUtils;
19  
20  import com.google.common.base.Preconditions;
21  
22  public final class MetaInfResource implements Comparable<MetaInfResource> {
23  
24  	public static final long UNKNOWN_SIZE = -1;
25  	public static final long UNKNOWN_LINECOUNT = -1;
26  
27  	private final String location;
28  	private final long size;
29  	private final long lineCount;
30  
31  	public MetaInfResource(String location) {
32  		this(location, UNKNOWN_SIZE, UNKNOWN_LINECOUNT);
33  	}
34  
35  	public MetaInfResource(String location, long size, long lineCount) {
36  		Preconditions.checkArgument(!StringUtils.isBlank(location), "'location' cannot be blank");
37  		Preconditions.checkArgument(size == -1 || size >= 0, "'size' must be >= zero. Use %s to indicate unknown", UNKNOWN_SIZE);
38  		Preconditions.checkArgument(lineCount == -1 || lineCount >= 0, "'lineCount' must be >= zero. Use %s to indicate unknown", UNKNOWN_LINECOUNT);
39  		this.location = location;
40  		this.size = size;
41  		this.lineCount = lineCount;
42  	}
43  
44  	@Override
45  	public int compareTo(MetaInfResource other) {
46  		return location.compareTo(other.getLocation());
47  	}
48  
49  	public String getLocation() {
50  		return location;
51  	}
52  
53  	public long getSize() {
54  		return size;
55  	}
56  
57  	public long getLineCount() {
58  		return lineCount;
59  	}
60  
61  }