/** * If the given object is an objectId, create and store * Else we need the string representation to store, including the "@" * * @param objectId Object * @throws IllegalArgumentException */ public GroupId(Object objectId) throws IllegalArgumentException { if(objectId == null) { this.objectId = new ObjectId(""); // If it is an objectId, store as is } else if(objectId instanceof ObjectId) { this.objectId = (ObjectId) objectId; // Else it must be a string, store as such } else { if(Type.objectId.equals(getType(objectId))) { this.objectId = new ObjectId(objectId.toString()); } else { this.objectId = objectId.toString(); } } }
/** * If the given object is an objectId, create and store * Else we need the string representation to store, including the "@" * * @param objectId Object * @throws IllegalArgumentException */ public GroupId(Object objectId) throws IllegalArgumentException { if(objectId == null) { this.objectId = new ObjectId(""); // If it is an objectId, store as is } else if(objectId instanceof ObjectId) { this.objectId = (ObjectId) objectId; // Else it must be a string, store as such } else { if(Type.objectId.equals(getType(objectId))) { this.objectId = new ObjectId(objectId.toString()); } else { this.objectId = objectId.toString(); } } }
/** * Backwards Compatibility. * * @param type * @param objectId * @throws IllegalArgumentException when the provided objectId is not valid */ public GroupId(Type type, String objectId) throws IllegalArgumentException { // If Type is an objectId, convert objectId to ObjectId and store if(type.equals(Type.objectId)) { this.objectId = new ObjectId(objectId); // Else store the string representation of the type } else if(Type.custom.equals(type)){ //Custom @ id this.objectId = objectId; } else { this.objectId = typeToString(type); } }
/** * Backwards Compatibility. * * @param type * @param objectId * @throws IllegalArgumentException when the provided objectId is not valid */ public GroupId(Type type, String objectId) throws IllegalArgumentException { // If Type is an objectId, convert objectId to ObjectId and store if(type.equals(Type.objectId)) { this.objectId = new ObjectId(objectId); // Else store the string representation of the type } else if(Type.custom.equals(type)){ //Custom @ id this.objectId = objectId; } else { this.objectId = typeToString(type); } }
/** * 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; } }
/** * 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; } }