-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: media-reference management
- Loading branch information
1 parent
6d6214e
commit c97c550
Showing
9 changed files
with
106 additions
and
45 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
69 changes: 69 additions & 0 deletions
69
src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/MediaReference.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,69 @@ | ||
package com.sitepark.ies.contentrepository.core.domain.entity; | ||
|
||
public class MediaReference { | ||
|
||
private final long mediaId; | ||
final long usedBy; | ||
private final MediaReferenceType type; | ||
|
||
protected MediaReference(Builder builder) { | ||
this.mediaId = builder.mediaId; | ||
this.usedBy = builder.usedBy; | ||
this.type = builder.type; | ||
} | ||
|
||
public long getMediaId() { | ||
return this.mediaId; | ||
} | ||
|
||
public long getUsedBy() { | ||
return this.usedBy; | ||
} | ||
|
||
public MediaReferenceType getType() { | ||
return this.type; | ||
} | ||
|
||
public static Builder builder() { | ||
return new Builder(); | ||
} | ||
|
||
public Builder toBuilder() { | ||
return new Builder(this); | ||
} | ||
|
||
public static class Builder { | ||
|
||
private long mediaId; | ||
private long usedBy; | ||
private MediaReferenceType type; | ||
|
||
protected Builder() {} | ||
|
||
protected Builder(MediaReference media) { | ||
this.mediaId = media.mediaId; | ||
this.usedBy = media.usedBy; | ||
this.type = media.type; | ||
} | ||
|
||
public Builder mediaId(long mediaId) { | ||
assert mediaId > 0; | ||
this.mediaId = mediaId; | ||
return this; | ||
} | ||
|
||
public Builder usedBy(long usedBy) { | ||
assert usedBy > 0; | ||
this.usedBy = usedBy; | ||
return this; | ||
} | ||
public Builder type(MediaReferenceType type) { | ||
assert type != null; | ||
this.type = type; | ||
return this; | ||
} | ||
public MediaReference build() { | ||
return new MediaReference(this); | ||
} | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/MediaReferenceType.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,5 @@ | ||
package com.sitepark.ies.contentrepository.core.domain.entity; | ||
|
||
public enum MediaReferenceType { | ||
EMBEDDED | ||
} |
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
8 changes: 8 additions & 0 deletions
8
src/main/java/com/sitepark/ies/contentrepository/core/port/MediaReferenceManager.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,8 @@ | ||
package com.sitepark.ies.contentrepository.core.port; | ||
|
||
import com.sitepark.ies.contentrepository.core.domain.entity.MediaReference; | ||
|
||
public interface MediaReferenceManager { | ||
void removeByReference(long usedBy); | ||
void addReference(MediaReference reference); | ||
} |
8 changes: 0 additions & 8 deletions
8
src/main/java/com/sitepark/ies/contentrepository/core/port/MediaRepository.java
This file was deleted.
Oops, something went wrong.
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