FINERACT-2095: Support for string type primary keys - enum options
This commit is contained in:
committed by
Adam Saghy
parent
33ecbc7130
commit
009e9ded01
+39
@@ -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;
|
||||
}
|
||||
+4
-8
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
+35
@@ -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);
|
||||
}
|
||||
}
|
||||
+5
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user