Skip to content

Commit

Permalink
MID-9278 optionalCleanup annotation support added (also resource/sche…
Browse files Browse the repository at this point in the history
…ma/definition marked as first item)
  • Loading branch information
1azyman committed Nov 28, 2023
1 parent 733f646 commit a9cfb4a
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ default boolean isIgnored() {

String getRemovedSince();

boolean isOptionalCleanup();

/**
* Experimental functionality is not stable and it may be changed in any
* future release without any warning. Use at your own risk.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public interface MutableDefinition extends Definition {

void setRemovedSince(String removedSince);

void setOptionalCleanup(boolean optionalCleanup);

void setExperimental(boolean experimental);

void setEmphasized(boolean emphasized);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public class PrismConstants {
public static final QName A_SCHEMA_MIGRATION_VERSION = new QName(NS_ANNOTATION, "version");
public static final QName A_SCHEMA_MIGRATION_OPERATION = new QName(NS_ANNOTATION, "operation");
public static final QName A_SCHEMA_MIGRATION_REPLACEMENT = new QName(NS_ANNOTATION, "replacement");
public static final QName A_OPTIONAL_CLEANUP = new QName(NS_ANNOTATION, "optionalCleanup");
public static final QName A_DEFAULT_PREFIX = new QName(NS_ANNOTATION, "defaultPrefix");
public static final QName A_DIAGRAM = new QName(NS_ANNOTATION, "diagram");
public static final QName A_DIAGRAM_NAME = new QName(NS_ANNOTATION, "name");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ default String getRemovedSince() {
return delegate().getRemovedSince();
}

@Override
default boolean isOptionalCleanup() {
return delegate().isOptionalCleanup();
}

@Override
default boolean isExperimental() {
return delegate().isExperimental();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public abstract class DefinitionImpl extends AbstractFreezable implements Mutabl
protected String deprecatedSince;
protected boolean removed = false;
protected String removedSince;
private boolean optionalCleanup;
protected String plannedRemoval;
protected boolean experimental = false;
protected boolean elaborate = false;
Expand Down Expand Up @@ -148,6 +149,17 @@ public void setRemoved(boolean removed) {
this.removed = removed;
}

@Override
public boolean isOptionalCleanup() {
return optionalCleanup;
}

@Override
public void setOptionalCleanup(boolean optionalCleanup) {
checkMutable();
this.optionalCleanup = optionalCleanup;
}

@Override
public String getRemovedSince() {
return removedSince;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
@Experimental
public class DummyPrismObjectDefinition implements PrismObjectDefinition<Objectable> {

@Override
public boolean isOptionalCleanup() {
throw new UnsupportedOperationException();
}

@Override
public boolean isAlwaysUseForEquals() {
throw new UnsupportedOperationException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ public void process(@NotNull MutableDefinition definition, @NotNull List<Element
OPERATIONAL(new AnnotationProcessor<MutableItemDefinition<?>, Boolean>(
A_OPERATIONAL, Boolean.class, MutableItemDefinition.class, MutableItemDefinition::setOperational, true)),

OPTIONAL_CLEANUP(new AnnotationProcessor<>(
A_OPTIONAL_CLEANUP, Boolean.class, MutableDefinition::setOptionalCleanup, true)),

PLANNED_REMOVAL(new AnnotationProcessor<MutableItemDefinition<?>, String>(
A_PLANNED_REMOVAL, String.class, MutableItemDefinition.class, MutableItemDefinition::setPlannedRemoval, null)),

Expand Down Expand Up @@ -133,7 +136,7 @@ public static void processAnnotation(MutableDefinition definition, XSAnnotation
}

List<Element> elements = SchemaProcessorUtil.getAnnotationElements(xsAnnotation, annotation.processor.name);
if (elements == null || elements.isEmpty()) {
if (elements.isEmpty()) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,14 @@
</xsd:annotation>
</xsd:element>

<xsd:element name="optionalCleanup" type="xsd:boolean">
<xsd:annotation>
<xsd:documentation>
Marks item that could be ignored by SCM tools (e.g. Git), or removed before commit.
</xsd:documentation>
</xsd:annotation>
</xsd:element>

<xsd:element name="composite" type="xsd:boolean">
<xsd:annotation>
<xsd:documentation>
Expand Down

0 comments on commit a9cfb4a

Please sign in to comment.