FINERACT-2095: Support for string type primary keys - enum options

This commit is contained in:
Marta Jankovics
2024-06-26 15:00:50 +02:00
committed by Adam Saghy
parent 33ecbc7130
commit 009e9ded01
4 changed files with 83 additions and 8 deletions
@@ -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;
/**
* <p>
* Immutable data object representing generic enumeration value.
* </p>
*/
@Getter
@EqualsAndHashCode
@AllArgsConstructor
public abstract class BaseEnumOptionData<T> implements Serializable {
protected T id;
protected final String code;
protected final String value;
}
@@ -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;
* </p>
*/
@Getter
@EqualsAndHashCode
@AllArgsConstructor
public class EnumOptionData implements Serializable {
public class EnumOptionData extends BaseEnumOptionData<Long> 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);
}
}
@@ -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;
/**
* <p>
* Immutable data object representing generic enumeration value.
* </p>
*/
@Getter
public class StringEnumOptionData extends BaseEnumOptionData<String> implements Serializable {
public StringEnumOptionData(String id, String code, String description) {
super(id, code, description);
}
}
@@ -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());
}
}