adamsaghy commented on code in PR #2758: URL: https://github.com/apache/fineract/pull/2758#discussion_r1031662120
########## fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/domain/ExternalId.java: ########## @@ -0,0 +1,81 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 org.apache.fineract.infrastructure.core.domain; + +import java.io.Serial; +import java.io.Serializable; +import java.util.UUID; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import org.apache.fineract.infrastructure.core.exception.PlatformInternalServerException; + +/** + * ExternalId Value object + */ +@Getter +@EqualsAndHashCode +@Builder +@AllArgsConstructor Review Comment: ok :) ########## fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/domain/ExternalId.java: ########## @@ -0,0 +1,81 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 org.apache.fineract.infrastructure.core.domain; + +import java.io.Serial; +import java.io.Serializable; +import java.util.UUID; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import org.apache.fineract.infrastructure.core.exception.PlatformInternalServerException; + +/** + * ExternalId Value object + */ +@Getter +@EqualsAndHashCode +@Builder +@AllArgsConstructor +public class ExternalId implements Serializable { + + @Serial + private static final long serialVersionUID = 1; + private static final ExternalId empty = new ExternalId(null); + private final String value; + + /** + * @return Create a new ExternalId object where value is a newly generated UUID + */ + public static ExternalId generate() { + return new ExternalId(UUID.randomUUID().toString()); + } + + /** + * @return Create and return an empty ExternalId object + */ + public static ExternalId empty() { + return empty; + } + + /** + * @return whether value was set for the ExternalId object (return false if value is null) + */ + public boolean isSet() { + return value != null; + } + + /** + * Throws exception if value was not set (value is null) for this object + * + * @throws PlatformInternalServerException + * if value was not set (value is null) for this object + */ + public void throwErrorIfItsNotSet() { Review Comment: Roger -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
