Skip to content

Commit b0f3cbf

Browse files
authored
Merge branch 'develop' into develop
2 parents 66a00d6 + bf20ef1 commit b0f3cbf

File tree

154 files changed

+3068
-1552
lines changed

Some content is hidden

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

154 files changed

+3068
-1552
lines changed

bosk-annotations/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
plugins {
33
id 'bosk.maven-publish'
4-
id 'com.github.spotbugs' version '5.1.5'
4+
id 'com.github.spotbugs' version '6.1.2'
55
}
66

77
java {
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module works.bosk.annotations {
2+
exports works.bosk.annotations;
3+
}

bosk-annotations/src/main/java/works/bosk/annotations/DerivedRecord.java

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

bosk-annotations/src/main/java/works/bosk/annotations/DeserializationPath.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
*
1717
* <pre>
1818
* public class MyDTO implements StateTreeNode {
19-
* {@code @DeserializationPath("a/b/c")}
19+
* &#064;DeserializationPath("a/b/c")
2020
* MyObject field;
2121
* }
2222
*
23-
* public class MyObject extends ReflectiveEntity&lt;MyObject> {
24-
* Reference&lt;MyObject> self;
25-
* Optional&lt;MyObject> nested;
26-
* }
23+
* public record MyObject(
24+
* &#064;Self Reference&lt;MyObject> self,
25+
* Optional&lt;MyObject> nested
26+
* ) extends Entity {}
2727
* </pre>
2828
*
2929
* If we deserialize an instance <code>x</code> of <code>MyDTO</code>, then

bosk-bson/README.md

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

bosk-bson/build.gradle

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

bosk-core/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22

33
This is the subproject for the published `bosk-core` library,
44
containing the minimum essential functionality of Bosk.
5+
Its use is documented in the [User's Guide](../docs/USERS.md).

bosk-core/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ plugins {
33
id 'bosk.development'
44
id 'bosk.maven-publish'
55
id 'info.solidsoft.pitest' version '1.7.4'
6-
id 'com.github.spotbugs' version '5.1.5'
6+
id 'com.github.spotbugs' version '6.1.2'
77
}
88

99
java {
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module works.bosk.core {
2+
requires org.jetbrains.annotations;
3+
requires org.objectweb.asm.util;
4+
requires org.pcollections;
5+
requires org.slf4j;
6+
requires works.bosk.annotations;
7+
requires static lombok;
8+
9+
exports works.bosk;
10+
exports works.bosk.drivers;
11+
exports works.bosk.exceptions;
12+
exports works.bosk.util;
13+
exports works.bosk.bytecode to works.bosk.jackson;
14+
exports works.bosk.logging to works.bosk.mongo, works.bosk.logback;
15+
}

bosk-core/src/main/java/works/bosk/Bosk.java

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import works.bosk.exceptions.ReferenceBindingException;
3737
import works.bosk.util.Classes;
3838

39+
import static java.lang.Thread.holdsLock;
3940
import static java.util.Collections.unmodifiableCollection;
4041
import static java.util.Objects.requireNonNull;
4142
import static java.util.UUID.randomUUID;
@@ -109,9 +110,9 @@ public class Bosk<R extends StateTreeNode> implements BoskInfo<R> {
109110
@SuppressWarnings("this-escape")
110111
public Bosk(String name, Type rootType, DefaultRootFunction<R> defaultRootFunction, DriverFactory<R> driverFactory) {
111112
this.name = name;
113+
this.pathCompiler = PathCompiler.withSourceType(rootType); // Required before rootRef
112114
this.localDriver = new LocalDriver(defaultRootFunction);
113115
this.rootRef = new RootRef(rootType);
114-
this.pathCompiler = PathCompiler.withSourceType(rootType);
115116
try {
116117
validateType(rootType);
117118
} catch (InvalidTypeException e) {
@@ -223,9 +224,9 @@ public <T> void submitConditionalReplacement(Reference<T> target, T newValue, Re
223224
}
224225

225226
@Override
226-
public <T> void submitInitialization(Reference<T> target, T newValue) {
227+
public <T> void submitConditionalCreation(Reference<T> target, T newValue) {
227228
assertCorrectBosk(target);
228-
downstream.submitInitialization(target, newValue);
229+
downstream.submitConditionalCreation(target, newValue);
229230
}
230231

231232
@Override
@@ -277,11 +278,13 @@ private <T> void assertCorrectBosk(Reference<T> target) {
277278
* When it comes to hooks, this provides three guarantees:
278279
*
279280
* <ol><li>
280-
* All updates submitted to this driver are applied to the Bosk state in order.
281+
* Updates submitted to this driver are applied to the Bosk state in the order they were submitted.
281282
* </li><li>
282283
* Hooks are run sequentially: no hook begins until the previous one finishes.
283284
* </li><li>
284-
* Hooks are run in breadth-first fashion.
285+
* Hooks are run in <em>breadth-first</em> fashion:
286+
* hooks triggered by one update run before any hooks triggered by subsequent updates,
287+
* even if those hooks themselves submit more updates.
285288
* </li></ol>
286289
*
287290
* Satisfying all of these simultaneously is tricky, especially because we can't just put
@@ -320,7 +323,7 @@ public <T> void submitReplacement(Reference<T> target, T newValue) {
320323
}
321324

322325
@Override
323-
public <T> void submitInitialization(Reference<T> target, T newValue) {
326+
public <T> void submitConditionalCreation(Reference<T> target, T newValue) {
324327
synchronized (this) {
325328
boolean preconditionsSatisfied;
326329
try (@SuppressWarnings("unused") ReadContext executionContext = supersedingReadContext()) {
@@ -404,7 +407,8 @@ void triggerEverywhere(HookRegistration<?> reg) {
404407
/**
405408
* @return false if the update was ignored
406409
*/
407-
private synchronized <T> boolean tryGraftReplacement(Reference<T> target, T newValue) {
410+
private <T> boolean tryGraftReplacement(Reference<T> target, T newValue) {
411+
assert holdsLock(this);
408412
Dereferencer dereferencer = dereferencerFor(target);
409413
try {
410414
LOGGER.debug("Applying replacement at {}", target);
@@ -428,7 +432,8 @@ private synchronized <T> boolean tryGraftReplacement(Reference<T> target, T newV
428432
/**
429433
* @return false if the update was ignored
430434
*/
431-
private synchronized <T> boolean tryGraftDeletion(Reference<T> target) {
435+
private <T> boolean tryGraftDeletion(Reference<T> target) {
436+
assert holdsLock(this);
432437
Path targetPath = target.path();
433438
assert !targetPath.isEmpty();
434439
Dereferencer dereferencer = dereferencerFor(target);
@@ -977,6 +982,11 @@ public <TT> Reference<Reference<TT>> thenReference(Class<TT> targetClass, Path p
977982
return this.then(Classes.reference(targetClass), path);
978983
}
979984

985+
@Override
986+
public <TT extends VariantCase> Reference<TaggedUnion<TT>> thenTaggedUnion(Class<TT> variantCaseClass, Path path) throws InvalidTypeException {
987+
return this.then(Classes.taggedUnion(variantCaseClass), path);
988+
}
989+
980990
@Override
981991
public BoskDiagnosticContext diagnosticContext() {
982992
return diagnosticContext;
@@ -1035,6 +1045,11 @@ public final <TT> Reference<Reference<TT>> thenReference(Class<TT> targetClass,
10351045
return rootReference().thenReference(targetClass, path.then(segments));
10361046
}
10371047

1048+
@Override
1049+
public <TT extends VariantCase> Reference<TaggedUnion<TT>> thenTaggedUnion(Class<TT> variantCaseClass, String... segments) throws InvalidTypeException {
1050+
return rootReference().thenTaggedUnion(variantCaseClass, path.then(segments));
1051+
}
1052+
10381053
@SuppressWarnings("unchecked")
10391054
@Override
10401055
public final <TT> Reference<TT> enclosingReference(Class<TT> targetClass) {
@@ -1103,7 +1118,7 @@ public final String toString() {
11031118
* A {@link Reference} with no unbound parameters.
11041119
*/
11051120
private sealed class DefiniteReference<T> extends ReferenceImpl<T> {
1106-
@Getter(lazy = true) private final Dereferencer dereferencer = compileVettedPath(path);
1121+
private final Dereferencer dereferencer = compileVettedPath(path);
11071122

11081123
public DefiniteReference(Path path, Type targetType) {
11091124
super(path, targetType);
@@ -1131,6 +1146,10 @@ public void forEachValue(BiConsumer<T, BindingEnvironment> action, BindingEnviro
11311146
action.accept(value, existingEnvironment);
11321147
}
11331148
}
1149+
1150+
public Dereferencer dereferencer() {
1151+
return this.dereferencer;
1152+
}
11341153
}
11351154

11361155
/**

0 commit comments

Comments
 (0)