Skip to content

Commit 0f1a430

Browse files
authored
Merge pull request #138 from filip26/feat/v100
V1.0 CBOR-LD prep
2 parents 7694597 + 31f1632 commit 0f1a430

File tree

170 files changed

+3461
-3253
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

170 files changed

+3461
-3253
lines changed

maven-settings.xml

Lines changed: 0 additions & 12 deletions
This file was deleted.

pom.xml

Lines changed: 15 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<groupId>com.apicatalog</groupId>
99
<artifactId>iridium-cbor-ld</artifactId>
10-
<version>0.4.0-SNAPSHOT</version>
10+
<version>0.7.0-SNAPSHOT</version>
1111

1212
<packaging>jar</packaging>
1313
<name>Iridium CBOR-LD</name>
@@ -53,17 +53,13 @@
5353
<maven.compiler.target>17</maven.compiler.target>
5454
<maven.compiler.source>17</maven.compiler.source>
5555

56-
<envSources>src/main/java17</envSources>
57-
5856
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
5957
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
6058

6159
<jakarta.json.version>2.0.1</jakarta.json.version>
62-
<titanium.version>1.6.0</titanium.version>
63-
<carbon.version>0.6.0</carbon.version>
6460

65-
<copper.version>1.0.0</copper.version>
6661
<copper-multibase>1.1.0</copper-multibase>
62+
<copper-multicodec>2.0.0</copper-multicodec>
6763

6864
<cbor-java.version>0.9</cbor-java.version>
6965

@@ -72,6 +68,8 @@
7268
<!-- test resources -->
7369
<junit.version>5.13.4</junit.version>
7470
<jakarta.json.version>2.0.1</jakarta.json.version>
71+
<titanium.version>1.6.0</titanium.version>
72+
7573
</properties>
7674

7775
<dependencies>
@@ -102,8 +100,8 @@
102100

103101
<dependency>
104102
<groupId>com.apicatalog</groupId>
105-
<artifactId>carbon-did</artifactId>
106-
<version>${carbon.version}</version>
103+
<artifactId>copper-multicodec</artifactId>
104+
<version>${copper-multicodec}</version>
107105
</dependency>
108106

109107
<!-- Tests -->
@@ -124,28 +122,6 @@
124122

125123
<build>
126124
<plugins>
127-
<plugin>
128-
<artifactId>maven-jar-plugin</artifactId>
129-
<version>3.4.2</version>
130-
</plugin>
131-
<plugin>
132-
<groupId>org.codehaus.mojo</groupId>
133-
<artifactId>build-helper-maven-plugin</artifactId>
134-
<version>3.6.1</version>
135-
<executions>
136-
<execution>
137-
<phase>generate-sources</phase>
138-
<goals>
139-
<goal>add-source</goal>
140-
</goals>
141-
<configuration>
142-
<sources>
143-
<source>${envSources}</source>
144-
</sources>
145-
</configuration>
146-
</execution>
147-
</executions>
148-
</plugin>
149125
<plugin>
150126
<groupId>org.apache.maven.plugins</groupId>
151127
<artifactId>maven-source-plugin</artifactId>
@@ -177,7 +153,6 @@
177153
<additionalOption>-Xdoclint:none</additionalOption>
178154
</additionalOptions>
179155
</configuration>
180-
181156
</plugin>
182157
<plugin>
183158
<groupId>org.jacoco</groupId>
@@ -199,32 +174,6 @@
199174
</execution>
200175
</executions>
201176
</plugin>
202-
<plugin>
203-
<groupId>org.codehaus.mojo</groupId>
204-
<artifactId>flatten-maven-plugin</artifactId>
205-
<version>1.3.0</version>
206-
<configuration>
207-
<flattenMode>ossrh</flattenMode>
208-
</configuration>
209-
<executions>
210-
<!-- enable flattening -->
211-
<execution>
212-
<id>flatten</id>
213-
<phase>process-resources</phase>
214-
<goals>
215-
<goal>flatten</goal>
216-
</goals>
217-
</execution>
218-
<!-- ensure proper cleanup -->
219-
<execution>
220-
<id>flatten.clean</id>
221-
<phase>clean</phase>
222-
<goals>
223-
<goal>clean</goal>
224-
</goals>
225-
</execution>
226-
</executions>
227-
</plugin>
228177
<plugin>
229178
<artifactId>maven-surefire-plugin</artifactId>
230179
<version>3.5.3</version>
@@ -254,40 +203,21 @@
254203
<goals>
255204
<goal>sign</goal>
256205
</goals>
257-
<configuration>
258-
<gpgArguments>
259-
<arg>--pinentry-mode</arg>
260-
<arg>loopback</arg>
261-
</gpgArguments>
262-
</configuration>
263206
</execution>
264207
</executions>
265208
</plugin>
266-
<plugin>
267-
<groupId>org.sonatype.plugins</groupId>
268-
<artifactId>nexus-staging-maven-plugin</artifactId>
269-
<version>1.7.0</version>
270-
<extensions>true</extensions>
271-
<configuration>
272-
<serverId>ossrh</serverId>
273-
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
274-
<autoReleaseAfterClose>true</autoReleaseAfterClose>
275-
</configuration>
209+
<plugin>
210+
<groupId>org.sonatype.central</groupId>
211+
<artifactId>central-publishing-maven-plugin</artifactId>
212+
<version>0.8.0</version>
213+
<extensions>true</extensions>
214+
<configuration>
215+
<publishingServerId>central</publishingServerId>
216+
<autoPublish>true</autoPublish>
217+
</configuration>
276218
</plugin>
277219
</plugins>
278220
</build>
279-
<distributionManagement>
280-
<repository>
281-
<id>ossrh</id>
282-
<name>Central Repository OSSRH</name>
283-
<url>
284-
https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
285-
</repository>
286-
<snapshotRepository>
287-
<id>ossrh</id>
288-
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
289-
</snapshotRepository>
290-
</distributionManagement>
291221
</profile>
292222
</profiles>
293223
</project>

