blob: 33c478e4abfff62acf753c6b6e04c1c9c476f36f (
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
/*
* Copyright (c) 2020, Google LLC 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
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.internal.storage.pack;
import org.eclipse.jgit.lib.AnyObjectId;
import org.eclipse.jgit.lib.ObjectId;
/**
* A commit object for which a bitmap index should be built.
*/
public final class BitmapCommit extends ObjectId {
private final boolean reuseWalker;
private final int flags;
private final boolean addToIndex;
BitmapCommit(AnyObjectId objectId, boolean reuseWalker, int flags) {
super(objectId);
this.reuseWalker = reuseWalker;
this.flags = flags;
this.addToIndex = false;
}
BitmapCommit(AnyObjectId objectId, boolean reuseWalker, int flags,
boolean addToIndex) {
super(objectId);
this.reuseWalker = reuseWalker;
this.flags = flags;
this.addToIndex = addToIndex;
}
boolean isReuseWalker() {
return reuseWalker;
}
int getFlags() {
return flags;
}
/**
* Whether corresponding bitmap should be added to PackBitmapIndexBuilder.
*
* @return true if the corresponding bitmap should be added to
* PackBitmapIndexBuilder.
*/
public boolean isAddToIndex() {
return addToIndex;
}
/**
* Get a builder of BitmapCommit whose object id is {@code objId}.
*
* @param objId
* the object id of the BitmapCommit
* @return a BitmapCommit builder with object id set.
*/
public static Builder newBuilder(AnyObjectId objId) {
return new Builder().setId(objId);
}
/**
* Get a builder of BitmapCommit whose fields are copied from
* {@code commit}.
*
* @param commit
* the bitmap commit the builder is copying from
* @return a BitmapCommit build with fields copied from an existing bitmap
* commit.
*/
public static Builder copyFrom(BitmapCommit commit) {
return new Builder().setId(commit)
.setReuseWalker(commit.isReuseWalker())
.setFlags(commit.getFlags())
.setAddToIndex(commit.isAddToIndex());
}
/**
* Builder of BitmapCommit.
*/
public static class Builder {
private AnyObjectId objectId;
private boolean reuseWalker;
private int flags;
private boolean addToIndex;
// Prevent default constructor.
private Builder() {
}
/**
* Set objectId of the builder.
*
* @param objectId
* the object id of the BitmapCommit
* @return the builder itself
*/
public Builder setId(AnyObjectId objectId) {
this.objectId = objectId;
return this;
}
/**
* Set reuseWalker of the builder.
*
* @param reuseWalker
* whether the BitmapCommit should reuse bitmap walker when
* walking objects
* @return the builder itself
*/
public Builder setReuseWalker(boolean reuseWalker) {
this.reuseWalker = reuseWalker;
return this;
}
/**
* Set flags of the builder.
*
* @param flags
* the flags of the BitmapCommit
* @return the builder itself
*/
public Builder setFlags(int flags) {
this.flags = flags;
return this;
}
/**
* Set whether whether the bitmap of the BitmapCommit should be added to
* PackBitmapIndexBuilder when building bitmap index file.
*
* @param addToIndex
* whether the bitmap of the BitmapCommit should be added to
* PackBitmapIndexBuilder when building bitmap index file
* @return the builder itself
*/
public Builder setAddToIndex(boolean addToIndex) {
this.addToIndex = addToIndex;
return this;
}
/**
* Builds BitmapCommit from the builder.
*
* @return the new BitmapCommit.
*/
public BitmapCommit build() {
return new BitmapCommit(objectId, reuseWalker, flags,
addToIndex);
}
}
}
|