annotate src/org/tmatesoft/hg/util/Pair.java @ 388:b015f3918120

Work on FIXME: correct HgDataFile#workingCopy with tests; BasicSessionContext with property override; platform-specific options to internals
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Wed, 15 Feb 2012 22:57:56 +0100
parents fd845a53f53d
children 5311e041d2dd
rev   line source
235
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
1 /*
388
b015f3918120 Work on FIXME: correct HgDataFile#workingCopy with tests; BasicSessionContext with property override; platform-specific options to internals
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 235
diff changeset
2 * Copyright (c) 2011-2012 TMate Software Ltd
235
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
3 *
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
4 * This program is free software; you can redistribute it and/or modify
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
6 * the Free Software Foundation; version 2 of the License.
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
7 *
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
8 * This program is distributed in the hope that it will be useful,
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
11 * GNU General Public License for more details.
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
12 *
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
13 * For information on how to redistribute this software under
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
14 * the terms of a license other than GNU General Public License
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
15 * contact TMate Software at support@hg4j.com
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
16 */
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
17 package org.tmatesoft.hg.util;
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
18
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
19 import org.tmatesoft.hg.internal.Experimental;
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
20
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
21 /**
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
22 * Nothing but a holder for two values.
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
23 *
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
24 * @author Artem Tikhomirov
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
25 * @author TMate Software Ltd.
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
26 */
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
27 @Experimental
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
28 public final class Pair<T1,T2> {
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
29 private final T1 value1;
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
30 private final T2 value2;
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
31
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
32 public Pair(T1 v1, T2 v2) {
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
33 value1 = v1;
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
34 value2 = v2;
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
35 }
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
36
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
37 public T1 first() {
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
38 return value1;
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
39 }
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
40 public T2 second() {
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
41 return value2;
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
42 }
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
43 public boolean hasFirst() {
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
44 return value1 != null;
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
45 }
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
46 public boolean hasSecond() {
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
47 return value2 != null;
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
48 }
388
b015f3918120 Work on FIXME: correct HgDataFile#workingCopy with tests; BasicSessionContext with property override; platform-specific options to internals
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 235
diff changeset
49
b015f3918120 Work on FIXME: correct HgDataFile#workingCopy with tests; BasicSessionContext with property override; platform-specific options to internals
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 235
diff changeset
50 @Override
b015f3918120 Work on FIXME: correct HgDataFile#workingCopy with tests; BasicSessionContext with property override; platform-specific options to internals
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 235
diff changeset
51 public String toString() {
b015f3918120 Work on FIXME: correct HgDataFile#workingCopy with tests; BasicSessionContext with property override; platform-specific options to internals
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 235
diff changeset
52 StringBuilder sb = new StringBuilder();
b015f3918120 Work on FIXME: correct HgDataFile#workingCopy with tests; BasicSessionContext with property override; platform-specific options to internals
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 235
diff changeset
53 sb.append('<');
b015f3918120 Work on FIXME: correct HgDataFile#workingCopy with tests; BasicSessionContext with property override; platform-specific options to internals
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 235
diff changeset
54 sb.append(first());
b015f3918120 Work on FIXME: correct HgDataFile#workingCopy with tests; BasicSessionContext with property override; platform-specific options to internals
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 235
diff changeset
55 sb.append(':');
b015f3918120 Work on FIXME: correct HgDataFile#workingCopy with tests; BasicSessionContext with property override; platform-specific options to internals
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 235
diff changeset
56 sb.append(second());
b015f3918120 Work on FIXME: correct HgDataFile#workingCopy with tests; BasicSessionContext with property override; platform-specific options to internals
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 235
diff changeset
57 sb.append('>');
b015f3918120 Work on FIXME: correct HgDataFile#workingCopy with tests; BasicSessionContext with property override; platform-specific options to internals
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 235
diff changeset
58 return sb.toString();
b015f3918120 Work on FIXME: correct HgDataFile#workingCopy with tests; BasicSessionContext with property override; platform-specific options to internals
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 235
diff changeset
59 }
235
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
60 }
fd845a53f53d Experimental access to working dir parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
61