aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse/jgit/transport/RefLeaseSpec.java
blob: 8a131c897131c4a75ab9b31968a8b787c4c7f6f0 (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
/*
 * Copyright (C) 2017 Two Sigma Open Source 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.io.Serializable;

/**
 * Describes the expected value for a ref being pushed.
 *
 * @since 4.7
 */
public class RefLeaseSpec implements Serializable {
	private static final long serialVersionUID = 1L;

	/** Name of the ref whose value we want to check. */
	private final String ref;

	/** Local commitish to get expected value from. */
	private final String expected;

	/**
	 * <p>Constructor for RefLeaseSpec.</p>
	 *
	 * @param ref
	 *            ref being pushed
	 * @param expected
	 *            the expected value of the ref
	 */
	public RefLeaseSpec(String ref, String expected) {
		this.ref = ref;
		this.expected = expected;
	}

	/**
	 * Get the ref to protect.
	 *
	 * @return name of ref to check.
	 */
	public String getRef() {
		return ref;
	}

	/**
	 * Get the expected value of the ref, in the form
	 * of a local committish
	 *
	 * @return expected ref value.
	 */
	public String getExpected() {
		return expected;
	}

	@Override
	public String toString() {
		final StringBuilder r = new StringBuilder();
		r.append(getRef());
		r.append(':');
		r.append(getExpected());
		return r.toString();
	}
}