1 /*
2 * Copyright (C) 2017 Two Sigma Open Source and others
3 *
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Distribution License v. 1.0 which is available at
6 * https://www.eclipse.org/org/documents/edl-v10.php.
7 *
8 * SPDX-License-Identifier: BSD-3-Clause
9 */
10
11 package org.eclipse.jgit.transport;
12
13 import java.io.Serializable;
14
15 /**
16 * Describes the expected value for a ref being pushed.
17 *
18 * @since 4.7
19 */
20 public class RefLeaseSpec implements Serializable {
21 private static final long serialVersionUID = 1L;
22
23 /** Name of the ref whose value we want to check. */
24 private final String ref;
25
26 /** Local commitish to get expected value from. */
27 private final String expected;
28
29 /**
30 * <p>Constructor for RefLeaseSpec.</p>
31 *
32 * @param ref
33 * ref being pushed
34 * @param expected
35 * the expected value of the ref
36 */
37 public RefLeaseSpec(String ref, String expected) {
38 this.ref = ref;
39 this.expected = expected;
40 }
41
42 /**
43 * Get the ref to protect.
44 *
45 * @return name of ref to check.
46 */
47 public String getRef() {
48 return ref;
49 }
50
51 /**
52 * Get the expected value of the ref, in the form
53 * of a local committish
54 *
55 * @return expected ref value.
56 */
57 public String getExpected() {
58 return expected;
59 }
60
61 /** {@inheritDoc} */
62 @Override
63 public String toString() {
64 final StringBuilder r = new StringBuilder();
65 r.append(getRef());
66 r.append(':');
67 r.append(getExpected());
68 return r.toString();
69 }
70 }