From 3f5a8a3ba16f3249e8a29c70c58f3434bd4184c3 Mon Sep 17 00:00:00 2001 From: Kai Brassel <mail@khbrassel.de> Date: Tue, 5 Apr 2022 18:22:13 +0200 Subject: [PATCH] Correct type name and README --- README.md | 2 +- .../model/Quantities.ecore | 2 +- .../model/Quantities.genmodel | 2 +- .../model/quantities/QuantitiesPackage.java | 19 ++++++++------- .../impl/QuantitiesFactoryImpl.java | 23 ++++++------------- .../impl/QuantitiesPackageImpl.java | 10 ++++---- 6 files changed, 24 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 3da6b75..a8131dc 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Create Eclipse P2 repository with Ecore data type `Quantity` for units based on Also adds another Ecore data type `TimeOfDay` useful to model schedules and the like. -To install this feature in an Eclipse application add site [https://transfer.hft-stuttgart.de/pages/neqmodplus/de.hft-stuttgart.cityunits/p2repo]() via `Eclipse -> Help -> Install New Software...` and select _City Units_ (If nothing can be selected, ensure that _Group items by category_ is ticked.) +To install this feature in an Eclipse application add site [https://transfer.hft-stuttgart.de/pages/neqmodplus/de.hft-stuttgart.cityunits/p2repo]() via `Eclipse -> Help -> Install New Software...` and select _City Units_. For an introduction on dealing with units in Java, see [Baeldung: Introduction to javax.measure](https://www.baeldung.com/javax-measure). diff --git a/de.hftstuttgart.cityunits.model/model/Quantities.ecore b/de.hftstuttgart.cityunits.model/model/Quantities.ecore index bb15245..09342f6 100644 --- a/de.hftstuttgart.cityunits.model/model/Quantities.ecore +++ b/de.hftstuttgart.cityunits.model/model/Quantities.ecore @@ -2,5 +2,5 @@ <ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="quantities" nsURI="https://www.hftstuttgart.de/quantities" nsPrefix="quant"> <eClassifiers xsi:type="ecore:EDataType" name="Quantity" instanceClassName="de.hftstuttgart.cityunits.model.NullableQuantity"/> - <eClassifiers xsi:type="ecore:EDataType" name="LocalTime" instanceClassName="java.time.LocalTime"/> + <eClassifiers xsi:type="ecore:EDataType" name="TimeOfDay" instanceClassName="java.time.LocalTime"/> </ecore:EPackage> diff --git a/de.hftstuttgart.cityunits.model/model/Quantities.genmodel b/de.hftstuttgart.cityunits.model/model/Quantities.genmodel index 478fbdc..eeba660 100644 --- a/de.hftstuttgart.cityunits.model/model/Quantities.genmodel +++ b/de.hftstuttgart.cityunits.model/model/Quantities.genmodel @@ -8,6 +8,6 @@ <genPackages prefix="Quantities" basePackage="de.hftstuttgart.cityunits.model" disposableProviderFactory="true" ecorePackage="Quantities.ecore#/"> <genDataTypes ecoreDataType="Quantities.ecore#//Quantity" create="return de.hftstuttgart.cityunits.model.NullableQuantity.create(it);"/> - <genDataTypes ecoreDataType="Quantities.ecore#//LocalTime" create="return java.time.LocalTime.parse(it);"/> + <genDataTypes ecoreDataType="Quantities.ecore#//TimeOfDay"/> </genPackages> </genmodel:GenModel> diff --git a/de.hftstuttgart.cityunits.model/src/de/hftstuttgart/cityunits/model/quantities/QuantitiesPackage.java b/de.hftstuttgart.cityunits.model/src/de/hftstuttgart/cityunits/model/quantities/QuantitiesPackage.java index 64c9bbe..d2806bb 100644 --- a/de.hftstuttgart.cityunits.model/src/de/hftstuttgart/cityunits/model/quantities/QuantitiesPackage.java +++ b/de.hftstuttgart.cityunits.model/src/de/hftstuttgart/cityunits/model/quantities/QuantitiesPackage.java @@ -66,15 +66,14 @@ public interface QuantitiesPackage extends EPackage { /** - * The meta object id for the '<em>Local Time</em>' data type. + * The meta object id for the '<em>Time Of Day</em>' data type. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see java.time.LocalTime - * @see de.hftstuttgart.cityunits.model.quantities.impl.QuantitiesPackageImpl#getLocalTime() + * @see de.hftstuttgart.cityunits.model.quantities.impl.QuantitiesPackageImpl#getTimeOfDay() * @generated */ - int LOCAL_TIME = 1; - + int TIME_OF_DAY = 1; /** * Returns the meta object for data type '{@link de.hftstuttgart.cityunits.model.NullableQuantity <em>Quantity</em>}'. @@ -88,15 +87,15 @@ public interface QuantitiesPackage extends EPackage { EDataType getQuantity(); /** - * Returns the meta object for data type '{@link java.time.LocalTime <em>Local Time</em>}'. + * Returns the meta object for data type '{@link java.time.LocalTime <em>Time Of Day</em>}'. * <!-- begin-user-doc --> * <!-- end-user-doc --> - * @return the meta object for data type '<em>Local Time</em>'. + * @return the meta object for data type '<em>Time Of Day</em>'. * @see java.time.LocalTime * @model instanceClass="java.time.LocalTime" * @generated */ - EDataType getLocalTime(); + EDataType getTimeOfDay(); /** * Returns the factory that creates the instances of the model. @@ -131,14 +130,14 @@ public interface QuantitiesPackage extends EPackage { */ EDataType QUANTITY = eINSTANCE.getQuantity(); /** - * The meta object literal for the '<em>Local Time</em>' data type. + * The meta object literal for the '<em>Time Of Day</em>' data type. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see java.time.LocalTime - * @see de.hftstuttgart.cityunits.model.quantities.impl.QuantitiesPackageImpl#getLocalTime() + * @see de.hftstuttgart.cityunits.model.quantities.impl.QuantitiesPackageImpl#getTimeOfDay() * @generated */ - EDataType LOCAL_TIME = eINSTANCE.getLocalTime(); + EDataType TIME_OF_DAY = eINSTANCE.getTimeOfDay(); } diff --git a/de.hftstuttgart.cityunits.model/src/de/hftstuttgart/cityunits/model/quantities/impl/QuantitiesFactoryImpl.java b/de.hftstuttgart.cityunits.model/src/de/hftstuttgart/cityunits/model/quantities/impl/QuantitiesFactoryImpl.java index 5addccc..82031e8 100644 --- a/de.hftstuttgart.cityunits.model/src/de/hftstuttgart/cityunits/model/quantities/impl/QuantitiesFactoryImpl.java +++ b/de.hftstuttgart.cityunits.model/src/de/hftstuttgart/cityunits/model/quantities/impl/QuantitiesFactoryImpl.java @@ -74,8 +74,8 @@ public class QuantitiesFactoryImpl extends EFactoryImpl implements QuantitiesFac switch (eDataType.getClassifierID()) { case QuantitiesPackage.QUANTITY: return createQuantityFromString(eDataType, initialValue); - case QuantitiesPackage.LOCAL_TIME: - return createLocalTimeFromString(eDataType, initialValue); + case QuantitiesPackage.TIME_OF_DAY: + return createTimeOfDayFromString(eDataType, initialValue); default: throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); } @@ -91,8 +91,8 @@ public class QuantitiesFactoryImpl extends EFactoryImpl implements QuantitiesFac switch (eDataType.getClassifierID()) { case QuantitiesPackage.QUANTITY: return convertQuantityToString(eDataType, instanceValue); - case QuantitiesPackage.LOCAL_TIME: - return convertLocalTimeToString(eDataType, instanceValue); + case QuantitiesPackage.TIME_OF_DAY: + return convertTimeOfDayToString(eDataType, instanceValue); default: throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); } @@ -130,8 +130,8 @@ public class QuantitiesFactoryImpl extends EFactoryImpl implements QuantitiesFac * <!-- end-user-doc --> * @generated */ - public LocalTime createLocalTime(final String it) { - return java.time.LocalTime.parse(it); + public LocalTime createTimeOfDayFromString(EDataType eDataType, String initialValue) { + return (LocalTime)super.createFromString(eDataType, initialValue); } /** @@ -139,16 +139,7 @@ public class QuantitiesFactoryImpl extends EFactoryImpl implements QuantitiesFac * <!-- end-user-doc --> * @generated */ - public LocalTime createLocalTimeFromString(EDataType eDataType, String initialValue) { - return createLocalTime(initialValue); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String convertLocalTimeToString(EDataType eDataType, Object instanceValue) { + public String convertTimeOfDayToString(EDataType eDataType, Object instanceValue) { return super.convertToString(eDataType, instanceValue); } diff --git a/de.hftstuttgart.cityunits.model/src/de/hftstuttgart/cityunits/model/quantities/impl/QuantitiesPackageImpl.java b/de.hftstuttgart.cityunits.model/src/de/hftstuttgart/cityunits/model/quantities/impl/QuantitiesPackageImpl.java index 02a6158..f81579d 100644 --- a/de.hftstuttgart.cityunits.model/src/de/hftstuttgart/cityunits/model/quantities/impl/QuantitiesPackageImpl.java +++ b/de.hftstuttgart.cityunits.model/src/de/hftstuttgart/cityunits/model/quantities/impl/QuantitiesPackageImpl.java @@ -29,7 +29,7 @@ public class QuantitiesPackageImpl extends EPackageImpl implements QuantitiesPac * <!-- end-user-doc --> * @generated */ - private EDataType localTimeEDataType = null; + private EDataType timeOfDayEDataType = null; /** * Creates an instance of the model <b>Package</b>, registered with @@ -108,8 +108,8 @@ public class QuantitiesPackageImpl extends EPackageImpl implements QuantitiesPac * @generated */ @Override - public EDataType getLocalTime() { - return localTimeEDataType; + public EDataType getTimeOfDay() { + return timeOfDayEDataType; } /** @@ -142,7 +142,7 @@ public class QuantitiesPackageImpl extends EPackageImpl implements QuantitiesPac // Create data types quantityEDataType = createEDataType(QUANTITY); - localTimeEDataType = createEDataType(LOCAL_TIME); + timeOfDayEDataType = createEDataType(TIME_OF_DAY); } /** @@ -170,7 +170,7 @@ public class QuantitiesPackageImpl extends EPackageImpl implements QuantitiesPac // Initialize data types initEDataType(quantityEDataType, NullableQuantity.class, "Quantity", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); - initEDataType(localTimeEDataType, LocalTime.class, "LocalTime", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + initEDataType(timeOfDayEDataType, LocalTime.class, "TimeOfDay", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); // Create resource createResource(eNS_URI); -- GitLab