Skip to content

Commit 920a36f

Browse files
authored
Feature facility factory (#247)
* Add FacilityFactory * Update JavaDoc * Update CHANGELOG
1 parent 82c585f commit 920a36f

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

CHANGELOG.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This project adheres to `Semantic Versioning <https://semver.org/>`_.
1212
* A new enumeration for facilities ``life.qbic.datamodel.dtos.business.facilities.Facility`` (`#244 <https://github.com/qbicsoftware/data-model-lib/pull/244>`_)
1313
* New properties ``internalUnitPrice``, ``externalUnitPrice`` and ``serviceProvider`` for the ``life.qbic.datamodel.dtos.business.services.Product`` and its derivatives (`#245 <https://github.com/qbicsoftware/data-model-lib/pull/245>`_)
1414
* New properties ``totalPrice`` and ``totalDiscountPrice`` for the ``life.qbic.datamodel.dtos.business.ProductItem`` and ``totalDiscountPrice`` for the ``life.qbic.datamodel.dtos.business.Offer``
15-
15+
* A ``life.qbic.datamodel.dtos.business.facilities.FacilityFactory`` to get the facility for a given string representation (`#247 <https://github.com/qbicsoftware/data-model-lib/pull/247>`_)
1616
**Fixed**
1717

1818
**Dependencies**
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package life.qbic.datamodel.dtos.business.facilities
2+
3+
import life.qbic.datamodel.dtos.EnumFactory
4+
5+
/**
6+
* This class provides functionality for enum key retrieval
7+
*
8+
* This class retrieves the corresponding Facility for a given String
9+
*
10+
* @see Facility
11+
* @since: 2.11.0
12+
*/
13+
class FacilityFactory extends EnumFactory<Facility> {
14+
/**
15+
* This method returns the enum with the provided String value.
16+
*
17+
* @throws IllegalArgumentException in case the String could not be mapped
18+
* @param value the String corresponding to a key of the enum
19+
* @return the enum key for the provided string value
20+
* @since 2.11.0
21+
*/
22+
@Override
23+
Facility getForString(String value) {
24+
Facility desiredKey
25+
desiredKey = Facility.values().find {it.fullName.equals(value.trim())}
26+
if (!desiredKey) {
27+
throw new IllegalArgumentException("Invalid value '$value' for ${Facility.getSimpleName()}")
28+
}
29+
return desiredKey
30+
}
31+
}

0 commit comments

Comments
 (0)