-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MID-9278 always use equals annotation now support marking "self" not …
…only container items
- Loading branch information
Showing
12 changed files
with
113 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
.../java/com/evolveum/midpoint/prism/impl/schema/annotation/AlwaysUseForEqualsProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright (C) 2010-2023 Evolveum and contributors | ||
* | ||
* This work is dual-licensed under the Apache License 2.0 | ||
* and European Union Public License. See LICENSE file for details. | ||
*/ | ||
|
||
package com.evolveum.midpoint.prism.impl.schema.annotation; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
import javax.xml.namespace.QName; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
import org.w3c.dom.Element; | ||
|
||
import com.evolveum.midpoint.prism.ItemDefinition; | ||
import com.evolveum.midpoint.prism.MutableItemDefinition; | ||
import com.evolveum.midpoint.prism.MutablePrismContainerDefinition; | ||
import com.evolveum.midpoint.prism.PrismConstants; | ||
import com.evolveum.midpoint.util.DOMUtil; | ||
import com.evolveum.midpoint.util.exception.SchemaException; | ||
|
||
public class AlwaysUseForEqualsProcessor extends AnnotationProcessor<MutableItemDefinition<?>, QName> { | ||
|
||
public AlwaysUseForEqualsProcessor() { | ||
super(PrismConstants.A_ALWAYS_USE_FOR_EQUALS, QName.class, ItemDefinition.class, null, null); | ||
} | ||
|
||
@Override | ||
public void process(@NotNull MutableItemDefinition<?> definition, @NotNull List<Element> elements) throws SchemaException { | ||
if (elements.isEmpty()) { | ||
return; | ||
} | ||
|
||
if (elements.size() == 1 && elements.get(0).getTextContent().isEmpty()) { | ||
definition.setAlwaysUseForEquals(true); | ||
definition.setAnnotation(PrismConstants.A_ALWAYS_USE_FOR_EQUALS, null); | ||
|
||
return; | ||
} | ||
|
||
if (definition instanceof MutablePrismContainerDefinition<?> pcd) { | ||
List<QName> qnames = elements.stream().map(DOMUtil::getQNameValue).collect(Collectors.toList()); | ||
pcd.setAlwaysUseForEquals(qnames); | ||
|
||
pcd.setAnnotation(PrismConstants.A_ALWAYS_USE_FOR_EQUALS, qnames); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters