Add support for set() method to Key, and use fromString() for URLs
This way we have a consistent URL encoding for any entity key. Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
@@ -37,6 +37,18 @@ public final class Account {
|
||||
public int get() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void set(int newValue) {
|
||||
id = newValue;
|
||||
}
|
||||
|
||||
/** Parse an Account.Id out of a string representation. */
|
||||
public static Id parse(final String str) {
|
||||
final Id r = new Id();
|
||||
r.fromString(str);
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
@Column
|
||||
|
||||
@@ -44,6 +44,11 @@ public final class AccountExternalId {
|
||||
public String get() {
|
||||
return externalId;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void set(String newValue) {
|
||||
externalId = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Column(name = Column.NONE)
|
||||
|
||||
@@ -37,6 +37,11 @@ public final class AccountGroup {
|
||||
public String get() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void set(String newValue) {
|
||||
name = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
/** Synthetic key to link to within the database */
|
||||
@@ -55,6 +60,11 @@ public final class AccountGroup {
|
||||
public int get() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void set(int newValue) {
|
||||
id = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Column
|
||||
|
||||
@@ -46,6 +46,11 @@ public final class AccountSshKey {
|
||||
public int get() {
|
||||
return seq;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void set(int newValue) {
|
||||
seq = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Column(name = Column.NONE)
|
||||
|
||||
@@ -35,6 +35,11 @@ public final class ApprovalCategory {
|
||||
public String get() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void set(String newValue) {
|
||||
id = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Column
|
||||
|
||||
@@ -44,6 +44,11 @@ public final class ApprovalCategoryValue {
|
||||
public short get() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void set(short newValue) {
|
||||
value = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Column(name = Column.NONE)
|
||||
|
||||
@@ -42,6 +42,11 @@ public final class Branch {
|
||||
return branchName;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void set(String newValue) {
|
||||
branchName = newValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Project.NameKey getParentKey() {
|
||||
return projectName;
|
||||
@@ -76,6 +81,11 @@ public final class Branch {
|
||||
public int get() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void set(int newValue) {
|
||||
id = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Column(name = Column.NONE)
|
||||
|
||||
@@ -38,9 +38,16 @@ public final class Change {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void set(int newValue) {
|
||||
id = newValue;
|
||||
}
|
||||
|
||||
/** Parse a Change.Id out of a string representation. */
|
||||
public static Id fromString(final String str) {
|
||||
return new Id(Integer.parseInt(str));
|
||||
public static Id parse(final String str) {
|
||||
final Id r = new Id();
|
||||
r.fromString(str);
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -46,6 +46,11 @@ public final class ChangeMessage {
|
||||
public String get() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void set(String newValue) {
|
||||
uuid = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Column(name = Column.NONE)
|
||||
|
||||
@@ -38,6 +38,11 @@ public final class ContributorAgreement {
|
||||
public int get() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void set(int newValue) {
|
||||
id = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Column
|
||||
|
||||
@@ -44,6 +44,18 @@ public final class Patch {
|
||||
public String get() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void set(String newValue) {
|
||||
fileName = newValue;
|
||||
}
|
||||
|
||||
/** Parse a Patch.Id out of a string representation. */
|
||||
public static Id parse(final String str) {
|
||||
final Id r = new Id();
|
||||
r.fromString(str);
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
public static enum ChangeType {
|
||||
|
||||
@@ -46,6 +46,10 @@ public final class PatchContent {
|
||||
return KeyUtil.encode(sha1);
|
||||
}
|
||||
|
||||
public void fromString(final String in) {
|
||||
sha1 = KeyUtil.decode(in);
|
||||
}
|
||||
|
||||
public com.google.gwtorm.client.Key<?> getParentKey() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -46,6 +46,11 @@ public final class PatchLineComment {
|
||||
public String get() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void set(String newValue) {
|
||||
uuid = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
protected static final char STATUS_DRAFT = 'd';
|
||||
|
||||
@@ -44,6 +44,18 @@ public final class PatchSet {
|
||||
public int get() {
|
||||
return patchSetId;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void set(int newValue) {
|
||||
patchSetId = newValue;
|
||||
}
|
||||
|
||||
/** Parse a PatchSet.Id out of a string representation. */
|
||||
public static Id parse(final String str) {
|
||||
final Id r = new Id();
|
||||
r.fromString(str);
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
@Column(name = Column.NONE)
|
||||
|
||||
@@ -44,6 +44,11 @@ public final class PatchSetAncestor {
|
||||
public int get() {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void set(int newValue) {
|
||||
position = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Column(name = Column.NONE)
|
||||
|
||||
@@ -37,6 +37,11 @@ public final class Project {
|
||||
public String get() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void set(String newValue) {
|
||||
name = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
/** Synthetic key to link to within the database */
|
||||
@@ -55,6 +60,11 @@ public final class Project {
|
||||
public int get() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void set(int newValue) {
|
||||
id = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Column
|
||||
|
||||
@@ -34,6 +34,11 @@ public final class SystemConfig {
|
||||
public String get() {
|
||||
return VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void set(final String newValue) {
|
||||
assert get().equals(newValue);
|
||||
}
|
||||
}
|
||||
|
||||
public static SystemConfig create() {
|
||||
|
||||
Reference in New Issue
Block a user