aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse/jgit/transport/ObjectInfoRequest.java
blob: 241f1e749faac43d8f72498d0b0e4e8ef44c71fe (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
/*
 * Copyright (C) 2021, 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
 * https://www.eclipse.org/org/documents/edl-v10.php.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */
package org.eclipse.jgit.transport;

import java.util.Collections;
import java.util.List;

import org.eclipse.jgit.lib.ObjectId;

/**
 * object-info request.
 *
 * <p>
 * This is the parsed request for an object-info call, used as input to
 * {@link ProtocolV2Hook}.
 *
 * @see <a href=
 *      "https://www.kernel.org/pub/software/scm/git/docs/technical/protocol-v2.html#_object_info">object-info
 *      documentation</a>
 *
 * @since 5.13
 */
public final class ObjectInfoRequest {
	private final List<ObjectId> objectIDs;

	private ObjectInfoRequest(List<ObjectId> objectIDs) {
		this.objectIDs = objectIDs;
	}

	/**
	 * Get object ids requested by the client
	 *
	 * @return object IDs that the client requested.
	 */
	public List<ObjectId> getObjectIDs() {
		return this.objectIDs;
	}

	/**
	 * Create builder
	 *
	 * @return A builder of {@link ObjectInfoRequest}.
	 */
	public static Builder builder() {
		return new Builder();
	}

	/** A builder for {@link ObjectInfoRequest}. */
	public static final class Builder {
		private List<ObjectId> objectIDs = Collections.emptyList();

		private Builder() {
		}

		/**
		 * Set object ids
		 *
		 * @param value
		 *            of objectIds
		 * @return the Builder
		 */
		public Builder setObjectIDs(List<ObjectId> value) {
			objectIDs = value;
			return this;
		}

		/**
		 * Build the request
		 *
		 * @return ObjectInfoRequest the request
		 */
		public ObjectInfoRequest build() {
			return new ObjectInfoRequest(
					Collections.unmodifiableList(objectIDs));
		}
	}
}