Remove TrackingId class
The only portion of this class which was still used was an int constant. Move that to be a private constant in the class where it's used. Change-Id: I781032d09ce6020cccf66532869c15471a0c0fa7
This commit is contained in:
committed by
David Pursehouse
parent
5de2be720f
commit
0c51be4a54
@@ -1,152 +0,0 @@
|
||||
// Copyright (C) 2010 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.reviewdb.client;
|
||||
|
||||
import com.google.gwtorm.client.CompoundKey;
|
||||
import com.google.gwtorm.client.StringKey;
|
||||
|
||||
/** External tracking id associated with a {@link Change} */
|
||||
public final class TrackingId {
|
||||
public static final int TRACKING_ID_MAX_CHAR = 32;
|
||||
public static final int TRACKING_SYSTEM_MAX_CHAR = 10;
|
||||
|
||||
/** External tracking id */
|
||||
public static class Id extends StringKey<com.google.gwtorm.client.Key<?>> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
protected String id;
|
||||
|
||||
protected Id() {}
|
||||
|
||||
public Id(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String get() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void set(String newValue) {
|
||||
id = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
/** Name of external tracking system */
|
||||
public static class System extends StringKey<com.google.gwtorm.client.Key<?>> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
protected String system;
|
||||
|
||||
protected System() {}
|
||||
|
||||
public System(String s) {
|
||||
this.system = s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String get() {
|
||||
return system;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void set(String newValue) {
|
||||
system = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Key extends CompoundKey<Change.Id> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
protected Change.Id changeId;
|
||||
|
||||
protected Id trackingKey;
|
||||
|
||||
protected System trackingSystem;
|
||||
|
||||
protected Key() {
|
||||
changeId = new Change.Id();
|
||||
trackingKey = new Id();
|
||||
trackingSystem = new System();
|
||||
}
|
||||
|
||||
protected Key(Change.Id ch, Id id, System s) {
|
||||
changeId = ch;
|
||||
trackingKey = id;
|
||||
trackingSystem = s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Change.Id getParentKey() {
|
||||
return changeId;
|
||||
}
|
||||
|
||||
public TrackingId.Id getTrackingId() {
|
||||
return trackingKey;
|
||||
}
|
||||
|
||||
public TrackingId.System getTrackingSystem() {
|
||||
return trackingSystem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public com.google.gwtorm.client.Key<?>[] members() {
|
||||
return new com.google.gwtorm.client.Key<?>[] {trackingKey, trackingSystem};
|
||||
}
|
||||
}
|
||||
|
||||
protected Key key;
|
||||
|
||||
protected TrackingId() {}
|
||||
|
||||
public TrackingId(Change.Id ch, TrackingId.Id id, TrackingId.System s) {
|
||||
key = new Key(ch, id, s);
|
||||
}
|
||||
|
||||
public TrackingId(Change.Id ch, String id, String s) {
|
||||
key = new Key(ch, new TrackingId.Id(id), new TrackingId.System(s));
|
||||
}
|
||||
|
||||
public TrackingId.Key getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public Change.Id getChangeId() {
|
||||
return key.changeId;
|
||||
}
|
||||
|
||||
public String getTrackingId() {
|
||||
return key.trackingKey.get();
|
||||
}
|
||||
|
||||
public String getSystem() {
|
||||
return key.trackingSystem.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return key.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof TrackingId) {
|
||||
final TrackingId tr = (TrackingId) obj;
|
||||
return key.equals(tr.key);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,6 @@
|
||||
package com.google.gerrit.server.config;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.reviewdb.client.TrackingId;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
@@ -33,6 +32,8 @@ import org.eclipse.jgit.lib.Config;
|
||||
public class TrackingFootersProvider implements Provider<TrackingFooters> {
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
private static final int MAX_LENGTH = 10;
|
||||
|
||||
private static String TRACKING_ID_TAG = "trackingid";
|
||||
private static String FOOTER_TAG = "footer";
|
||||
private static String SYSTEM_TAG = "system";
|
||||
@@ -59,11 +60,11 @@ public class TrackingFootersProvider implements Provider<TrackingFooters> {
|
||||
configValid = false;
|
||||
logger.atSevere().log(
|
||||
"Missing %s.%s.%s in gerrit.config", TRACKING_ID_TAG, name, SYSTEM_TAG);
|
||||
} else if (system.length() > TrackingId.TRACKING_SYSTEM_MAX_CHAR) {
|
||||
} else if (system.length() > MAX_LENGTH) {
|
||||
configValid = false;
|
||||
logger.atSevere().log(
|
||||
"String too long \"%s\" in gerrit.config %s.%s.%s (max %d char)",
|
||||
system, TRACKING_ID_TAG, name, SYSTEM_TAG, TrackingId.TRACKING_SYSTEM_MAX_CHAR);
|
||||
system, TRACKING_ID_TAG, name, SYSTEM_TAG, MAX_LENGTH);
|
||||
}
|
||||
|
||||
String match = cfg.getString(TRACKING_ID_TAG, name, REGEX_TAG);
|
||||
|
||||
Reference in New Issue
Block a user