Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove parameterization so subclasses can use an initializer #3515

Merged
merged 1 commit into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
* }
* </pre>
* @param <T>
* @implNote Every class that inherits from an initializing class needs to define its own Converter.
* Otherwise, the class is parsed as the super class, and its overrides are not called.
*/
public interface Initializing<T extends Initializing<T>> {
public interface Initializing {

T init();
void init();

class Converter<T extends Initializing<T>> extends StdConverter<T, T> {
class Converter<T extends Initializing> extends StdConverter<T, T> {

@Override
public T convert(T value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
@Slf4j
@CPSType(id = "TREE", base = Concept.class)
@JsonDeserialize(converter = TreeConcept.TreeConceptInitializer.class)
public class TreeConcept extends Concept<ConceptTreeConnector> implements ConceptTreeNode<ConceptId>, SelectHolder<UniversalSelect>, Initializing<TreeConcept> {
public class TreeConcept extends Concept<ConceptTreeConnector> implements ConceptTreeNode<ConceptId>, SelectHolder<UniversalSelect>, Initializing {

@JsonIgnore
@Getter
Expand Down Expand Up @@ -90,7 +90,7 @@ public boolean matchesPrefix(int[] conceptPrefix) {
return conceptPrefix != null && conceptPrefix[0] == 0;
}

public TreeConcept init() {
public void init() {
setLocalId(0);
localIdMap.add(this);

Expand Down Expand Up @@ -124,8 +124,6 @@ public TreeConcept init() {

openList.addAll((openList.get(i)).getChildren());
}

return this;
}

public ConceptElement findMostSpecificChild(String stringValue, CalculatedValue<Map<String, Object>> rowMap) throws ConceptConfigurationException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public interface InternToExternMapper extends NamespacedIdentifiable<InternToExt

boolean initialized();

InternToExternMapper init();
void init();

String external(String internalValue);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
@Getter
@JsonDeserialize(converter = MapInternToExternMapper.Initializer.class )
@EqualsAndHashCode(callSuper = true)
public class MapInternToExternMapper extends NamedImpl<InternToExternMapperId> implements InternToExternMapper, NamespacedIdentifiable<InternToExternMapperId>, Initializing<MapInternToExternMapper> {
public class MapInternToExternMapper extends NamedImpl<InternToExternMapperId> implements InternToExternMapper, NamespacedIdentifiable<InternToExternMapperId>, Initializing {


// We inject the service as a non-final property so, jackson will never try to create a serializer for it (in contrast to constructor injection)
Expand Down Expand Up @@ -88,11 +88,11 @@ public class MapInternToExternMapper extends NamedImpl<InternToExternMapperId> i


@Override
public synchronized MapInternToExternMapper init() {
public synchronized void init() {

if (mapIndex == null && config == null) {
log.trace("Injections were null. Skipping init, because class was deserialized by a test object mapper");
return this;
return;
}

dataset = storage.getDataset();
Expand All @@ -114,8 +114,6 @@ public synchronized MapInternToExternMapper init() {
log.warn("Unable to get index: {} (enable TRACE for exception)", key, (Exception) (log.isTraceEnabled() ? e : null));
}
});

return this;
}


Expand Down
Loading