diff --git a/fineract-core/src/main/java/org/apache/fineract/infrastructure/core/data/BaseEnumOptionData.java b/fineract-core/src/main/java/org/apache/fineract/infrastructure/core/data/BaseEnumOptionData.java new file mode 100644 index 000000000..ca81d716e --- /dev/null +++ b/fineract-core/src/main/java/org/apache/fineract/infrastructure/core/data/BaseEnumOptionData.java @@ -0,0 +1,39 @@ +/** + * 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.data; + +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.EqualsAndHashCode; +import lombok.Getter; + +/** + *

+ * Immutable data object representing generic enumeration value. + *

+ */ +@Getter +@EqualsAndHashCode +@AllArgsConstructor +public abstract class BaseEnumOptionData implements Serializable { + + protected T id; + protected final String code; + protected final String value; +} diff --git a/fineract-core/src/main/java/org/apache/fineract/infrastructure/core/data/EnumOptionData.java b/fineract-core/src/main/java/org/apache/fineract/infrastructure/core/data/EnumOptionData.java index 6f2251e9f..f3c027a84 100644 --- a/fineract-core/src/main/java/org/apache/fineract/infrastructure/core/data/EnumOptionData.java +++ b/fineract-core/src/main/java/org/apache/fineract/infrastructure/core/data/EnumOptionData.java @@ -19,8 +19,6 @@ package org.apache.fineract.infrastructure.core.data; import java.io.Serializable; -import lombok.AllArgsConstructor; -import lombok.EqualsAndHashCode; import lombok.Getter; /** @@ -29,11 +27,9 @@ import lombok.Getter; *

*/ @Getter -@EqualsAndHashCode -@AllArgsConstructor -public class EnumOptionData implements Serializable { +public class EnumOptionData extends BaseEnumOptionData implements Serializable { - private final Long id; - private final String code; - private final String value; + public EnumOptionData(Long id, String code, String description) { + super(id, code, description); + } } diff --git a/fineract-core/src/main/java/org/apache/fineract/infrastructure/core/data/StringEnumOptionData.java b/fineract-core/src/main/java/org/apache/fineract/infrastructure/core/data/StringEnumOptionData.java new file mode 100644 index 000000000..ec5c152d7 --- /dev/null +++ b/fineract-core/src/main/java/org/apache/fineract/infrastructure/core/data/StringEnumOptionData.java @@ -0,0 +1,35 @@ +/** + * 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.data; + +import java.io.Serializable; +import lombok.Getter; + +/** + *

+ * Immutable data object representing generic enumeration value. + *

+ */ +@Getter +public class StringEnumOptionData extends BaseEnumOptionData implements Serializable { + + public StringEnumOptionData(String id, String code, String description) { + super(id, code, description); + } +} diff --git a/fineract-core/src/main/java/org/apache/fineract/interoperation/domain/InteropIdentifierType.java b/fineract-core/src/main/java/org/apache/fineract/interoperation/domain/InteropIdentifierType.java index 6cba22dc2..81b811271 100644 --- a/fineract-core/src/main/java/org/apache/fineract/interoperation/domain/InteropIdentifierType.java +++ b/fineract-core/src/main/java/org/apache/fineract/interoperation/domain/InteropIdentifierType.java @@ -22,6 +22,7 @@ import java.util.Arrays; import java.util.Map; import java.util.stream.Collectors; import lombok.Getter; +import org.apache.fineract.infrastructure.core.data.StringEnumOptionData; @Getter public enum InteropIdentifierType { @@ -65,4 +66,8 @@ public enum InteropIdentifierType { InteropIdentifierType idType = BY_ALIAS.get(name); return idType == null ? BY_NAME.get(name) : idType; } + + public StringEnumOptionData toStringEnumOptionData() { + return new StringEnumOptionData(name(), getCode(), getDescription()); + } }