Skip to content

Commit a96b059

Browse files
dfcoffinclaude
andauthored
feat: ESPI 4.0 Schema Compliance - Phase 0.6: Customer Domain Enums (#110)
Implements customer domain enumerations from customer.xsd with proper JAXB/Jakarta XML binding annotations and comprehensive XSD documentation. Customer Domain Enums: - CustomerKind (15 values) - Customer classifications (residential, commercialIndustrial, etc.) - SupplierKind (6 values) - Supplier types (utility, retailer, lse, mdma, msp, other) - ServiceKind (11 values) - Service types (electricity, gas, water, heat, etc.) - EnrollmentStatus (3 values) - DR program enrollment status (unenrolled, enrolled, enrolledPending) - NotificationMethodKind (5 values) - Notification methods (call, email, letter, ivr, other) - MeterMultiplierKind (6 values) - Meter multiplier types (kH, transformerRatio, kR, kE, ctRatio, ptRatio) - RevenueKind (7 values) - Revenue classifications (residential, commercial, industrial, etc.) - ProgramDateKind (4 values) - DR program date types - CRUDOperation (4 values) - CRUD operations (0=CREATE, 1=READ, 2=UPDATE, 3=DELETE) - MediaType (16 values) - IANA media types (application/json, application/pdf, text/csv, etc.) All enums include: - Apache License 2.0 header (copyright 2025 Green Button Alliance, Inc.) - Package: org.greenbuttonalliance.espi.common.domain.customer.enums - JAXB/Jakarta XML binding annotations (@XmlType with namespace="http://naesb.org/espi/customer") - getValue() and fromValue() methods with IllegalArgumentException for invalid values - Comprehensive Javadoc from XSD documentation with line numbers - Type-safe enum constants (String or int based on XSD type) Test Updates: - Updated CustomerKind test values: COMMERCIAL → COMMERCIAL_INDUSTRIAL per XSD - Updated SupplierKind test values: uppercase → lowercase per XSD - Updated CustomerKind test values: uppercase → lowercase per XSD Total enum values in batch: 77 Per ESPI 4.0 specification (NAESB REQ.21) All tests: 781/781 passed ✓ - Unit tests: 638/638 passed - Integration tests: 143/143 passed (with Docker/TestContainers) Related to #101 Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent cd1d771 commit a96b059

15 files changed

Lines changed: 910 additions & 192 deletions

File tree

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/*
2+
* Copyright 2025 Green Button Alliance, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.greenbuttonalliance.espi.common.domain.customer.enums;
18+
19+
import jakarta.xml.bind.annotation.XmlEnum;
20+
import jakarta.xml.bind.annotation.XmlEnumValue;
21+
import jakarta.xml.bind.annotation.XmlType;
22+
23+
/**
24+
* Enumeration for CRUDOperation values.
25+
*
26+
* Specifies the operation requested of this item.
27+
* Per ESPI 4.0 customer.xsd lines 1557-1591.
28+
*/
29+
@XmlType(name = "CRUDOperation", namespace = "http://naesb.org/espi/customer")
30+
@XmlEnum
31+
public enum CRUDOperation {
32+
33+
/**
34+
* Create.
35+
* XSD value: 0 (line 1564)
36+
*/
37+
@XmlEnumValue("0")
38+
CREATE(0),
39+
40+
/**
41+
* Read.
42+
* XSD value: 1 (line 1570)
43+
*/
44+
@XmlEnumValue("1")
45+
READ(1),
46+
47+
/**
48+
* Update.
49+
* XSD value: 2 (line 1576)
50+
*/
51+
@XmlEnumValue("2")
52+
UPDATE(2),
53+
54+
/**
55+
* Delete.
56+
* XSD value: 3 (line 1582)
57+
*/
58+
@XmlEnumValue("3")
59+
DELETE(3);
60+
61+
private final int value;
62+
63+
CRUDOperation(int value) {
64+
this.value = value;
65+
}
66+
67+
public int getValue() {
68+
return value;
69+
}
70+
71+
public static CRUDOperation fromValue(int value) {
72+
for (CRUDOperation operation : CRUDOperation.values()) {
73+
if (operation.value == value) {
74+
return operation;
75+
}
76+
}
77+
throw new IllegalArgumentException("Invalid CRUDOperation value: " + value);
78+
}
79+
}
Lines changed: 143 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,156 @@
11
/*
2+
* Copyright 2025 Green Button Alliance, Inc.
23
*
3-
* Copyright (c) 2025 Green Button Alliance, Inc.
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
47
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
59
*
6-
* Licensed under the Apache License, Version 2.0 (the "License");
7-
* you may not use this file except in compliance with the License.
8-
* You may obtain a copy of the License at
9-
*
10-
* http://www.apache.org/licenses/LICENSE-2.0
11-
*
12-
* Unless required by applicable law or agreed to in writing, software
13-
* distributed under the License is distributed on an "AS IS" BASIS,
14-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15-
* See the License for the specific language governing permissions and
16-
* limitations under the License.
17-
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
1815
*/
1916

2017
package org.greenbuttonalliance.espi.common.domain.customer.enums;
2118

19+
import jakarta.xml.bind.annotation.XmlEnum;
20+
import jakarta.xml.bind.annotation.XmlEnumValue;
21+
import jakarta.xml.bind.annotation.XmlType;
22+
2223
/**
2324
* Enumeration for CustomerKind values.
24-
*
25-
* Kind of customer based on the energy market business rules.
25+
*
26+
* Kind of customer.
27+
* Per ESPI 4.0 customer.xsd lines 1687-1772.
2628
*/
29+
@XmlType(name = "CustomerKind", namespace = "http://naesb.org/espi/customer")
30+
@XmlEnum
2731
public enum CustomerKind {
28-
/**
29-
* Commercial customer classification.
30-
*/
31-
COMMERCIAL,
32-
33-
/**
34-
* Enterprise customer classification.
35-
*/
36-
ENTERPRISE,
37-
38-
/**
39-
* Individual customer classification.
40-
*/
41-
INDIVIDUAL,
42-
43-
/**
44-
* Industrial customer classification.
45-
*/
46-
INDUSTRIAL,
47-
48-
/**
49-
* Residential customer classification.
50-
*/
51-
RESIDENTIAL,
52-
53-
/**
54-
* Subsidiary customer classification.
55-
*/
56-
SUBSIDIARY,
57-
58-
/**
59-
* Other customer classification.
60-
*/
61-
OTHER
32+
33+
/**
34+
* Residential customer.
35+
* XSD value: "residential" (line 1694)
36+
*/
37+
@XmlEnumValue("residential")
38+
RESIDENTIAL("residential"),
39+
40+
/**
41+
* Residential and commercial customer.
42+
* XSD value: "residentialAndCommercial" (line 1699)
43+
*/
44+
@XmlEnumValue("residentialAndCommercial")
45+
RESIDENTIAL_AND_COMMERCIAL("residentialAndCommercial"),
46+
47+
/**
48+
* Residential and streetlight customer.
49+
* XSD value: "residentialAndStreetlight" (line 1704)
50+
*/
51+
@XmlEnumValue("residentialAndStreetlight")
52+
RESIDENTIAL_AND_STREETLIGHT("residentialAndStreetlight"),
53+
54+
/**
55+
* Residential streetlight or other related customer.
56+
* XSD value: "residentialStreetlightOthers" (line 1709)
57+
*/
58+
@XmlEnumValue("residentialStreetlightOthers")
59+
RESIDENTIAL_STREETLIGHT_OTHERS("residentialStreetlightOthers"),
60+
61+
/**
62+
* Residential farm service customer.
63+
* XSD value: "residentialFarmService" (line 1714)
64+
*/
65+
@XmlEnumValue("residentialFarmService")
66+
RESIDENTIAL_FARM_SERVICE("residentialFarmService"),
67+
68+
/**
69+
* Commercial industrial customer.
70+
* XSD value: "commercialIndustrial" (line 1719)
71+
*/
72+
@XmlEnumValue("commercialIndustrial")
73+
COMMERCIAL_INDUSTRIAL("commercialIndustrial"),
74+
75+
/**
76+
* Pumping load customer.
77+
* XSD value: "pumpingLoad" (line 1724)
78+
*/
79+
@XmlEnumValue("pumpingLoad")
80+
PUMPING_LOAD("pumpingLoad"),
81+
82+
/**
83+
* Wind machine customer.
84+
* XSD value: "windMachine" (line 1729)
85+
*/
86+
@XmlEnumValue("windMachine")
87+
WIND_MACHINE("windMachine"),
88+
89+
/**
90+
* Customer as energy service supplier.
91+
* XSD value: "energyServiceSupplier" (line 1734)
92+
*/
93+
@XmlEnumValue("energyServiceSupplier")
94+
ENERGY_SERVICE_SUPPLIER("energyServiceSupplier"),
95+
96+
/**
97+
* Customer as energy service scheduler.
98+
* XSD value: "energyServiceScheduler" (line 1739)
99+
*/
100+
@XmlEnumValue("energyServiceScheduler")
101+
ENERGY_SERVICE_SCHEDULER("energyServiceScheduler"),
102+
103+
/**
104+
* Represents the owning enterprise.
105+
* XSD value: "enterprise" (line 1744)
106+
*/
107+
@XmlEnumValue("enterprise")
108+
ENTERPRISE("enterprise"),
109+
110+
/**
111+
* Represents a local operator of a larger enterprise.
112+
* XSD value: "regionalOperator" (line 1749)
113+
*/
114+
@XmlEnumValue("regionalOperator")
115+
REGIONAL_OPERATOR("regionalOperator"),
116+
117+
/**
118+
* A subsidiary of a larger enterprise.
119+
* XSD value: "subsidiary" (line 1754)
120+
*/
121+
@XmlEnumValue("subsidiary")
122+
SUBSIDIARY("subsidiary"),
123+
124+
/**
125+
* Internal use customer.
126+
* XSD value: "internalUse" (line 1759)
127+
*/
128+
@XmlEnumValue("internalUse")
129+
INTERNAL_USE("internalUse"),
130+
131+
/**
132+
* Other kind of customer.
133+
* XSD value: "other" (line 1764)
134+
*/
135+
@XmlEnumValue("other")
136+
OTHER("other");
137+
138+
private final String value;
139+
140+
CustomerKind(String value) {
141+
this.value = value;
142+
}
143+
144+
public String getValue() {
145+
return value;
146+
}
147+
148+
public static CustomerKind fromValue(String value) {
149+
for (CustomerKind kind : CustomerKind.values()) {
150+
if (kind.value.equals(value)) {
151+
return kind;
152+
}
153+
}
154+
throw new IllegalArgumentException("Invalid CustomerKind value: " + value);
155+
}
62156
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* Copyright 2025 Green Button Alliance, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.greenbuttonalliance.espi.common.domain.customer.enums;
18+
19+
import jakarta.xml.bind.annotation.XmlEnum;
20+
import jakarta.xml.bind.annotation.XmlEnumValue;
21+
import jakarta.xml.bind.annotation.XmlType;
22+
23+
/**
24+
* Enumeration for EnrollmentStatus values.
25+
*
26+
* [extension] Current Demand Response program enrollment status.
27+
* Per ESPI 4.0 customer.xsd lines 1808-1833.
28+
*/
29+
@XmlType(name = "EnrollmentStatus", namespace = "http://naesb.org/espi/customer")
30+
@XmlEnum
31+
public enum EnrollmentStatus {
32+
33+
/**
34+
* Currently NOT enrolled in the Demand Response program.
35+
* XSD value: "unenrolled" (line 1815)
36+
*/
37+
@XmlEnumValue("unenrolled")
38+
UNENROLLED("unenrolled"),
39+
40+
/**
41+
* Currently enrolled in the Demand Response program.
42+
* XSD value: "enrolled" (line 1820)
43+
*/
44+
@XmlEnumValue("enrolled")
45+
ENROLLED("enrolled"),
46+
47+
/**
48+
* Currently pending enrollment in the Demand Response program.
49+
* XSD value: "enrolledPending" (line 1825)
50+
*/
51+
@XmlEnumValue("enrolledPending")
52+
ENROLLED_PENDING("enrolledPending");
53+
54+
private final String value;
55+
56+
EnrollmentStatus(String value) {
57+
this.value = value;
58+
}
59+
60+
public String getValue() {
61+
return value;
62+
}
63+
64+
public static EnrollmentStatus fromValue(String value) {
65+
for (EnrollmentStatus status : EnrollmentStatus.values()) {
66+
if (status.value.equals(value)) {
67+
return status;
68+
}
69+
}
70+
throw new IllegalArgumentException("Invalid EnrollmentStatus value: " + value);
71+
}
72+
}

0 commit comments

Comments
 (0)