Ref { public static Ref createHeadRef(int headOffset) { CheckUtilities.checkIntArgumentGreaterThan(headOffset, -1, "headOffset"); if (0 == headOffset) { return HEAD; } else if (1 == headOffset) { return HEAD_1; } Ref cn = new Ref(); cn.refType = RefType.HEAD; cn.headOffset = headOffset; return cn; }  static Ref createBranchRef(String name); static Ref createHeadRef(int headOffset); static Ref createRemoteRef(String repositoryName, String name); static Ref createSha1Ref(String name); static Ref createTagRef(String name); Ref.RefType getRefType(); int getHeadOffset(); String getName(); String getRepositoryName(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); static final Ref HEAD; static final Ref HEAD_1; }
@Test public void testCreateHeadRef() { assertIllegalCreateHeadRefArgument(-1, "000004: The int argument is not greater than the lower bound (lowerBound < toCheck). " + "{ toCheck=[-1], lowerBound=[-1], variableName=[headOffset] }"); assertIllegalCreateHeadRefArgument(-23, "000004: The int argument is not greater than the lower bound (lowerBound < toCheck). " + "{ toCheck=[-23], lowerBound=[-1], variableName=[headOffset] }"); Ref ref = Ref.createHeadRef(0); assertEquals(ref, Ref.HEAD); assertTrue(Ref.HEAD == ref); assertEquals(ref.toString(), "HEAD"); ref.hashCode(); ref = Ref.createHeadRef(1); assertEquals(ref, Ref.HEAD_1); assertTrue(Ref.HEAD_1 == ref); assertEquals(ref.toString(), "HEAD^1"); ref.hashCode(); ref = Ref.createHeadRef(2); assertEquals("Expected RefType of HEAD.", ref.getRefType(), Ref.RefType.HEAD); assertEquals(ref.getHeadOffset(), 2); assertEquals(ref.getName(), null); assertEquals(ref.getRepositoryName(), null); assertEquals(ref.toString(), "HEAD~2"); ref.hashCode(); ref = Ref.createHeadRef(50); assertEquals("Expected RefType of HEAD.", ref.getRefType(), Ref.RefType.HEAD); assertEquals(ref.getHeadOffset(), 50); assertEquals(ref.getName(), null); assertEquals(ref.getRepositoryName(), null); assertEquals(ref.toString(), "HEAD~50"); ref.hashCode(); }