1
2
3
4
5
6
7
8
9
10
11
12
13
14
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 }