001/** 002 * Copyright 2010-2014 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 */ 016package org.kuali.common.util.metainf.model; 017 018import org.apache.commons.lang3.StringUtils; 019 020import com.google.common.base.Preconditions; 021 022public final class MetaInfResource implements Comparable<MetaInfResource> { 023 024 public static final long UNKNOWN_SIZE = -1; 025 public static final long UNKNOWN_LINECOUNT = -1; 026 027 private final String location; 028 private final long size; 029 private final long lineCount; 030 031 public MetaInfResource(String location) { 032 this(location, UNKNOWN_SIZE, UNKNOWN_LINECOUNT); 033 } 034 035 public MetaInfResource(String location, long size, long lineCount) { 036 Preconditions.checkArgument(!StringUtils.isBlank(location), "'location' cannot be blank"); 037 Preconditions.checkArgument(size == -1 || size >= 0, "'size' must be >= zero. Use %s to indicate unknown", UNKNOWN_SIZE); 038 Preconditions.checkArgument(lineCount == -1 || lineCount >= 0, "'lineCount' must be >= zero. Use %s to indicate unknown", UNKNOWN_LINECOUNT); 039 this.location = location; 040 this.size = size; 041 this.lineCount = lineCount; 042 } 043 044 @Override 045 public int compareTo(MetaInfResource other) { 046 return location.compareTo(other.getLocation()); 047 } 048 049 public String getLocation() { 050 return location; 051 } 052 053 public long getSize() { 054 return size; 055 } 056 057 public long getLineCount() { 058 return lineCount; 059 } 060 061}