Skip to content

Commit

Permalink
remove tabs and main as per comments
Browse files Browse the repository at this point in the history
  • Loading branch information
gmournos authored and guusdk committed Jun 8, 2020
1 parent d4fe3ba commit 2b32fc7
Showing 1 changed file with 44 additions and 50 deletions.
94 changes: 44 additions & 50 deletions src/main/java/nl/goodbytes/xmpp/xep0363/SecureUUID.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ public class SecureUUID implements SecureUniqueId {
private static final Base64.Encoder encoder = Base64.getUrlEncoder().withoutPadding();
private final String id;
private static final Pattern BASE64_REGEX = Pattern.compile("^[a-zA-Z0-9\\-_]+$");

private SecureUUID(String id) {
if (id == null || id.length() != 27
|| !BASE64_REGEX.matcher(id).matches()) {
throw new IllegalArgumentException();
}
this.id = id;
if (id == null || id.length() != 27
|| !BASE64_REGEX.matcher(id).matches()) {
throw new IllegalArgumentException();
}
this.id = id;
}

public static SecureUUID generate() {
Expand All @@ -26,53 +26,47 @@ public static SecureUUID generate() {
result = result.replace('/', '-').replace('+', '_');
return new SecureUUID(result);
}

public static SecureUUID fromString(String id) {
return new SecureUUID(id);
return new SecureUUID(id);
}

@Override
public int compareTo(SecureUniqueId o) {
if (o != null && o instanceof SecureUUID && id != null) {
return this.id.compareTo(((SecureUUID)o).id);
}

return -1;
}

@Override
public int compareTo(SecureUniqueId o) {
if (o != null && o instanceof SecureUUID && id != null) {
return this.id.compareTo(((SecureUUID)o).id);
}

return -1;
}


@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
if (id == null) {
return false;
}
SecureUUID other = SecureUUID.class.cast(obj);
return Objects.equals(this.id, other.id);
}

@Override
public String toString() {
return this.id;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
if (id == null) {
return false;
}
SecureUUID other = SecureUUID.class.cast(obj);
return Objects.equals(this.id, other.id);
}

@Override
public String toString() {
return this.id;
}

@Override
public int hashCode() {
if (id == null) {
return System.identityHashCode(this);
}
return Objects.hash(this.id);
}

@Override
public int hashCode() {
if (id == null) {
return System.identityHashCode(this);
}
return Objects.hash(this.id);
}

public static void main(String...args) throws Exception {
for (int i=0; i < 30;i++)
System.out.println(new SecureUUID(SecureUUID.generate().toString()));

}

}

0 comments on commit 2b32fc7

Please sign in to comment.