Skip to content

Commit

Permalink
support old constructor of AspectEntry (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
jywadhwani authored Dec 7, 2021
1 parent 0221886 commit 597e84d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.Value;


Expand All @@ -66,8 +68,9 @@ public abstract class BaseLocalDAO<ASPECT_UNION extends UnionTemplate, URN exten
*
* @param <ASPECT> must be a supported aspect type in {@code ASPECT_UNION}.
*/
@Value
@Data
@Builder
@AllArgsConstructor
static class AspectEntry<ASPECT extends RecordTemplate> {
@Nullable
ASPECT aspect;
Expand All @@ -77,6 +80,12 @@ static class AspectEntry<ASPECT extends RecordTemplate> {

@Builder.Default
boolean isSoftDeleted = false;

public AspectEntry(@Nullable ASPECT aspect, @Nullable ExtraInfo extraInfo) {
this.aspect = aspect;
this.extraInfo = extraInfo;
this.isSoftDeleted = false;
}
}

@Value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ private <T extends RecordTemplate> BaseLocalDAO.AspectEntry<T> makeAspectEntry(T
if (auditStamp != null) {
extraInfo = new ExtraInfo().setAudit(auditStamp);
}
return new BaseLocalDAO.AspectEntry<>(aspect, extraInfo, false);
return new BaseLocalDAO.AspectEntry<>(aspect, extraInfo);
}

private <T extends RecordTemplate> void expectGetLatest(FooUrn urn, Class<T> aspectClass,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,15 +335,15 @@ protected <ASPECT extends RecordTemplate> AspectEntry<ASPECT> getLatest(@Nonnull
final PrimaryKey key = new PrimaryKey(urn.toString(), ModelUtils.getAspectName(aspectClass), 0L);
final EbeanMetadataAspect latest = _server.find(EbeanMetadataAspect.class, key);
if (latest == null) {
return new AspectEntry<>(null, null, false);
return new AspectEntry<>(null, null);
}
final ExtraInfo extraInfo = toExtraInfo(latest);

if (latest.getMetadata().equals(DELETED_VALUE)) {
return new AspectEntry<>(null, extraInfo, true);
}

return new AspectEntry<>(RecordUtils.toRecordTemplate(aspectClass, latest.getMetadata()), extraInfo, false);
return new AspectEntry<>(RecordUtils.toRecordTemplate(aspectClass, latest.getMetadata()), extraInfo);
}

@Nonnull
Expand Down

0 comments on commit 597e84d

Please sign in to comment.