public LabelsFactoryImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public EObject create(EClass eClass) {
switch (eClass.getClassifierID()) {
case LabelsPackage.AREA_LABEL: return createAreaLabel();
case LabelsPackage.AREA_LABEL_VALUE: return createAreaLabelValue();
case LabelsPackage.COMMON_BORDER_RELATIONSHIP_LABEL: return createCommonBorderRelationshipLabel();
case LabelsPackage.COMMON_BORDER_RELATIONSHIP_LABEL_VALUE: return createCommonBorderRelationshipLabelValue();
case LabelsPackage.POPULATION_LABEL: return createPopulationLabel();
case LabelsPackage.POPULATION_LABEL_VALUE: return createPopulationLabelValue();
case LabelsPackage.RELATIVE_PHYSICAL_RELATIONSHIP_LABEL: return createRelativePhysicalRelationshipLabel();
case LabelsPackage.RELATIVE_PHYSICAL_RELATIONSHIP_LABEL_VALUE: return createRelativePhysicalRelationshipLabelValue();
case LabelsPackage.TRANSPORT_RELATIONSHIP_LABEL: return createTransportRelationshipLabel();
case LabelsPackage.TRANSPORT_RELATIONSHIP_LABEL_VALUE: return createTransportRelationshipLabelValue();
case LabelsPackage.PHYSICAL_RELATIONSHIP_LABEL_VALUE: return createPhysicalRelationshipLabelValue();
case LabelsPackage.ROAD_TRANSPORT_RELATIONSHIP_LABEL: return createRoadTransportRelationshipLabel();
case LabelsPackage.ROAD_TRANSPORT_RELATIONSHIP_LABEL_VALUE: return createRoadTransportRelationshipLabelValue();
case LabelsPackage.EARTH_SCIENCE_LABEL: return createEarthScienceLabel();
case LabelsPackage.EARTH_SCIENCE_LABEL_VALUE: return createEarthScienceLabelValue();
case LabelsPackage.PARENT_LABEL: return createParentLabel();
case LabelsPackage.PARENT_LABEL_VALUE: return createParentLabelValue();
default:
throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); //$NON-NLS-1$ //$NON-NLS-2$
}
}
I’m receiving a “Duplicate case error” in Eclipse for the above code. Eclipse underlines the “AREA_LABEL” line, “PARENT_LABEL” line, and “PARENT_LABEL_VALUE” line as duplicates even though they seem to be different. I assume this is a syntax error but I’m not sure. Let me know if you need any other code/classes. Thank you.
It all depends on the actual values of those labels, they might have different names but the same values. Check their definition, it’s hard to tell their actual types and values from just the piece of code you posted.
To fix this error, make sure that each of the constants really has different values. Or use an enumeration, as suggested by @djjeck.