src/main/java/com/apicatalog/cbor/CborComparison.java

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@ public static final boolean equals(byte[] value1, byte[] value2) throws CborExce
1717
if (value1 == null || value2 == null) {
1818
return value1 == value2;
1919
}
20-
20+
2121
if (value1.length != value2.length) {
2222
return false;
2323
}
24-
24+
2525
final List<DataItem> decoded1 = CborDecoder.decode(value1);
2626
final List<DataItem> decoded2 = CborDecoder.decode(value2);
27-
27+
2828
if (decoded1 == null || decoded2 == null) {
2929
return decoded1 == decoded2;
3030
}
31-
31+
3232
return equals(decoded1, decoded2);
3333
}
3434

@@ -37,56 +37,51 @@ public static final boolean equals(Collection<DataItem> value1, Collection<DataI
3737
if (value1 == null || value2 == null) {
3838
return value1 == value2;
3939
}
40-
40+
4141
if (value1.size() != value2.size()) {
4242
return false;
4343
}
44-
44+
4545
Iterator<DataItem> it1 = value1.iterator();
4646
Iterator<DataItem> it2 = value2.iterator();
47-
47+
4848
while (it1.hasNext()) {
4949
if (!equals(it1.next(), it2.next())) {
5050
return false;
5151
}
5252
}
53-
return true;
53+
return true;
5454
}
5555

5656
public static final boolean equals(DataItem value1, DataItem value2) {
5757

5858
if (value1 == null || value2 == null) {
5959
return value1 == value2;
6060
}
61-
61+
6262
if (value1.getMajorType() != value2.getMajorType()) {
6363
return false;
6464
}
65-
66-
switch (value1.getMajorType()) {
67-
case ARRAY:
68-
return equals(((Array)value1).getDataItems(), ((Array)value2).getDataItems());
69-
70-
case MAP:
71-
return equals((Map)value1, (Map)value2);
72-
73-
default:
74-
return value1.equals(value2);
75-
}
65+
66+
return switch (value1.getMajorType()) {
67+
case ARRAY -> equals(((Array) value1).getDataItems(), ((Array) value2).getDataItems());
68+
case MAP -> equals((Map) value1, (Map) value2);
69+
default -> value1.equals(value2);
70+
};
7671
}
7772

7873
public static final boolean equals(Map value1, Map value2) {
7974

8075
if (value1 == null || value2 == null) {
8176
return value1 == value2;
8277
}
83-
78+
8479
if (value1.getKeys().size() != value2.getKeys().size()) {
8580
return false;
8681
}
87-
82+
8883
final Iterator<DataItem> keys = value1.getKeys().iterator();
89-
84+
9085
while (keys.hasNext()) {
9186
final DataItem key = keys.next();
9287
if (!equals(value1.get(key), value2.get(key))) {

src/main/java/com/apicatalog/cbor/CborWriter.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
public class CborWriter {
1515

1616
final Writer writer;
17-
17+
1818
public CborWriter(Writer writer) {
1919
this.writer = writer;
2020
}
21-
21+
2222
public void write(List<DataItem> value) throws IOException {
23-
23+
2424
writer.write('[');
25-
25+
2626
boolean first = true;
2727

2828
for (final DataItem item : value) {
@@ -32,36 +32,36 @@ public void write(List<DataItem> value) throws IOException {
3232
write(item);
3333
first = false;
3434
}
35-
36-
writer.write(']');
35+
36+
writer.write(']');
3737
}
38-
38+
3939
public void write(DataItem value) throws IOException {
40-
40+
4141
switch (value.getMajorType()) {
4242
case ARRAY:
43-
write(((Array)value).getDataItems());
43+
write(((Array) value).getDataItems());
4444
break;
45-
45+
4646
case MAP:
47-
write((Map)value);
47+
write((Map) value);
4848
break;
49-
49+
5050
case BYTE_STRING:
51-
write((ByteString)value);
51+
write((ByteString) value);
5252
break;
53-
53+
5454
default:
5555
writer.write(value.toString());
5656
}
5757
}
58-
58+
5959
protected void write(Map value) throws IOException {
60-
60+
6161
writer.write('{');
62-
62+
6363
boolean first = true;
64-
64+
6565
for (final DataItem key : value.getKeys()) {
6666
if (!first) {
6767
writer.write(',');

0 commit comments

Comments
 (0)