Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1583 from apache/3409-mixin.eventtypes
merging ... still WIP but has some fixes already (CAUSEWAY-3409: Mixed in members might have the wrong domain-event type associated)
- Loading branch information
Showing
117 changed files
with
5,824 additions
and
6,378 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
99 changes: 99 additions & 0 deletions
99
...del/src/main/java/org/apache/causeway/core/metamodel/facets/DomainEventFacetAbstract.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,99 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.causeway.core.metamodel.facets; | ||
|
||
import java.util.function.BiConsumer; | ||
|
||
import org.apache.causeway.core.metamodel.facetapi.Facet; | ||
import org.apache.causeway.core.metamodel.facetapi.FacetAbstract; | ||
import org.apache.causeway.core.metamodel.facetapi.FacetHolder; | ||
import org.apache.causeway.core.metamodel.spec.ObjectSpecification; | ||
|
||
import lombok.NonNull; | ||
|
||
/** | ||
* Base for any event-type holding facets, | ||
* while defining the facet-type is up to implementors. | ||
*/ | ||
public abstract class DomainEventFacetAbstract<T> | ||
extends FacetAbstract { | ||
|
||
public static enum EventTypeOrigin { | ||
/** {@link #eventType} originates from configured defaults */ | ||
DEFAULT, | ||
/** {@link #eventType} originates from domain object annotation */ | ||
ANNOTATED_OBJECT, | ||
/** {@link #eventType} originates from member annotation */ | ||
ANNOTATED_MEMBER; | ||
public boolean isDefault() { return this==DEFAULT; } | ||
public boolean isAnnotatedObject() { return this==ANNOTATED_OBJECT; } | ||
public boolean isAnnotatedMember() { return this==ANNOTATED_MEMBER; } | ||
} | ||
|
||
private Class<? extends T> eventType; | ||
private EventTypeOrigin eventTypeOrigin; | ||
|
||
protected DomainEventFacetAbstract( | ||
final Class<? extends Facet> facetType, | ||
final Class<? extends T> eventType, | ||
final EventTypeOrigin eventTypeOrigin, | ||
final FacetHolder holder) { | ||
super(facetType, holder); | ||
this.eventType = eventType; | ||
this.eventTypeOrigin = eventTypeOrigin; | ||
} | ||
|
||
public final Class<? extends T> getEventType() { | ||
return eventType; | ||
} | ||
|
||
public final EventTypeOrigin getEventTypeOrigin() { | ||
return eventTypeOrigin; | ||
} | ||
|
||
/** called during meta-model post-processing only */ | ||
protected final void updateEventType( | ||
final Class<? extends T> eventType, | ||
final EventTypeOrigin eventTypeOrigin) { | ||
this.eventType = eventType; | ||
this.eventTypeOrigin = eventTypeOrigin; | ||
} | ||
|
||
/** | ||
* Called by meta-model post-processors, to honor domain object annotations on mixees. | ||
* (required only, if this facet belongs to a mixed-in member) | ||
*/ | ||
public void initWithMixee(final ObjectSpecification mixeeSpec) {} | ||
|
||
|
||
@Override | ||
public void visitAttributes(final BiConsumer<String, Object> visitor) { | ||
super.visitAttributes(visitor); | ||
visitor.accept("eventType", getEventType()); | ||
visitor.accept("eventTypeOrigin", getEventTypeOrigin().name()); | ||
} | ||
|
||
@Override | ||
public boolean semanticEquals(final @NonNull Facet other) { | ||
return other instanceof DomainEventFacetAbstract | ||
? this.getEventType() == ((DomainEventFacetAbstract<?>)other).getEventType() | ||
: false; | ||
} | ||
|
||
} |
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
Oops, something went wrong.