• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

oracle / opengrok / #3691

09 Nov 2023 04:15PM UTC coverage: 74.721% (+8.6%) from 66.08%
#3691

push

web-flow
avoid annotations for binary files (#4476)

fixes #4473

6 of 13 new or added lines in 4 files covered. (46.15%)

258 existing lines in 28 files now uncovered.

43797 of 58614 relevant lines covered (74.72%)

0.75 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

50.0
/opengrok-indexer/src/main/java/org/opengrok/indexer/history/TagEntry.java
1
/*
2
 * CDDL HEADER START
3
 *
4
 * The contents of this file are subject to the terms of the
5
 * Common Development and Distribution License (the "License").
6
 * You may not use this file except in compliance with the License.
7
 *
8
 * See LICENSE.txt included in this distribution for the specific
9
 * language governing permissions and limitations under the License.
10
 *
11
 * When distributing Covered Code, include this CDDL HEADER in each
12
 * file and include the License file at LICENSE.txt.
13
 * If applicable, add the following below this CDDL HEADER, with the
14
 * fields enclosed by brackets "[]" replaced with your own identifying
15
 * information: Portions Copyright [yyyy] [name of copyright owner]
16
 *
17
 * CDDL HEADER END
18
 */
19

20
/*
21
 * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
22
 * Portions Copyright (c) 2017, 2020, Chris Fraire <cfraire@me.com>.
23
 */
24
package org.opengrok.indexer.history;
25

26
import java.util.Date;
27

28
/**
29
 * Represents an identifier for a version control "commit" (also known as a
30
 * "changeset") where the version control system uses either monotonic, linear
31
 * revision numbering; or alternatively where OpenGrok uses "commit time" as a
32
 * proxy for ancestry.
33
 *
34
 * @author Stanislav Kozina
35
 */
36
public abstract class TagEntry implements Comparable<TagEntry> {
1✔
37

38
    private static final String DATE_NULL_ASSERT = "date == null";
39

40
    /**
41
     * If repo uses linear revision numbering.
42
     */
43
    protected final int revision;
44
    /**
45
     * If repo does not use linear numbering.
46
     */
47
    protected final Date date;
48
    /**
49
     * Tag of the revision.
50
     */
51
    protected String tags;
52
    /**
53
     * Sentinel value for a repo that does not use linear numbering.
54
     */
55
    protected static final int NOREV = -1;
56

57
    /**
58
     * Initializes an instance for a repo where revision number is present.
59
     *
60
     * @param revision revision number
61
     * @param tags string representing tags
62
     */
UNCOV
63
    protected TagEntry(int revision, String tags) {
×
UNCOV
64
        this.revision = revision;
×
UNCOV
65
        this.date = null;
×
UNCOV
66
        this.tags = tags;
×
UNCOV
67
    }
×
68

69
    /**
70
     * Initializes an instance for a repo where revision number is not present
71
     * and {@code date} is used instead.
72
     *
73
     * @param date revision date
74
     * @param tags string representing tags
75
     * @throws IllegalArgumentException if {@code date} is null
76
     */
77
    protected TagEntry(Date date, String tags) {
1✔
78
        if (date == null) {
1✔
79
            throw new IllegalArgumentException("`date' is null");
×
80
        }
81
        this.revision = NOREV;
1✔
82
        this.date = date;
1✔
83
        this.tags = tags;
1✔
84
    }
1✔
85

86
    public String getTags() {
UNCOV
87
        return this.tags;
×
88
    }
89

90
    public void setTags(String tag) {
91
        this.tags = tag;
×
92
    }
×
93

94
    public Date getDate() {
95
        return date;
×
96
    }
97

98
    /**
99
     * Necessary Comparable method, used for sorting of TagEntries.
100
     *
101
     * @param that Compare to.
102
     * @return 1 for greater, 0 for equal and -1 for smaller objects.
103
     */
104
    @Override
105
    public int compareTo(TagEntry that) {
106
        if (this == that) {
1✔
107
            return 0;
1✔
108
        }
109

110
        if (this.revision != NOREV) {
1✔
UNCOV
111
            return Integer.compare(this.revision, that.revision);
×
112
        }
113
        assert this.date != null : DATE_NULL_ASSERT;
1✔
114
        return this.date.compareTo(that.date);
1✔
115
    }
116

117
    @Override
118
    public boolean equals(Object aThat) {
119
        if (this == aThat) {
1✔
120
            return true;
×
121
        }
122
        if (!(aThat instanceof TagEntry)) {
1✔
123
            return false;
×
124
        }
125
        TagEntry that = (TagEntry) aThat;
1✔
126
        if (this.revision != NOREV) {
1✔
127
            return this.revision == that.revision;
×
128
        }
129
        assert this.date != null : DATE_NULL_ASSERT;
1✔
130
        return this.date.equals(that.date);
1✔
131
    }
132

133
    @Override
134
    public int hashCode() {
135
        if (this.revision != NOREV) {
×
136
            return this.revision;
×
137
        }
138
        assert this.date != null : DATE_NULL_ASSERT;
×
139
        return this.date.hashCode();
×
140
    }
141

142
    /**
143
     * Compares to given HistoryEntry, needed for history parsing. Depends on
144
     * specific repository revision format, therefore abstract.
145
     *
146
     * @param aThat HistoryEntry we compare to.
147
     * @return 1 for greater, 0 for equal and -1 for smaller objects.
148
     */
149
    public abstract int compareTo(HistoryEntry aThat);
150
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc