Refactor LabelId out of PatchSetApprovals

Decouple the LabelId from the PatchSetApprovals so that we can
apply a vote in another context.  Specifically, we may want to
apply a vote(s) to a PatchSetVerification, a separate approval
channel for test results that may verify a single patchset.

Change-Id: Ibb162a6a9249204c24c8751ea01fb816586449dd
This commit is contained in:
David Ostrovsky
2015-01-14 10:58:42 +01:00
committed by David Pursehouse
parent b49af60c23
commit a066f02009
12 changed files with 68 additions and 51 deletions

View File

@@ -0,0 +1,57 @@
// Copyright (C) 2015 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.Column;
import com.google.gwtorm.client.StringKey;
public class LabelId extends StringKey<com.google.gwtorm.client.Key<?>> {
private static final long serialVersionUID = 1L;
public static final LabelId SUBMIT = new LabelId("SUBM");
@Column(id = 1)
protected String id;
protected LabelId() {
}
public LabelId(final String n) {
id = n;
}
@Override
public String get() {
return id;
}
@Override
protected void set(String newValue) {
id = newValue;
}
@Override
public int hashCode() {
return get().hashCode();
}
@Override
public boolean equals(Object b) {
if (this == b) {
return get().equals(((LabelId) b).get());
}
return false;
}
}

View File

@@ -16,53 +16,12 @@ package com.google.gerrit.reviewdb.client;
import com.google.gwtorm.client.Column;
import com.google.gwtorm.client.CompoundKey;
import com.google.gwtorm.client.StringKey;
import java.sql.Timestamp;
import java.util.Objects;
/** An approval (or negative approval) on a patch set. */
public final class PatchSetApproval {
public static class LabelId extends
StringKey<com.google.gwtorm.client.Key<?>> {
private static final long serialVersionUID = 1L;
public static final LabelId SUBMIT = new LabelId("SUBM");
@Column(id = 1)
protected String id;
protected LabelId() {
}
public LabelId(final String n) {
id = n;
}
@Override
public String get() {
return id;
}
@Override
protected void set(String newValue) {
id = newValue;
}
@Override
public int hashCode() {
return get().hashCode();
}
@Override
public boolean equals(Object b) {
if (b instanceof LabelId) {
return get().equals(((LabelId) b).get());
}
return false;
}
}
public static class Key extends CompoundKey<PatchSet.Id> {
private static final long serialVersionUID = 1L;