aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsObjectRepresentation.java
blob: 885582fae2372e7f50f50c227e6e8b38ca03fc3e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
 * Copyright (C) 2011, Google Inc. and others
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Distribution License v. 1.0 which is available at
 * https://www.eclipse.org/org/documents/edl-v10.php.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

package org.eclipse.jgit.internal.storage.dfs;

import org.eclipse.jgit.internal.storage.pack.StoredObjectRepresentation;
import org.eclipse.jgit.lib.ObjectId;

class DfsObjectRepresentation extends StoredObjectRepresentation {
	final DfsPackFile pack;
	int format;
	long offset;
	long length;
	ObjectId baseId;

	DfsObjectRepresentation(DfsPackFile pack) {
		this.pack = pack;
	}

	@Override
	public int getFormat() {
		return format;
	}

	@Override
	public int getWeight() {
		return (int) Math.min(length, Integer.MAX_VALUE);
	}

	@Override
	public ObjectId getDeltaBase() {
		return baseId;
	}

	@Override
	public boolean wasDeltaAttempted() {
		switch (pack.getPackDescription().getPackSource()) {
		case GC:
		case GC_REST:
			return true;
		default:
			return false;
		}
	}
}