@Override public boolean equals(Object o) { if (o == this) { return true; } if (!(o instanceof GlobalId)) { return false; } GlobalId actual = (GlobalId) o; return this.getDomainName().equals(actual.getDomainName()) && this.getLocalId().equals(actual.getLocalId()); }
/** * Try and construct a GlobalId given a string for a DomainName and a string for a LocalId * * @param domainName String to try and create DomainName from * @param localId String to try and create LocalId from * @throws IllegalArgumentException */ public GlobalId(String domainName, String localId) throws IllegalArgumentException { this.domainName = new DomainName(domainName); this.localId = new LocalId(localId); }
public static UserId fromJson(String jsonId) { Type idSpecEnum = Type.jsonValueOf(jsonId); if (idSpecEnum != null) { return new UserId(idSpecEnum, null); } return new UserId(Type.userId, jsonId); }
@Test public void testGlobalId() throws Exception { DomainName dn = new DomainName("example.com"); LocalId lid = new LocalId("195mg90a39v"); GlobalId g1 = new GlobalId(dn, lid); assertTrue(g1 instanceof GlobalId); GlobalId g2 = new GlobalId("example.com:195mg90a39v"); assertTrue(g2 instanceof GlobalId); GlobalId g3 = new GlobalId("example.com", "195mg90a39v"); assertTrue(g3 instanceof GlobalId); }
/** * Set the objectId with a String * * @param objectId String * @throws IllegalArgumentException */ public void setObjectId(String objectId) throws IllegalArgumentException { if(getType(objectId).equals(Type.objectId)) { this.objectId = new ObjectId(objectId); } else { this.objectId = objectId; } }
public static GroupId fromJson(String jsonId) { Type idSpecEnum = Type.jsonValueOf(jsonId); if (idSpecEnum != null) { return new GroupId(idSpecEnum, null); } return new GroupId(Type.groupId, jsonId); }
/** * Get the type of the stored objectId. * * @return GroupId.Type */ public Type getType() { return getType(this.objectId); }
@Test public void testDomainName() throws Exception { DomainName d1 = new DomainName(""); assertTrue(d1 instanceof DomainName); DomainName d2 = new DomainName("localhost"); assertTrue(d2 instanceof DomainName); DomainName d3 = new DomainName("example.com"); assertTrue(d3 instanceof DomainName); }
@Test public void testLocalId() throws Exception { LocalId l1 = new LocalId(""); assertTrue(l1 instanceof LocalId); LocalId l2 = new LocalId("195mg90a39v"); assertTrue(l2 instanceof LocalId); }
/** * Set the localId with a String * * @param localId String */ public void setLocalId(String localId) { this.localId = new LocalId(localId); }
/** * Constructor for DomainName * * @param domainName String to try and create DomainName from * @throws IllegalArgumentException */ public DomainName(String domainName) throws IllegalArgumentException { setDomainName(domainName); }
/** {@inheritDoc} */ public String getId() { return this.id.toString(); } }
@Test public void testGlobalId() throws Exception { DomainName dn = new DomainName("example.com"); LocalId lid = new LocalId("195mg90a39v"); GlobalId g1 = new GlobalId(dn, lid); assertTrue(g1 instanceof GlobalId); GlobalId g2 = new GlobalId("example.com:195mg90a39v"); assertTrue(g2 instanceof GlobalId); GlobalId g3 = new GlobalId("example.com", "195mg90a39v"); assertTrue(g3 instanceof GlobalId); }
public static UserId fromJson(String jsonId) { Type idSpecEnum = Type.jsonValueOf(jsonId); if (idSpecEnum != null) { return new UserId(idSpecEnum, null); } return new UserId(Type.userId, jsonId); }
/** * Set the objectId with a String * * @param objectId String * @throws IllegalArgumentException */ public void setObjectId(String objectId) throws IllegalArgumentException { if(getType(objectId).equals(Type.objectId)) { this.objectId = new ObjectId(objectId); } else { this.objectId = objectId; } }
@Override public boolean equals(Object o) { if (o == this) { return true; } if (!(o instanceof GlobalId)) { return false; } GlobalId actual = (GlobalId) o; return this.getDomainName().equals(actual.getDomainName()) && this.getLocalId().equals(actual.getLocalId()); }
/** * Try and construct a GlobalId given a string for a DomainName and a string for a LocalId * * @param domainName String to try and create DomainName from * @param localId String to try and create LocalId from * @throws IllegalArgumentException */ public GlobalId(String domainName, String localId) throws IllegalArgumentException { this.domainName = new DomainName(domainName); this.localId = new LocalId(localId); }
/** * Get the type of the stored objectId. * * @return GroupId.Type */ public Type getType() { return getType(this.objectId); }
/** * Set the localId with a String * * @param localId String */ public void setLocalId(String localId) { this.localId = new LocalId(localId); }
public static UserId fromJson(String jsonId) { Type idSpecEnum = Type.jsonValueOf(jsonId); if (idSpecEnum != null) { return new UserId(idSpecEnum, null); } return new UserId(Type.userId, jsonId); }